-
-
Notifications
You must be signed in to change notification settings - Fork 33.8k
Fix colortemp conversion for osramlightify #6516
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
Conversation
Copied from the LIFX fix in 75df4be.
@amelchio, thanks for your PR! By analyzing the history of the files in this pull request, we identified @olimpiurob, @tfriedel and @fabaff to be potential reviewers. |
o_temp = self._light.temp() | ||
self._temperature = int(TEMP_MIN_HASS + (TEMP_MAX_HASS - TEMP_MIN_HASS) | ||
* (o_temp - TEMP_MIN) / (TEMP_MAX - TEMP_MIN)) | ||
self._temperature = color_temperature_kelvin_to_mired(self._light.temp()) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
line too long (81 > 79 characters)
@@ -96,7 +94,7 @@ def __init__(self, light_id, light, update_lights): | |||
self._brightness = 0 | |||
self._rgb = (0, 0, 0) | |||
self._name = "" | |||
self._temperature = TEMP_MIN | |||
self._temperature = 2000 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
While we're doing cleanup here, can you just change self._brightness
, self._rgb
, self._name
, self._temperature
, and self._state
assignments in __init__
to None
? These will get overwritten when self.update()
is called, so it's safer/cleaner to initialize them to None
since it shouldn't matter if everything is working. It's bad practice to preload fake data in the constructor.
Also if you're feeling extra ambitious you can drop the self.update()
call in __init__
, and change add_devices_callback(new_lights)
to add_devices_callback(new_lights, True)
to migrate to the new style and remove IO from the constructor.
@armills: While we're doing cleanup here, can you just change self._brightness, self._rgb, self._name, self._temperature, and self._state assignments in __init__ to None? These will get overwritten when self.update() is called, so it's safer/cleaner to initialize them to None since it shouldn't matter if everything is working.
Sure. I did not like putting the 2000 constant in there in the first place. However, I do not have the hardware to test my modifications so I am not too ambitious. |
Ah, that's fair enough. I think it's pretty clear at least from a visual inspection that all of those attributes get unconditionally assigned in |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks good, but it wouldn't hurt to get a sanity check from someone with the hardware.
The #6498 issue has a success report on my initial commit. |
Ah, didn't see that context. I'm just going to give this some time to let other devs take a look before we merge, since it was just opened. |
When this is merged, I have a follow up PR ready, to add the lightify group feature to HA, similar to how it is handled with hue. |
Thanks 🐬 |
* Fix colortemp conversion for osramlightify Copied from the LIFX fix in 75df4be. * Fix style * Updates from review @armills: While we're doing cleanup here, can you just change self._brightness, self._rgb, self._name, self._temperature, and self._state assignments in __init__ to None? These will get overwritten when self.update() is called, so it's safer/cleaner to initialize them to None since it shouldn't matter if everything is working.
cherry-picked for 0.40 |
Description:
Related issue (if applicable): fixes #6498
Checklist:
If the code communicates with devices, web services, or third-party tools:
tox
run successfully.