From 5fd9b474dca3c9eaca6ad6f86625cc54ba88175f Mon Sep 17 00:00:00 2001 From: Joakim Plate Date: Sun, 3 Nov 2019 20:36:02 +0100 Subject: [PATCH] Always provide brightness value (#28228) HA will remove attribute when light is off, but google expect all trait data all the time. --- homeassistant/components/google_assistant/trait.py | 2 ++ tests/components/google_assistant/test_smart_home.py | 2 +- 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/homeassistant/components/google_assistant/trait.py b/homeassistant/components/google_assistant/trait.py index 7d6e79a8237..6b5530ab2ce 100644 --- a/homeassistant/components/google_assistant/trait.py +++ b/homeassistant/components/google_assistant/trait.py @@ -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 diff --git a/tests/components/google_assistant/test_smart_home.py b/tests/components/google_assistant/test_smart_home.py index 2f7fdb8e131..3c3801b35c6 100644 --- a/tests/components/google_assistant/test_smart_home.py +++ b/tests/components/google_assistant/test_smart_home.py @@ -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,