Osram lightify, removed double set to the lightify bridge in case of brightness changes ()

* osram lightify removed duplicated set in case of brightness changes

* lightify component: anticipate brightness evaluation to handle unconsidered scenario described in the PR request comments (light turned on with color/temperature)

* Correction for travis ci error:
undefined name 'transition'
This commit is contained in:
Riccardo Canta 2017-06-08 20:17:29 +02:00 committed by Anders Melchiorsen
parent 0863d50210
commit 055db05946

View file

@ -157,8 +157,6 @@ class Luminary(Light):
def turn_on(self, **kwargs):
"""Turn the device on."""
self._luminary.set_onoff(1)
if ATTR_TRANSITION in kwargs:
transition = int(kwargs[ATTR_TRANSITION] * 10)
_LOGGER.debug("turn_on requested transition time for light: "
@ -168,6 +166,16 @@ class Luminary(Light):
_LOGGER.debug("turn_on requested transition time for light: "
"%s is: %s", self._name, transition)
if ATTR_BRIGHTNESS in kwargs:
self._brightness = kwargs[ATTR_BRIGHTNESS]
_LOGGER.debug("turn_on requested brightness for light: %s is: %s ",
self._name, self._brightness)
self._luminary.set_luminance(
int(self._brightness / 2.55),
transition)
else:
self._luminary.set_onoff(1)
if ATTR_RGB_COLOR in kwargs:
red, green, blue = kwargs[ATTR_RGB_COLOR]
_LOGGER.debug("turn_on requested ATTR_RGB_COLOR for light:"
@ -191,14 +199,6 @@ class Luminary(Light):
"%s: %s", self._name, kelvin)
self._luminary.set_temperature(kelvin, transition)
if ATTR_BRIGHTNESS in kwargs:
self._brightness = kwargs[ATTR_BRIGHTNESS]
_LOGGER.debug("turn_on requested brightness for light: %s is: %s ",
self._name, self._brightness)
self._luminary.set_luminance(
int(self._brightness / 2.55),
transition)
if ATTR_EFFECT in kwargs:
effect = kwargs.get(ATTR_EFFECT)
if effect == EFFECT_RANDOM: