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

Fix colortemp conversion for osramlightify #6516

Merged
merged 3 commits into from
Mar 11, 2017

Conversation

amelchio
Copy link
Contributor

Description:

Related issue (if applicable): fixes #6498

Checklist:

If the code communicates with devices, web services, or third-party tools:

  • Local tests with tox run successfully.

@mention-bot
Copy link

@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())

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
Copy link
Contributor

@emlove emlove Mar 10, 2017

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.
@amelchio
Copy link
Contributor Author

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.

@emlove
Copy link
Contributor

emlove commented Mar 10, 2017

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 update. I had assumed you had the hardware to double-check. :) It might be a good idea to recruit someone from the forums/chatroom to test it, but it looks pretty safe to me.

Copy link
Contributor

@emlove emlove 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, but it wouldn't hurt to get a sanity check from someone with the hardware.

@amelchio
Copy link
Contributor Author

The #6498 issue has a success report on my initial commit.

@emlove
Copy link
Contributor

emlove commented Mar 10, 2017

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.

@deisi
Copy link
Contributor

deisi commented Mar 11, 2017

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.

@balloob balloob added this to the 0.40 milestone Mar 11, 2017
@balloob balloob merged commit 9a86cca into home-assistant:dev Mar 11, 2017
@balloob
Copy link
Member

balloob commented Mar 11, 2017

Thanks 🐬

balloob pushed a commit that referenced this pull request Mar 11, 2017
* 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.
@balloob
Copy link
Member

balloob commented Mar 11, 2017

cherry-picked for 0.40

@balloob balloob mentioned this pull request Mar 24, 2017
@amelchio amelchio deleted the osramlightify-colortemp branch April 26, 2017 15:44
@home-assistant home-assistant locked and limited conversation to collaborators Aug 12, 2017
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Osramlightify color tempertaure inverted
7 participants