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.
This commit is contained in:
ochlocracy 2019-10-02 18:59:21 -04:00 committed by Jason Hu
parent c43eeee62f
commit 9c1feacd47
2 changed files with 3 additions and 3 deletions

View File

@ -326,7 +326,7 @@ class AlexaColorTemperatureController(AlexaCapibility):
return color_util.color_temperature_mired_to_kelvin( return color_util.color_temperature_mired_to_kelvin(
self.entity.attributes["color_temp"] self.entity.attributes["color_temp"]
) )
return 0 return None
class AlexaPercentageController(AlexaCapibility): class AlexaPercentageController(AlexaCapibility):

View File

@ -294,8 +294,8 @@ async def test_report_colored_temp_light_state(hass):
) )
properties = await reported_properties(hass, "light.test_off") properties = await reported_properties(hass, "light.test_off")
properties.assert_equal( properties.assert_not_has_property(
"Alexa.ColorTemperatureController", "colorTemperatureInKelvin", 0 "Alexa.ColorTemperatureController", "colorTemperatureInKelvin"
) )