Add assumed state to sensehat light.

This commit is contained in:
Paulus Schoutsen 2017-04-29 21:39:27 -07:00 committed by GitHub
parent b815ccc3b8
commit cf664e42cc

View File

@ -82,6 +82,16 @@ class SenseHatLight(Light):
"""Return true if light is on.""" """Return true if light is on."""
return self._is_on return self._is_on
@property
def should_poll(self):
"""Return if we should poll this device."""
return False
@property
def assumed_state(self) -> bool:
"""Return True if unable to access real state of the entity."""
return True
def turn_on(self, **kwargs): def turn_on(self, **kwargs):
"""Instruct the light to turn on and set correct brightness & color.""" """Instruct the light to turn on and set correct brightness & color."""
self._brightness = kwargs.get(ATTR_BRIGHTNESS, 255) self._brightness = kwargs.get(ATTR_BRIGHTNESS, 255)
@ -95,8 +105,10 @@ class SenseHatLight(Light):
int(self._rgb_color[2] * percent_bright)) int(self._rgb_color[2] * percent_bright))
self._is_on = True self._is_on = True
this.schedule_update_ha_state()
def turn_off(self, **kwargs): def turn_off(self, **kwargs):
"""Instruct the light to turn off.""" """Instruct the light to turn off."""
self._sensehat.clear() self._sensehat.clear()
self._is_on = False self._is_on = False
this.schedule_update_ha_state()