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
This commit is contained in:
Bryan York 2018-08-02 13:09:19 -07:00 committed by Paulus Schoutsen
parent 48af5116b3
commit 38928c4c0e
3 changed files with 8 additions and 6 deletions

View file

@ -304,10 +304,12 @@ class ColorTemperatureTrait(_Trait):
def sync_attributes(self): def sync_attributes(self):
"""Return color temperature attributes for a sync request.""" """Return color temperature attributes for a sync request."""
attrs = self.state.attributes attrs = self.state.attributes
# Max Kelvin is Min Mireds K = 1000000 / mireds
# Min Kevin is Max Mireds K = 1000000 / mireds
return { return {
'temperatureMinK': color_util.color_temperature_mired_to_kelvin(
attrs.get(light.ATTR_MIN_MIREDS)),
'temperatureMaxK': color_util.color_temperature_mired_to_kelvin( '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)), attrs.get(light.ATTR_MAX_MIREDS)),
} }

View file

@ -74,8 +74,8 @@ async def test_sync_message(hass):
'willReportState': False, 'willReportState': False,
'attributes': { 'attributes': {
'colorModel': 'rgb', 'colorModel': 'rgb',
'temperatureMinK': 6535, 'temperatureMinK': 2000,
'temperatureMaxK': 2000, 'temperatureMaxK': 6535,
}, },
'roomHint': 'Living Room' 'roomHint': 'Living Room'
}] }]

View file

@ -414,8 +414,8 @@ async def test_color_temperature_light(hass):
})) }))
assert trt.sync_attributes() == { assert trt.sync_attributes() == {
'temperatureMinK': 5000, 'temperatureMinK': 2000,
'temperatureMaxK': 2000, 'temperatureMaxK': 5000,
} }
assert trt.query_attributes() == { assert trt.query_attributes() == {