Fix on state for fibaro light entity (#68914)

This commit is contained in:
rappenze
2022-03-30 19:41:18 +02:00
committed by GitHub
parent 2c245fcfec
commit 4ca4180fd2

View File

@@ -193,9 +193,23 @@ class FibaroLight(FibaroDevice, LightEntity):
self.call_turn_off()
@property
def is_on(self):
"""Return true if device is on."""
return self.current_binary_state
def is_on(self) -> bool | None:
"""Return true if device is on.
Dimmable and RGB lights can be on based on different
properties, so we need to check here several values.
"""
props = self.fibaro_device.properties
if self.current_binary_state:
return True
if "brightness" in props and props.brightness != "0":
return True
if "currentProgram" in props and props.currentProgram != "0":
return True
if "currentProgramID" in props and props.currentProgramID != "0":
return True
return False
async def async_update(self):
"""Update the state."""