Correct Hue mireds for lights (#33597)

pull/33669/head
Paulus Schoutsen 2020-04-04 14:29:03 -07:00 committed by GitHub
parent feed139ae7
commit 0a3ec6fea1
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 44 additions and 36 deletions

View File

@ -278,6 +278,22 @@ class HueLight(Light):
return self.light.action.get("ct") return self.light.action.get("ct")
return self.light.state.get("ct") return self.light.state.get("ct")
@property
def min_mireds(self):
"""Return the coldest color_temp that this light supports."""
if self.is_group:
return super().min_mireds
return self.light.controlcapabilities["ct"]["min"]
@property
def max_mireds(self):
"""Return the warmest color_temp that this light supports."""
if self.is_group:
return super().min_mireds
return self.light.controlcapabilities["ct"]["max"]
@property @property
def is_on(self): def is_on(self):
"""Return true if device is on.""" """Return true if device is on."""

View File

@ -49,6 +49,17 @@ GROUP_RESPONSE = {
"state": {"any_on": True, "all_on": False}, "state": {"any_on": True, "all_on": False},
}, },
} }
LIGHT_1_CAPABILITIES = {
"certified": True,
"control": {
"mindimlevel": 5000,
"maxlumen": 600,
"colorgamuttype": "A",
"colorgamut": [[0.704, 0.296], [0.2151, 0.7106], [0.138, 0.08]],
"ct": {"min": 153, "max": 500},
},
"streaming": {"renderer": True, "proxy": False},
}
LIGHT_1_ON = { LIGHT_1_ON = {
"state": { "state": {
"on": True, "on": True,
@ -62,12 +73,7 @@ LIGHT_1_ON = {
"colormode": "xy", "colormode": "xy",
"reachable": True, "reachable": True,
}, },
"capabilities": { "capabilities": LIGHT_1_CAPABILITIES,
"control": {
"colorgamuttype": "A",
"colorgamut": [[0.704, 0.296], [0.2151, 0.7106], [0.138, 0.08]],
}
},
"type": "Extended color light", "type": "Extended color light",
"name": "Hue Lamp 1", "name": "Hue Lamp 1",
"modelid": "LCT001", "modelid": "LCT001",
@ -88,12 +94,7 @@ LIGHT_1_OFF = {
"colormode": "xy", "colormode": "xy",
"reachable": True, "reachable": True,
}, },
"capabilities": { "capabilities": LIGHT_1_CAPABILITIES,
"control": {
"colorgamuttype": "A",
"colorgamut": [[0.704, 0.296], [0.2151, 0.7106], [0.138, 0.08]],
}
},
"type": "Extended color light", "type": "Extended color light",
"name": "Hue Lamp 1", "name": "Hue Lamp 1",
"modelid": "LCT001", "modelid": "LCT001",
@ -101,6 +102,17 @@ LIGHT_1_OFF = {
"manufacturername": "Philips", "manufacturername": "Philips",
"uniqueid": "456", "uniqueid": "456",
} }
LIGHT_2_CAPABILITIES = {
"certified": True,
"control": {
"mindimlevel": 5000,
"maxlumen": 600,
"colorgamuttype": "A",
"colorgamut": [[0.704, 0.296], [0.2151, 0.7106], [0.138, 0.08]],
"ct": {"min": 153, "max": 500},
},
"streaming": {"renderer": True, "proxy": False},
}
LIGHT_2_OFF = { LIGHT_2_OFF = {
"state": { "state": {
"on": False, "on": False,
@ -114,12 +126,7 @@ LIGHT_2_OFF = {
"colormode": "hs", "colormode": "hs",
"reachable": True, "reachable": True,
}, },
"capabilities": { "capabilities": LIGHT_2_CAPABILITIES,
"control": {
"colorgamuttype": "A",
"colorgamut": [[0.704, 0.296], [0.2151, 0.7106], [0.138, 0.08]],
}
},
"type": "Extended color light", "type": "Extended color light",
"name": "Hue Lamp 2", "name": "Hue Lamp 2",
"modelid": "LCT001", "modelid": "LCT001",
@ -140,12 +147,7 @@ LIGHT_2_ON = {
"colormode": "hs", "colormode": "hs",
"reachable": True, "reachable": True,
}, },
"capabilities": { "capabilities": LIGHT_2_CAPABILITIES,
"control": {
"colorgamuttype": "A",
"colorgamut": [[0.704, 0.296], [0.2151, 0.7106], [0.138, 0.08]],
}
},
"type": "Extended color light", "type": "Extended color light",
"name": "Hue Lamp 2 new", "name": "Hue Lamp 2 new",
"modelid": "LCT001", "modelid": "LCT001",
@ -353,12 +355,7 @@ async def test_new_light_discovered(hass, mock_bridge):
"colormode": "hs", "colormode": "hs",
"reachable": True, "reachable": True,
}, },
"capabilities": { "capabilities": LIGHT_1_CAPABILITIES,
"control": {
"colorgamuttype": "A",
"colorgamut": [[0.704, 0.296], [0.2151, 0.7106], [0.138, 0.08]],
}
},
"type": "Extended color light", "type": "Extended color light",
"name": "Hue Lamp 3", "name": "Hue Lamp 3",
"modelid": "LCT001", "modelid": "LCT001",
@ -518,12 +515,7 @@ async def test_other_light_update(hass, mock_bridge):
"colormode": "hs", "colormode": "hs",
"reachable": True, "reachable": True,
}, },
"capabilities": { "capabilities": LIGHT_2_CAPABILITIES,
"control": {
"colorgamuttype": "A",
"colorgamut": [[0.704, 0.296], [0.2151, 0.7106], [0.138, 0.08]],
}
},
"type": "Extended color light", "type": "Extended color light",
"name": "Hue Lamp 2 new", "name": "Hue Lamp 2 new",
"modelid": "LCT001", "modelid": "LCT001",