From 9c1feacd47671eb4935215c31110b778f3a63eb5 Mon Sep 17 00:00:00 2001 From: ochlocracy <5885236+ochlocracy@users.noreply.github.com> Date: Wed, 2 Oct 2019 18:59:21 -0400 Subject: [PATCH] Fix colorTemperatureInKelvin in Alexa report when light is off (#27107) * Fixes #26405 Return None if light state is off since attribute is unavailable, prevents property from being reported with invalid value of 0. * Update Test to check property is not reported when light state is off. --- homeassistant/components/alexa/capabilities.py | 2 +- tests/components/alexa/test_capabilities.py | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/homeassistant/components/alexa/capabilities.py b/homeassistant/components/alexa/capabilities.py index c8bc76fbe83..b8bd3841a78 100644 --- a/homeassistant/components/alexa/capabilities.py +++ b/homeassistant/components/alexa/capabilities.py @@ -326,7 +326,7 @@ class AlexaColorTemperatureController(AlexaCapibility): return color_util.color_temperature_mired_to_kelvin( self.entity.attributes["color_temp"] ) - return 0 + return None class AlexaPercentageController(AlexaCapibility): diff --git a/tests/components/alexa/test_capabilities.py b/tests/components/alexa/test_capabilities.py index 94c931e3514..d53f145e6ff 100644 --- a/tests/components/alexa/test_capabilities.py +++ b/tests/components/alexa/test_capabilities.py @@ -294,8 +294,8 @@ async def test_report_colored_temp_light_state(hass): ) properties = await reported_properties(hass, "light.test_off") - properties.assert_equal( - "Alexa.ColorTemperatureController", "colorTemperatureInKelvin", 0 + properties.assert_not_has_property( + "Alexa.ColorTemperatureController", "colorTemperatureInKelvin" )