From 38928c4c0e0e0f13f86aec14fa2b8e1d87fb73ea Mon Sep 17 00:00:00 2001 From: Bryan York Date: Thu, 2 Aug 2018 13:09:19 -0700 Subject: [PATCH] Fix Min/Max Kelvin color temp attribute for Google (#15697) * Fix Min/Max Kelvin color temp attribute for Google Max Kelvin is actually Min Mireds and vice-versa. K = 1000000 / mireds * Update test_smart_home.py * Update test_trait.py --- homeassistant/components/google_assistant/trait.py | 6 ++++-- tests/components/google_assistant/test_smart_home.py | 4 ++-- tests/components/google_assistant/test_trait.py | 4 ++-- 3 files changed, 8 insertions(+), 6 deletions(-) diff --git a/homeassistant/components/google_assistant/trait.py b/homeassistant/components/google_assistant/trait.py index 74ee55c5e93..1d369eb87da 100644 --- a/homeassistant/components/google_assistant/trait.py +++ b/homeassistant/components/google_assistant/trait.py @@ -304,10 +304,12 @@ class ColorTemperatureTrait(_Trait): def sync_attributes(self): """Return color temperature attributes for a sync request.""" attrs = self.state.attributes + # Max Kelvin is Min Mireds K = 1000000 / mireds + # Min Kevin is Max Mireds K = 1000000 / mireds return { - 'temperatureMinK': color_util.color_temperature_mired_to_kelvin( - attrs.get(light.ATTR_MIN_MIREDS)), 'temperatureMaxK': color_util.color_temperature_mired_to_kelvin( + attrs.get(light.ATTR_MIN_MIREDS)), + 'temperatureMinK': color_util.color_temperature_mired_to_kelvin( attrs.get(light.ATTR_MAX_MIREDS)), } diff --git a/tests/components/google_assistant/test_smart_home.py b/tests/components/google_assistant/test_smart_home.py index cdaf4200c97..66e7747e06a 100644 --- a/tests/components/google_assistant/test_smart_home.py +++ b/tests/components/google_assistant/test_smart_home.py @@ -74,8 +74,8 @@ async def test_sync_message(hass): 'willReportState': False, 'attributes': { 'colorModel': 'rgb', - 'temperatureMinK': 6535, - 'temperatureMaxK': 2000, + 'temperatureMinK': 2000, + 'temperatureMaxK': 6535, }, 'roomHint': 'Living Room' }] diff --git a/tests/components/google_assistant/test_trait.py b/tests/components/google_assistant/test_trait.py index e6336e05246..1f7ee011e61 100644 --- a/tests/components/google_assistant/test_trait.py +++ b/tests/components/google_assistant/test_trait.py @@ -414,8 +414,8 @@ async def test_color_temperature_light(hass): })) assert trt.sync_attributes() == { - 'temperatureMinK': 5000, - 'temperatureMaxK': 2000, + 'temperatureMinK': 2000, + 'temperatureMaxK': 5000, } assert trt.query_attributes() == {