diff --git a/homeassistant/components/control4/climate.py b/homeassistant/components/control4/climate.py index 2640a5cd02c63f..afc45d33aba01a 100644 --- a/homeassistant/components/control4/climate.py +++ b/homeassistant/components/control4/climate.py @@ -272,7 +272,10 @@ def current_humidity(self) -> int | None: 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: diff --git a/tests/components/control4/test_climate.py b/tests/components/control4/test_climate.py index c77ebee1f654b0..d7e348db9bb59e 100644 --- a/tests/components/control4/test_climate.py +++ b/tests/components/control4/test_climate.py @@ -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", [