Fix invalid min and max color temp in bad ZHA light devices (#81604)
* Fix ZHA default color temps * update testpull/81607/head
parent
64a508be7b
commit
83c6a7e18b
|
@ -98,12 +98,26 @@ class ColorChannel(ZigbeeChannel):
|
||||||
@property
|
@property
|
||||||
def min_mireds(self) -> int:
|
def min_mireds(self) -> int:
|
||||||
"""Return the coldest color_temp that this channel supports."""
|
"""Return the coldest color_temp that this channel supports."""
|
||||||
return self.cluster.get("color_temp_physical_min", self.MIN_MIREDS)
|
min_mireds = self.cluster.get("color_temp_physical_min", self.MIN_MIREDS)
|
||||||
|
if min_mireds == 0:
|
||||||
|
self.warning(
|
||||||
|
"[Min mireds is 0, setting to %s] Please open an issue on the quirks repo to have this device corrected",
|
||||||
|
self.MIN_MIREDS,
|
||||||
|
)
|
||||||
|
min_mireds = self.MIN_MIREDS
|
||||||
|
return min_mireds
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def max_mireds(self) -> int:
|
def max_mireds(self) -> int:
|
||||||
"""Return the warmest color_temp that this channel supports."""
|
"""Return the warmest color_temp that this channel supports."""
|
||||||
return self.cluster.get("color_temp_physical_max", self.MAX_MIREDS)
|
max_mireds = self.cluster.get("color_temp_physical_max", self.MAX_MIREDS)
|
||||||
|
if max_mireds == 0:
|
||||||
|
self.warning(
|
||||||
|
"[Max mireds is 0, setting to %s] Please open an issue on the quirks repo to have this device corrected",
|
||||||
|
self.MAX_MIREDS,
|
||||||
|
)
|
||||||
|
max_mireds = self.MAX_MIREDS
|
||||||
|
return max_mireds
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def hs_supported(self) -> bool:
|
def hs_supported(self) -> bool:
|
||||||
|
|
|
@ -242,7 +242,9 @@ async def eWeLink_light(hass, zigpy_device_mock, zha_device_joined):
|
||||||
color_cluster = zigpy_device.endpoints[1].light_color
|
color_cluster = zigpy_device.endpoints[1].light_color
|
||||||
color_cluster.PLUGGED_ATTR_READS = {
|
color_cluster.PLUGGED_ATTR_READS = {
|
||||||
"color_capabilities": lighting.Color.ColorCapabilities.Color_temperature
|
"color_capabilities": lighting.Color.ColorCapabilities.Color_temperature
|
||||||
| lighting.Color.ColorCapabilities.XY_attributes
|
| lighting.Color.ColorCapabilities.XY_attributes,
|
||||||
|
"color_temp_physical_min": 0,
|
||||||
|
"color_temp_physical_max": 0,
|
||||||
}
|
}
|
||||||
zha_device = await zha_device_joined(zigpy_device)
|
zha_device = await zha_device_joined(zigpy_device)
|
||||||
zha_device.available = True
|
zha_device.available = True
|
||||||
|
@ -1192,6 +1194,8 @@ async def test_transitions(
|
||||||
assert eWeLink_state.state == STATE_ON
|
assert eWeLink_state.state == STATE_ON
|
||||||
assert eWeLink_state.attributes["color_temp"] == 235
|
assert eWeLink_state.attributes["color_temp"] == 235
|
||||||
assert eWeLink_state.attributes["color_mode"] == ColorMode.COLOR_TEMP
|
assert eWeLink_state.attributes["color_mode"] == ColorMode.COLOR_TEMP
|
||||||
|
assert eWeLink_state.attributes["min_mireds"] == 153
|
||||||
|
assert eWeLink_state.attributes["max_mireds"] == 500
|
||||||
|
|
||||||
|
|
||||||
async def async_test_on_off_from_light(hass, cluster, entity_id):
|
async def async_test_on_off_from_light(hass, cluster, entity_id):
|
||||||
|
|
Loading…
Reference in New Issue