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
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -193,9 +193,23 @@ class FibaroLight(FibaroDevice, LightEntity):
self.call_turn_off() self.call_turn_off()
@property @property
def is_on(self): def is_on(self) -> bool | None:
"""Return true if device is on.""" """Return true if device is on.
return self.current_binary_state
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): async def async_update(self):
"""Update the state.""" """Update the state."""