Always provide brightness value (#28228)

HA will remove attribute when light is off, but google expect all trait data all the time.
This commit is contained in:
Joakim Plate 2019-11-03 20:36:02 +01:00 committed by Paulus Schoutsen
parent ecf2e9c0ab
commit 5fd9b474dc
2 changed files with 3 additions and 1 deletions

View File

@ -185,6 +185,8 @@ class BrightnessTrait(_Trait):
brightness = self.state.attributes.get(light.ATTR_BRIGHTNESS)
if brightness is not None:
response["brightness"] = int(100 * (brightness / 255))
else:
response["brightness"] = 0
return response

View File

@ -226,7 +226,7 @@ async def test_query_message(hass):
"payload": {
"devices": {
"light.non_existing": {"online": False},
"light.demo_light": {"on": False, "online": True},
"light.demo_light": {"on": False, "online": True, "brightness": 0},
"light.another_light": {
"on": True,
"online": True,