mirror of
https://github.com/home-assistant/core.git
synced 2025-07-23 21:27:38 +00:00
light.piglow update (#7408)
* light.piglow: brightness control logic update Do not reset brightness when brightness is not explicitly supplied. Based on conversation at: https://github.com/home-assistant/home-assistant/pull/7377#discussion_r114102005 * light.piglow: add assumed state
This commit is contained in:
parent
c35d09d5f0
commit
70ad06d71c
@ -72,6 +72,16 @@ class PiglowLight(Light):
|
||||
"""Flag supported features."""
|
||||
return SUPPORT_PIGLOW
|
||||
|
||||
@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
|
||||
|
||||
@property
|
||||
def is_on(self):
|
||||
"""Return true if light is on."""
|
||||
@ -80,7 +90,9 @@ class PiglowLight(Light):
|
||||
def turn_on(self, **kwargs):
|
||||
"""Instruct the light to turn on."""
|
||||
self._piglow.clear()
|
||||
self._brightness = kwargs.get(ATTR_BRIGHTNESS, 255)
|
||||
|
||||
if ATTR_BRIGHTNESS in kwargs:
|
||||
self._brightness = kwargs[ATTR_BRIGHTNESS]
|
||||
percent_bright = (self._brightness / 255)
|
||||
|
||||
if ATTR_RGB_COLOR in kwargs:
|
||||
@ -92,9 +104,11 @@ class PiglowLight(Light):
|
||||
self._piglow.all(self._brightness)
|
||||
self._piglow.show()
|
||||
self._is_on = True
|
||||
self.schedule_update_ha_state()
|
||||
|
||||
def turn_off(self, **kwargs):
|
||||
"""Instruct the light to turn off."""
|
||||
self._piglow.clear()
|
||||
self._piglow.show()
|
||||
self._is_on = False
|
||||
self.schedule_update_ha_state()
|
||||
|
Loading…
x
Reference in New Issue
Block a user