diff --git a/tests/components/esphome/test_climate.py b/tests/components/esphome/test_climate.py index 065890fd623..cb9a084d094 100644 --- a/tests/components/esphome/test_climate.py +++ b/tests/components/esphome/test_climate.py @@ -1,6 +1,7 @@ """Test ESPHome climates.""" +import math from unittest.mock import call from aioesphomeapi import ( @@ -16,6 +17,7 @@ from aioesphomeapi import ( from homeassistant.components.climate import ( ATTR_CURRENT_HUMIDITY, + ATTR_CURRENT_TEMPERATURE, ATTR_FAN_MODE, ATTR_HUMIDITY, ATTR_HVAC_MODE, @@ -377,3 +379,56 @@ async def test_climate_entity_with_humidity( ) mock_client.climate_command.assert_has_calls([call(key=1, target_humidity=23)]) mock_client.climate_command.reset_mock() + + +async def test_climate_entity_with_inf_value( + hass: HomeAssistant, mock_client: APIClient, mock_generic_device_entry +) -> None: + """Test a generic climate entity with infinite temp.""" + entity_info = [ + ClimateInfo( + object_id="myclimate", + key=1, + name="my climate", + unique_id="my_climate", + supports_current_temperature=True, + supports_two_point_target_temperature=True, + supports_action=True, + visual_min_temperature=10.0, + visual_max_temperature=30.0, + supports_current_humidity=True, + supports_target_humidity=True, + visual_min_humidity=10.1, + visual_max_humidity=29.7, + ) + ] + states = [ + ClimateState( + key=1, + mode=ClimateMode.AUTO, + action=ClimateAction.COOLING, + current_temperature=math.inf, + target_temperature=math.inf, + fan_mode=ClimateFanMode.AUTO, + swing_mode=ClimateSwingMode.BOTH, + current_humidity=20.1, + target_humidity=25.7, + ) + ] + user_service = [] + await mock_generic_device_entry( + mock_client=mock_client, + entity_info=entity_info, + user_service=user_service, + states=states, + ) + state = hass.states.get("climate.test_myclimate") + assert state is not None + assert state.state == HVACMode.AUTO + attributes = state.attributes + assert attributes[ATTR_CURRENT_HUMIDITY] == 20 + assert attributes[ATTR_HUMIDITY] == 26 + assert attributes[ATTR_MAX_HUMIDITY] == 30 + assert attributes[ATTR_MIN_HUMIDITY] == 10 + assert ATTR_TEMPERATURE not in attributes + assert attributes[ATTR_CURRENT_TEMPERATURE] is None