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

Change Osram to use Github lightify dep #4256

Merged
merged 11 commits into from Nov 23, 2016
Merged

Change Osram to use Github lightify dep #4256

merged 11 commits into from Nov 23, 2016

Conversation

tfriedel
Copy link
Contributor

@tfriedel tfriedel commented Nov 6, 2016

Description:

Related issue (if applicable): fixes #3089

Pull request in home-assistant.github.io with documentation (if applicable): home-assistant/home-assistant.github.io#<home-assistant.github.io PR number goes here>

Example entry for configuration.yaml (if applicable):

Checklist:

If user exposed functionality or configuration variables are added/changed:

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

  • Local tests with tox run successfully. Your PR cannot be merged unless tests pass
  • New dependencies have been added to the REQUIREMENTS variable (example).
  • New dependencies are only imported inside functions that use them (example).
  • New dependencies have been added to requirements_all.txt by running script/gen_requirements_all.py.
  • New files were added to .coveragerc.

If the code does not interact with devices:

  • Local tests with tox run successfully. Your PR cannot be merged unless tests pass
  • Tests have been added to verify that the new code works.

…tify/commits/master/osramlightify.py ) from Oct 2, 2016 and changed the REQUIRMENTS line to use the fixed lightify component with thread safety fixes

…tify/commits/master/osramlightify.py ) from Oct 2, 2016 and changed the REQUIRMENTS line to use the fixed lightify component with thread safety fixes
@mention-bot
Copy link

@tfriedel, thanks for your PR! By analyzing the history of the files in this pull request, we identified @olimpiurob, @tchellomello and @fabaff to be potential reviewers.

@@ -19,7 +19,7 @@
SUPPORT_COLOR_TEMP, SUPPORT_RGB_COLOR, SUPPORT_TRANSITION, PLATFORM_SCHEMA)
import homeassistant.helpers.config_validation as cv

REQUIREMENTS = ['lightify==1.0.3']
REQUIREMENTS = ['https://github.com/tfriedel/python-lightify/archive/master.zip#lightify==0.0.4']

Choose a reason for hiding this comment

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

farcy v1.1

  • 80: E501 line too long (97 > 79 characters)


if ATTR_TRANSITION in kwargs:
fade = kwargs[ATTR_TRANSITION] * 10
transition = kwargs[ATTR_TRANSITION] * 10
_LOGGER.debug("turn_on requested transition time for light: %s is: %s ",

Choose a reason for hiding this comment

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

farcy v1.1

  • 80: E501 line too long (84 > 79 characters)

else:
fade = 0
transition = 0
_LOGGER.debug("turn_on requested transition time for light: %s is: %s ",

Choose a reason for hiding this comment

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

farcy v1.1

  • 80: E501 line too long (84 > 79 characters)


if ATTR_BRIGHTNESS in kwargs:
brightness = int(kwargs[ATTR_BRIGHTNESS] / 2.55)
_LOGGER.debug("turn_on requested ATTR_RGB_COLOR for light: %s is: %s %s %s ",

Choose a reason for hiding this comment

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

farcy v1.1

  • 80: E501 line too long (89 > 79 characters)

fade)

self._light.set_luminance(brightness, fade)
kelvin = int(((TEMP_MAX - TEMP_MIN) * (color_t - TEMP_MIN_HASS) / (TEMP_MAX_HASS - TEMP_MIN_HASS)) + TEMP_MIN)

Choose a reason for hiding this comment

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

farcy v1.1

  • 80: E501 line too long (122 > 79 characters)


self._light.set_luminance(brightness, fade)
kelvin = int(((TEMP_MAX - TEMP_MIN) * (color_t - TEMP_MIN_HASS) / (TEMP_MAX_HASS - TEMP_MIN_HASS)) + TEMP_MIN)
_LOGGER.debug("turn_on requested set_temperature for light: %s: %s ",

Choose a reason for hiding this comment

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

farcy v1.1

  • 80: E501 line too long (81 > 79 characters)

self._brightness = kwargs[ATTR_BRIGHTNESS]
_LOGGER.debug("turn_on requested brightness for light: %s is: %s ",
self._light.name, self._brightness)
self._brightness = self._light.set_luminance(int(self._brightness / 2.55), transition)

Choose a reason for hiding this comment

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

farcy v1.1

  • 80: E501 line too long (98 > 79 characters)

random.randrange(0, 255),
random.randrange(0, 255),
transition)
_LOGGER.debug("turn_on requested random effect for light: %s with transition %s ",

Choose a reason for hiding this comment

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

farcy v1.1

  • 80: E501 line too long (98 > 79 characters)

if ATTR_TRANSITION in kwargs:
fade = kwargs[ATTR_TRANSITION] * 10
transition = kwargs[ATTR_TRANSITION] * 10
_LOGGER.debug("turn_off requested transition time for light: %s is: %s ",

Choose a reason for hiding this comment

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

farcy v1.1

  • 80: E501 line too long (85 > 79 characters)

fade = 0
self._light.set_luminance(0, fade)
transition = 0
_LOGGER.debug("turn_off requested transition time for light: %s is: %s ",

Choose a reason for hiding this comment

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

farcy v1.1

  • 80: E501 line too long (85 > 79 characters)

@tfriedel tfriedel closed this Nov 6, 2016
@tfriedel tfriedel reopened this Nov 6, 2016

if ATTR_COLOR_TEMP in kwargs:
color_t = kwargs[ATTR_COLOR_TEMP]
kelvin = int(((TEMP_MAX - TEMP_MIN) * (color_t - TEMP_MIN_HASS) /
(TEMP_MAX_HASS - TEMP_MIN_HASS)) + TEMP_MIN)
self._light.set_temperature(kelvin, fade)
(TEMP_MAX_HASS - TEMP_MIN_HASS)) + TEMP_MIN)

Choose a reason for hiding this comment

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

farcy v1.1

  • 17: E128 continuation line under-indented for visual indent

@robbiet480 robbiet480 changed the title used MindrustUK's version ( https://github.com/MindrustUK/python-ligh… Change Osram to use Github lightify dep Nov 7, 2016
@balloob
Copy link
Member

balloob commented Nov 7, 2016

What is the benefit from switching to your lib instead of a lib published on PyPi?

@tfriedel
Copy link
Contributor Author

tfriedel commented Nov 7, 2016

See this thread
https://community.home-assistant.io/t/written-some-osram-lightify-support/43/49
Basically the guy who published the lib for pypi is not developing the lib
and he did not react to my pull request a month ago. My lib includes fixes
to make it thread safe and more robust. It was unusable for me an other
users before.

Paulus Schoutsen notifications@github.com schrieb am Mo., 7. Nov. 2016,
08:43:

What is the benefit from switching to your lib instead of a lib published
on PyPi?


You are receiving this because you modified the open/close state.
Reply to this email directly, view it on GitHub
#4256 (comment),
or mute the thread
https://github.com/notifications/unsubscribe-auth/ABu6xvnOsdA5qWeNz1jzauje_XpdXYyQks5q7taggaJpZM4Kqr3L
.

@tchellomello
Copy link
Contributor

I have been using this version for some time already and it is very stable and working fine. Thanks for your PR @tfriedel

@@ -19,7 +19,8 @@
SUPPORT_COLOR_TEMP, SUPPORT_RGB_COLOR, SUPPORT_TRANSITION, PLATFORM_SCHEMA)
import homeassistant.helpers.config_validation as cv

REQUIREMENTS = ['lightify==1.0.3']
REQUIREMENTS = ['https://github.com/tfriedel/python-lightify/archive/'
'master.zip#lightify==0.0.4']
Copy link
Member

Choose a reason for hiding this comment

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

Please don't point it at the master branch but at the zip of a specific commit.

You also need to specify the exact version number as is contained in the zip, so I think 1.0.4 ?

@@ -101,6 +104,9 @@ def name(self):
@property
def rgb_color(self):
"""Last RGB color value set."""
_LOGGER.debug("rgb_color light state for light: %s is: %s %s %s ",
self._light.name(), self._light.red(),
self._light.green(), self._light.blue())
return self._light.rgb()
Copy link
Member

Choose a reason for hiding this comment

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

We should not make any requests to lights in properties. Instead, all access has to be moved to the update method and data should be stored in instance variables.


@property
def is_on(self):
"""Update Status to True if device is on."""
self.update_lights()
self.update()
Copy link
Member

Choose a reason for hiding this comment

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

Home Assistant will take care of calling update. You cannot do any I/O inside properties.

@@ -223,6 +223,9 @@ https://github.com/robbiet480/pygtfs/archive/00546724e4bbcb3053110d844ca44e22462
# homeassistant.components.scene.hunterdouglas_powerview
https://github.com/sander76/powerviewApi/archive/246e782d60d5c0addcc98d7899a0186f9d5640b0.zip#powerviewApi==0.3.15

# homeassistant.components.light.osramlightify
https://github.com/tfriedel/python-lightify/archive/master.zip#lightify==0.0.4
Copy link
Member

Choose a reason for hiding this comment

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

This is not in sync anymore with the platform requirement.

@balloob
Copy link
Member

balloob commented Nov 23, 2016

Looks good! 🐬

@balloob balloob merged commit 0c47434 into home-assistant:dev Nov 23, 2016
@home-assistant home-assistant locked and limited conversation to collaborators Mar 17, 2017
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Osram Lightify throwing "struct.error: ubyte" when trying to change colors
5 participants