1
0
mirror of https://github.com/home-assistant/core.git synced 2026-07-09 07:45:11 +01:00

Fix Control4 climate crash when humidity is 'Undefined' (#171015)

This commit is contained in:
Franck Nijhof
2026-05-17 22:45:09 +02:00
parent 37478d33eb
commit a314f7bf64
2 changed files with 38 additions and 1 deletions
+4 -1
View File
@@ -273,7 +273,10 @@ class Control4Climate(Control4Entity, ClimateEntity):
if data is None:
return None
humidity = data.get(CONTROL4_HUMIDITY)
return int(humidity) if humidity is not None else None
try:
return int(humidity) if humidity is not None else None
except ValueError, TypeError:
return None
@property
def hvac_mode(self) -> HVACMode:
+34
View File
@@ -385,6 +385,40 @@ async def test_climate_missing_variables(
assert state.attributes["temperature"] == 68.0
@pytest.mark.parametrize(
"mock_climate_variables",
[
{
123: {
"HVAC_STATE": "Off",
"HVAC_MODE": "Heat",
"TEMPERATURE_F": 72.0,
"HUMIDITY": "Undefined",
"COOL_SETPOINT_F": 75.0,
"HEAT_SETPOINT_F": 68.0,
"SCALE": "FAHRENHEIT",
}
}
],
)
@pytest.mark.usefixtures(
"mock_c4_account",
"mock_c4_director",
"mock_climate_update_variables",
"init_integration",
)
async def test_climate_undefined_humidity(
hass: HomeAssistant,
mock_config_entry: MockConfigEntry,
) -> None:
"""Test climate entity handles 'Undefined' humidity string gracefully."""
state = hass.states.get(ENTITY_ID)
assert state is not None
assert state.state == HVACMode.HEAT
assert state.attributes.get("current_temperature") == 72.0
assert state.attributes.get("current_humidity") is None
@pytest.mark.parametrize(
"mock_climate_variables",
[