From 6b5062eec5ef50cbde1b597f010a0343e68bb0ae Mon Sep 17 00:00:00 2001 From: rappenze Date: Tue, 12 Apr 2022 23:58:52 +0200 Subject: [PATCH] Fix fibaro light state for rgb lights and HC3 (#69884) --- homeassistant/components/fibaro/light.py | 18 ++++++++++++------ 1 file changed, 12 insertions(+), 6 deletions(-) diff --git a/homeassistant/components/fibaro/light.py b/homeassistant/components/fibaro/light.py index 4d1c039f137..e117eac8a90 100644 --- a/homeassistant/components/fibaro/light.py +++ b/homeassistant/components/fibaro/light.py @@ -2,6 +2,7 @@ from __future__ import annotations import asyncio +from contextlib import suppress from functools import partial from homeassistant.components.light import ( @@ -198,16 +199,21 @@ class FibaroLight(FibaroDevice, LightEntity): Dimmable and RGB lights can be on based on different properties, so we need to check here several values. + + JSON for HC2 uses always string, HC3 uses int for integers. """ 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 + with suppress(ValueError, TypeError): + if "brightness" in props and int(props.brightness) != 0: + return True + with suppress(ValueError, TypeError): + if "currentProgram" in props and int(props.currentProgram) != 0: + return True + with suppress(ValueError, TypeError): + if "currentProgramID" in props and int(props.currentProgramID) != 0: + return True return False