Support on-off device in rfxtrx light

This commit is contained in:
Daniel 2016-02-15 10:05:47 +01:00
parent bca3207e0c
commit 0d45470ea6

View File

@ -155,16 +155,18 @@ class RfxtrxLight(Light):
def turn_on(self, **kwargs):
""" Turn the light on. """
brightness = kwargs.get(ATTR_BRIGHTNESS)
if not self._event:
return
if brightness is None:
self._brightness = 100
self._event.device.send_on(rfxtrx.RFXOBJECT.transport)
else:
self._brightness = ((brightness + 4) * 100 // 255 - 1)
if hasattr(self, '_event') and self._event:
self._event.device.send_dim(rfxtrx.RFXOBJECT.transport,
self._brightness)
self._brightness = (self._brightness * 255 // 100)
self._state = True
self.update_ha_state()