Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add unique_id to yeelightsunflower #36311

Merged
merged 1 commit into from
Jun 1, 2020
Merged

Add unique_id to yeelightsunflower #36311

merged 1 commit into from
Jun 1, 2020

Conversation

lindsaymarkward
Copy link
Contributor

Proposed change

Add unique_id so that entity_ids can be changed in the UI.
Fix error that occurred because hs_color (2 values) was set to an RGB color list (3 values); replace hs_color with rgb_color (actual lights only implement RGB).
No changes to configuration.yaml needed.

Type of change

  • Dependency upgrade
  • Bugfix (non-breaking change which fixes an issue)
  • New integration (thank you!)
  • New feature (which adds functionality to an existing integration)
  • Breaking change (fix/feature causing existing functionality to break)
  • Code quality improvements to existing code or addition of tests

Checklist

  • The code change is tested and works locally.
  • Local tests pass. Your PR cannot be merged unless tests pass
  • There is no commented out code in this PR.
  • I have followed the development checklist
  • The code has been formatted using Black (black --fast homeassistant tests)
  • Tests have been added to verify that the new code works.

I have not added any new tests.

The integration reached or maintains the following Integration Quality Scale:

  • No score or internal
  • 🥈 Silver
  • 🥇 Gold
  • 🏆 Platinum

def hs_color(self):
"""Return the color property."""
return self._hs_color
def rgb_color(self):
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This isn't correct. A light entity that supports color needs to implement the hs_color property.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ah, I didn't know that.
Can you help me understand please. When I look at https://developers.home-assistant.io/docs/core/entity/light I don't see the requirement. (I don't see rgb_color either, but I'm not implementing many of those properties).

It works without it, but I'll make it convert the RGB to HS and implement that method.

@@ -45,13 +44,19 @@ def __init__(self, light):
self._available = light.available
self._brightness = light.brightness
self._is_on = light.is_on
self._hs_color = light.rgb_color
self._rgb_color = light.rgb_color
self._unique_id = self.name
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We don't need to include sunflower_ in the unique_id. The entity registry is aware of both the integration domain and the platform domain.

What kind of id is the zid?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It's a 4-digit HEX like 6553 or 287B.
What would you like the unique_id to be instead?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If the zid is unique and stable, just use that. 👍

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

OK. It is unique and stable, so I will.
I had sunflower_ in there to be more descriptive. light.6553 doesn't give as much information, but I guess a user probably knows where their light entities came from :)

@MartinHjelmare MartinHjelmare changed the title Add unique_id, use RGB instead of HS color Add yeelightsunflower unique_id, use RGB instead of HS color May 31, 2020
@MartinHjelmare
Copy link
Member

Please don't mix a feature addition and a bug fix in the same PR. Split these tasks into two separate PRs.

@lindsaymarkward
Copy link
Contributor Author

Thanks for the review @MartinHjelmare . I did notice that I'd missed the platform in the title and that there were two things; obviously not small enough to combine.
If I'm doing two new PRs, should I wait for the first to be merged before starting the second since they're for the same file?

@MartinHjelmare
Copy link
Member

I suggest making a new PR for the color fix and keep this PR for adding unique id.

@lindsaymarkward lindsaymarkward changed the title Add yeelightsunflower unique_id, use RGB instead of HS color Add unique_id to yeelightsunflower May 31, 2020
@lindsaymarkward
Copy link
Contributor Author

How is this now for just adding the unique_id?

Copy link
Member

@MartinHjelmare MartinHjelmare left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good! Thanks!

@bdraco bdraco merged commit a333417 into home-assistant:dev Jun 1, 2020
Copy link
Member

@bdraco bdraco left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants