mirror of
https://github.com/home-assistant/core.git
synced 2025-04-25 17:57:55 +00:00
Change Osram to use Github lightify dep (#4256)
* used MindrustUK's version ( https://github.com/MindrustUK/python-lightify/commits/master/osramlightify.py ) from Oct 2, 2016 and changed the REQUIRMENTS line to use the fixed lightify component with thread safety fixes * reformatted long lines * updated osramlightify requirements in requirements_all.txt * ran script gen_requirements_all.py * rerun requirements gen script on linux * fixed some inspection warnings * zip file points to a specific commit * no requests to lights in properties, instead instance variables are update in update method * regenerated requirements_all.txt * removed call to update from is_on() property
This commit is contained in:
parent
1d8a1df2c4
commit
0c47434aad
@ -19,7 +19,8 @@ from homeassistant.components.light import (
|
|||||||
SUPPORT_COLOR_TEMP, SUPPORT_RGB_COLOR, SUPPORT_TRANSITION, PLATFORM_SCHEMA)
|
SUPPORT_COLOR_TEMP, SUPPORT_RGB_COLOR, SUPPORT_TRANSITION, PLATFORM_SCHEMA)
|
||||||
import homeassistant.helpers.config_validation as cv
|
import homeassistant.helpers.config_validation as cv
|
||||||
|
|
||||||
REQUIREMENTS = ['lightify==1.0.3']
|
REQUIREMENTS = ['https://github.com/tfriedel/python-lightify/archive/'
|
||||||
|
'd6eadcf311e6e21746182d1480e97b350dda2b3e.zip#lightify==1.0.4']
|
||||||
|
|
||||||
_LOGGER = logging.getLogger(__name__)
|
_LOGGER = logging.getLogger(__name__)
|
||||||
|
|
||||||
@ -92,37 +93,43 @@ class OsramLightifyLight(Light):
|
|||||||
self._light = light
|
self._light = light
|
||||||
self._light_id = light_id
|
self._light_id = light_id
|
||||||
self.update_lights = update_lights
|
self.update_lights = update_lights
|
||||||
|
self._brightness = 0
|
||||||
|
self._rgb = (0, 0, 0)
|
||||||
|
self._name = ""
|
||||||
|
self._temperature = TEMP_MIN
|
||||||
|
self._state = False
|
||||||
|
self.update()
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def name(self):
|
def name(self):
|
||||||
"""Return the name of the device if any."""
|
"""Return the name of the device if any."""
|
||||||
return self._light.name()
|
return self._name
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def rgb_color(self):
|
def rgb_color(self):
|
||||||
"""Last RGB color value set."""
|
"""Last RGB color value set."""
|
||||||
return self._light.rgb()
|
_LOGGER.debug("rgb_color light state for light: %s is: %s %s %s ",
|
||||||
|
self._name, self._rgb[0], self._rgb[1], self._rgb[2])
|
||||||
|
return self._rgb
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def color_temp(self):
|
def color_temp(self):
|
||||||
"""Return the color temperature."""
|
"""Return the color temperature."""
|
||||||
o_temp = self._light.temp()
|
return self._temperature
|
||||||
temperature = int(TEMP_MIN_HASS + (TEMP_MAX_HASS - TEMP_MIN_HASS) *
|
|
||||||
(o_temp - TEMP_MIN) / (TEMP_MAX - TEMP_MIN))
|
|
||||||
return temperature
|
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def brightness(self):
|
def brightness(self):
|
||||||
"""Brightness of this light between 0..255."""
|
"""Brightness of this light between 0..255."""
|
||||||
return int(self._light.lum() * 2.55)
|
_LOGGER.debug("brightness for light %s is: %s",
|
||||||
|
self._name, self._brightness)
|
||||||
|
return self._brightness
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def is_on(self):
|
def is_on(self):
|
||||||
"""Update Status to True if device is on."""
|
"""Update Status to True if device is on."""
|
||||||
self.update_lights()
|
|
||||||
_LOGGER.debug("is_on light state for light: %s is: %s",
|
_LOGGER.debug("is_on light state for light: %s is: %s",
|
||||||
self._light.name(), self._light.on())
|
self._name, self._state)
|
||||||
return self._light.on()
|
return self._state
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def supported_features(self):
|
def supported_features(self):
|
||||||
@ -131,47 +138,86 @@ class OsramLightifyLight(Light):
|
|||||||
|
|
||||||
def turn_on(self, **kwargs):
|
def turn_on(self, **kwargs):
|
||||||
"""Turn the device on."""
|
"""Turn the device on."""
|
||||||
brightness = 100
|
_LOGGER.debug("turn_on Attempting to turn on light: %s ",
|
||||||
if self.brightness:
|
self._name)
|
||||||
brightness = int(self.brightness / 2.55)
|
|
||||||
|
self._light.set_onoff(1)
|
||||||
|
self._state = self._light.on()
|
||||||
|
|
||||||
if ATTR_TRANSITION in kwargs:
|
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 ",
|
||||||
|
self._name, transition)
|
||||||
else:
|
else:
|
||||||
fade = 0
|
transition = 0
|
||||||
|
_LOGGER.debug("turn_on requested transition time for light:"
|
||||||
|
" %s is: %s ",
|
||||||
|
self._name, transition)
|
||||||
|
|
||||||
if ATTR_RGB_COLOR in kwargs:
|
if ATTR_RGB_COLOR in kwargs:
|
||||||
red, green, blue = kwargs[ATTR_RGB_COLOR]
|
red, green, blue = kwargs[ATTR_RGB_COLOR]
|
||||||
self._light.set_rgb(red, green, blue, fade)
|
_LOGGER.debug("turn_on requested ATTR_RGB_COLOR for light:"
|
||||||
|
" %s is: %s %s %s ",
|
||||||
if ATTR_BRIGHTNESS in kwargs:
|
self._name, red, green, blue)
|
||||||
brightness = int(kwargs[ATTR_BRIGHTNESS] / 2.55)
|
self._light.set_rgb(red, green, blue, transition)
|
||||||
|
|
||||||
if ATTR_COLOR_TEMP in kwargs:
|
if ATTR_COLOR_TEMP in kwargs:
|
||||||
color_t = kwargs[ATTR_COLOR_TEMP]
|
color_t = kwargs[ATTR_COLOR_TEMP]
|
||||||
kelvin = int(((TEMP_MAX - TEMP_MIN) * (color_t - TEMP_MIN_HASS) /
|
kelvin = int(((TEMP_MAX - TEMP_MIN) * (color_t - TEMP_MIN_HASS) /
|
||||||
(TEMP_MAX_HASS - TEMP_MIN_HASS)) + TEMP_MIN)
|
(TEMP_MAX_HASS - TEMP_MIN_HASS)) + TEMP_MIN)
|
||||||
self._light.set_temperature(kelvin, fade)
|
_LOGGER.debug("turn_on requested set_temperature for light:"
|
||||||
|
" %s: %s ", self._name, kelvin)
|
||||||
|
self._light.set_temperature(kelvin, transition)
|
||||||
|
|
||||||
effect = kwargs.get(ATTR_EFFECT)
|
if ATTR_BRIGHTNESS in kwargs:
|
||||||
if effect == EFFECT_RANDOM:
|
self._brightness = kwargs[ATTR_BRIGHTNESS]
|
||||||
self._light.set_rgb(random.randrange(0, 255),
|
_LOGGER.debug("turn_on requested brightness for light: %s is: %s ",
|
||||||
random.randrange(0, 255),
|
self._name, self._brightness)
|
||||||
random.randrange(0, 255),
|
self._brightness = self._light.set_luminance(
|
||||||
fade)
|
int(self._brightness / 2.55),
|
||||||
|
transition)
|
||||||
|
|
||||||
|
if ATTR_EFFECT in kwargs:
|
||||||
|
effect = kwargs.get(ATTR_EFFECT)
|
||||||
|
if effect == EFFECT_RANDOM:
|
||||||
|
self._light.set_rgb(random.randrange(0, 255),
|
||||||
|
random.randrange(0, 255),
|
||||||
|
random.randrange(0, 255),
|
||||||
|
transition)
|
||||||
|
_LOGGER.debug("turn_on requested random effect for light:"
|
||||||
|
" %s with transition %s ",
|
||||||
|
self._name, transition)
|
||||||
|
|
||||||
self._light.set_luminance(brightness, fade)
|
|
||||||
self.update_ha_state()
|
self.update_ha_state()
|
||||||
|
|
||||||
def turn_off(self, **kwargs):
|
def turn_off(self, **kwargs):
|
||||||
"""Turn the device off."""
|
"""Turn the device off."""
|
||||||
|
_LOGGER.debug("turn_off Attempting to turn off light: %s ",
|
||||||
|
self._name)
|
||||||
if ATTR_TRANSITION in kwargs:
|
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 ",
|
||||||
|
self._name, transition)
|
||||||
|
self._light.set_luminance(0, transition)
|
||||||
else:
|
else:
|
||||||
fade = 0
|
transition = 0
|
||||||
self._light.set_luminance(0, fade)
|
_LOGGER.debug("turn_off requested transition time for light:"
|
||||||
|
" %s is: %s ",
|
||||||
|
self._name, transition)
|
||||||
|
self._light.set_onoff(0)
|
||||||
|
self._state = self._light.on()
|
||||||
|
|
||||||
self.update_ha_state()
|
self.update_ha_state()
|
||||||
|
|
||||||
def update(self):
|
def update(self):
|
||||||
"""Synchronize state with bridge."""
|
"""Synchronize state with bridge."""
|
||||||
self.update_lights(no_throttle=True)
|
self.update_lights(no_throttle=True)
|
||||||
|
self._brightness = int(self._light.lum() * 2.55)
|
||||||
|
self._name = self._light.name()
|
||||||
|
self._rgb = self._light.rgb()
|
||||||
|
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._state = self._light.on()
|
||||||
|
@ -226,6 +226,9 @@ https://github.com/robbiet480/pygtfs/archive/00546724e4bbcb3053110d844ca44e22462
|
|||||||
# homeassistant.components.scene.hunterdouglas_powerview
|
# homeassistant.components.scene.hunterdouglas_powerview
|
||||||
https://github.com/sander76/powerviewApi/archive/246e782d60d5c0addcc98d7899a0186f9d5640b0.zip#powerviewApi==0.3.15
|
https://github.com/sander76/powerviewApi/archive/246e782d60d5c0addcc98d7899a0186f9d5640b0.zip#powerviewApi==0.3.15
|
||||||
|
|
||||||
|
# homeassistant.components.light.osramlightify
|
||||||
|
https://github.com/tfriedel/python-lightify/archive/d6eadcf311e6e21746182d1480e97b350dda2b3e.zip#lightify==1.0.4
|
||||||
|
|
||||||
# homeassistant.components.mysensors
|
# homeassistant.components.mysensors
|
||||||
https://github.com/theolind/pymysensors/archive/0b705119389be58332f17753c53167f551254b6c.zip#pymysensors==0.8
|
https://github.com/theolind/pymysensors/archive/0b705119389be58332f17753c53167f551254b6c.zip#pymysensors==0.8
|
||||||
|
|
||||||
@ -258,9 +261,6 @@ libnacl==1.5.0
|
|||||||
# homeassistant.components.light.lifx
|
# homeassistant.components.light.lifx
|
||||||
liffylights==0.9.4
|
liffylights==0.9.4
|
||||||
|
|
||||||
# homeassistant.components.light.osramlightify
|
|
||||||
lightify==1.0.3
|
|
||||||
|
|
||||||
# homeassistant.components.light.limitlessled
|
# homeassistant.components.light.limitlessled
|
||||||
limitlessled==1.0.2
|
limitlessled==1.0.2
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user