mirror of
https://github.com/home-assistant/core.git
synced 2025-07-19 11:17:21 +00:00
Add assumed state to sensehat light.
This commit is contained in:
parent
b815ccc3b8
commit
cf664e42cc
@ -82,6 +82,16 @@ class SenseHatLight(Light):
|
||||
"""Return true if light 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):
|
||||
"""Instruct the light to turn on and set correct brightness & color."""
|
||||
self._brightness = kwargs.get(ATTR_BRIGHTNESS, 255)
|
||||
@ -95,8 +105,10 @@ class SenseHatLight(Light):
|
||||
int(self._rgb_color[2] * percent_bright))
|
||||
|
||||
self._is_on = True
|
||||
this.schedule_update_ha_state()
|
||||
|
||||
def turn_off(self, **kwargs):
|
||||
"""Instruct the light to turn off."""
|
||||
self._sensehat.clear()
|
||||
self._is_on = False
|
||||
this.schedule_update_ha_state()
|
||||
|
Loading…
x
Reference in New Issue
Block a user