diff --git a/homeassistant/components/homekit_controller/climate.py b/homeassistant/components/homekit_controller/climate.py index 9c8e15b1002..44ecee13875 100644 --- a/homeassistant/components/homekit_controller/climate.py +++ b/homeassistant/components/homekit_controller/climate.py @@ -20,22 +20,16 @@ from homeassistant.components.climate import ( DEFAULT_MAX_TEMP, DEFAULT_MIN_TEMP, ClimateEntity, - ClimateEntityFeature, ) from homeassistant.components.climate.const import ( ATTR_HVAC_MODE, ATTR_TARGET_TEMP_HIGH, ATTR_TARGET_TEMP_LOW, - CURRENT_HVAC_COOL, - CURRENT_HVAC_HEAT, - CURRENT_HVAC_IDLE, - CURRENT_HVAC_OFF, - HVAC_MODE_COOL, - HVAC_MODE_HEAT, - HVAC_MODE_HEAT_COOL, - HVAC_MODE_OFF, SWING_OFF, SWING_VERTICAL, + ClimateEntityFeature, + HVACAction, + HVACMode, ) from homeassistant.config_entries import ConfigEntry from homeassistant.const import ATTR_TEMPERATURE, TEMP_CELSIUS @@ -48,16 +42,16 @@ _LOGGER = logging.getLogger(__name__) # Map of Homekit operation modes to hass modes MODE_HOMEKIT_TO_HASS = { - HeatingCoolingTargetValues.OFF: HVAC_MODE_OFF, - HeatingCoolingTargetValues.HEAT: HVAC_MODE_HEAT, - HeatingCoolingTargetValues.COOL: HVAC_MODE_COOL, - HeatingCoolingTargetValues.AUTO: HVAC_MODE_HEAT_COOL, + HeatingCoolingTargetValues.OFF: HVACMode.OFF, + HeatingCoolingTargetValues.HEAT: HVACMode.HEAT, + HeatingCoolingTargetValues.COOL: HVACMode.COOL, + HeatingCoolingTargetValues.AUTO: HVACMode.HEAT_COOL, } CURRENT_MODE_HOMEKIT_TO_HASS = { - HeatingCoolingCurrentValues.IDLE: CURRENT_HVAC_IDLE, - HeatingCoolingCurrentValues.HEATING: CURRENT_HVAC_HEAT, - HeatingCoolingCurrentValues.COOLING: CURRENT_HVAC_COOL, + HeatingCoolingCurrentValues.IDLE: HVACAction.IDLE, + HeatingCoolingCurrentValues.HEATING: HVACAction.HEATING, + HeatingCoolingCurrentValues.COOLING: HVACAction.COOLING, } SWING_MODE_HOMEKIT_TO_HASS = { @@ -66,16 +60,16 @@ SWING_MODE_HOMEKIT_TO_HASS = { } CURRENT_HEATER_COOLER_STATE_HOMEKIT_TO_HASS = { - CurrentHeaterCoolerStateValues.INACTIVE: CURRENT_HVAC_OFF, - CurrentHeaterCoolerStateValues.IDLE: CURRENT_HVAC_IDLE, - CurrentHeaterCoolerStateValues.HEATING: CURRENT_HVAC_HEAT, - CurrentHeaterCoolerStateValues.COOLING: CURRENT_HVAC_COOL, + CurrentHeaterCoolerStateValues.INACTIVE: HVACAction.OFF, + CurrentHeaterCoolerStateValues.IDLE: HVACAction.IDLE, + CurrentHeaterCoolerStateValues.HEATING: HVACAction.HEATING, + CurrentHeaterCoolerStateValues.COOLING: HVACAction.COOLING, } TARGET_HEATER_COOLER_STATE_HOMEKIT_TO_HASS = { - TargetHeaterCoolerStateValues.AUTOMATIC: HVAC_MODE_HEAT_COOL, - TargetHeaterCoolerStateValues.HEAT: HVAC_MODE_HEAT, - TargetHeaterCoolerStateValues.COOL: HVAC_MODE_COOL, + TargetHeaterCoolerStateValues.AUTOMATIC: HVACMode.HEAT_COOL, + TargetHeaterCoolerStateValues.HEAT: HVACMode.HEAT, + TargetHeaterCoolerStateValues.COOL: HVACMode.COOL, } # Map of hass operation modes to homekit modes @@ -146,14 +140,14 @@ class HomeKitHeaterCoolerEntity(HomeKitEntity, ClimateEntity): hvac_mode, ) - async def async_set_hvac_mode(self, hvac_mode: str) -> None: + async def async_set_hvac_mode(self, hvac_mode: HVACMode) -> None: """Set new target operation mode.""" - if hvac_mode == HVAC_MODE_OFF: + if hvac_mode == HVACMode.OFF: await self.async_put_characteristics( {CharacteristicsTypes.ACTIVE: ActivationStateValues.INACTIVE} ) return - if hvac_mode not in {HVAC_MODE_HEAT, HVAC_MODE_COOL}: + if hvac_mode not in {HVACMode.HEAT, HVACMode.COOL}: _LOGGER.warning( "HomeKit device %s: Setting temperature in %s mode is not supported yet;" " Consider raising a ticket if you have this device and want to help us implement this feature", @@ -256,7 +250,7 @@ class HomeKitHeaterCoolerEntity(HomeKitEntity, ClimateEntity): return super().max_temp @property - def hvac_action(self) -> str | None: + def hvac_action(self) -> HVACAction | None: """Return the current running hvac operation.""" # This characteristic describes the current mode of a device, # e.g. a thermostat is "heating" a room to 75 degrees Fahrenheit. @@ -265,12 +259,12 @@ class HomeKitHeaterCoolerEntity(HomeKitEntity, ClimateEntity): self.service.value(CharacteristicsTypes.ACTIVE) == ActivationStateValues.INACTIVE ): - return CURRENT_HVAC_OFF + return HVACAction.OFF value = self.service.value(CharacteristicsTypes.CURRENT_HEATER_COOLER_STATE) return CURRENT_HEATER_COOLER_STATE_HOMEKIT_TO_HASS.get(value) @property - def hvac_mode(self) -> str: + def hvac_mode(self) -> HVACMode: """Return hvac operation ie. heat, cool mode.""" # This characteristic describes the target mode # E.g. should the device start heating a room if the temperature @@ -280,12 +274,12 @@ class HomeKitHeaterCoolerEntity(HomeKitEntity, ClimateEntity): self.service.value(CharacteristicsTypes.ACTIVE) == ActivationStateValues.INACTIVE ): - return HVAC_MODE_OFF + return HVACMode.OFF value = self.service.value(CharacteristicsTypes.TARGET_HEATER_COOLER_STATE) return TARGET_HEATER_COOLER_STATE_HOMEKIT_TO_HASS[value] @property - def hvac_modes(self) -> list[str]: + def hvac_modes(self) -> list[HVACMode]: """Return the list of available hvac operation modes.""" valid_values = clamp_enum_to_char( TargetHeaterCoolerStateValues, @@ -294,7 +288,7 @@ class HomeKitHeaterCoolerEntity(HomeKitEntity, ClimateEntity): modes = [ TARGET_HEATER_COOLER_STATE_HOMEKIT_TO_HASS[mode] for mode in valid_values ] - modes.append(HVAC_MODE_OFF) + modes.append(HVACMode.OFF) return modes @property @@ -380,7 +374,7 @@ class HomeKitClimateEntity(HomeKitEntity, ClimateEntity): cool_temp = kwargs.get(ATTR_TARGET_TEMP_HIGH) if ( - (mode == HVAC_MODE_HEAT_COOL) + (mode == HVACMode.HEAT_COOL) and ( ClimateEntityFeature.TARGET_TEMPERATURE_RANGE & self.supported_features ) @@ -407,7 +401,7 @@ class HomeKitClimateEntity(HomeKitEntity, ClimateEntity): {CharacteristicsTypes.RELATIVE_HUMIDITY_TARGET: humidity} ) - async def async_set_hvac_mode(self, hvac_mode: str) -> None: + async def async_set_hvac_mode(self, hvac_mode: HVACMode) -> None: """Set new target operation mode.""" await self.async_put_characteristics( { @@ -426,8 +420,8 @@ class HomeKitClimateEntity(HomeKitEntity, ClimateEntity): def target_temperature(self) -> float | None: """Return the temperature we try to reach.""" value = self.service.value(CharacteristicsTypes.HEATING_COOLING_TARGET) - if (MODE_HOMEKIT_TO_HASS.get(value) in {HVAC_MODE_HEAT, HVAC_MODE_COOL}) or ( - (MODE_HOMEKIT_TO_HASS.get(value) in {HVAC_MODE_HEAT_COOL}) + if (MODE_HOMEKIT_TO_HASS.get(value) in {HVACMode.HEAT, HVACMode.COOL}) or ( + (MODE_HOMEKIT_TO_HASS.get(value) in {HVACMode.HEAT_COOL}) and not ( ClimateEntityFeature.TARGET_TEMPERATURE_RANGE & self.supported_features ) @@ -439,7 +433,7 @@ class HomeKitClimateEntity(HomeKitEntity, ClimateEntity): def target_temperature_high(self) -> float | None: """Return the highbound target temperature we try to reach.""" value = self.service.value(CharacteristicsTypes.HEATING_COOLING_TARGET) - if (MODE_HOMEKIT_TO_HASS.get(value) in {HVAC_MODE_HEAT_COOL}) and ( + if (MODE_HOMEKIT_TO_HASS.get(value) in {HVACMode.HEAT_COOL}) and ( ClimateEntityFeature.TARGET_TEMPERATURE_RANGE & self.supported_features ): return self.service.value( @@ -451,7 +445,7 @@ class HomeKitClimateEntity(HomeKitEntity, ClimateEntity): def target_temperature_low(self) -> float | None: """Return the lowbound target temperature we try to reach.""" value = self.service.value(CharacteristicsTypes.HEATING_COOLING_TARGET) - if (MODE_HOMEKIT_TO_HASS.get(value) in {HVAC_MODE_HEAT_COOL}) and ( + if (MODE_HOMEKIT_TO_HASS.get(value) in {HVACMode.HEAT_COOL}) and ( ClimateEntityFeature.TARGET_TEMPERATURE_RANGE & self.supported_features ): return self.service.value( @@ -463,7 +457,7 @@ class HomeKitClimateEntity(HomeKitEntity, ClimateEntity): def min_temp(self) -> float: """Return the minimum target temp.""" value = self.service.value(CharacteristicsTypes.HEATING_COOLING_TARGET) - if (MODE_HOMEKIT_TO_HASS.get(value) in {HVAC_MODE_HEAT_COOL}) and ( + if (MODE_HOMEKIT_TO_HASS.get(value) in {HVACMode.HEAT_COOL}) and ( ClimateEntityFeature.TARGET_TEMPERATURE_RANGE & self.supported_features ): min_temp = self.service[ @@ -472,9 +466,9 @@ class HomeKitClimateEntity(HomeKitEntity, ClimateEntity): if min_temp is not None: return min_temp elif MODE_HOMEKIT_TO_HASS.get(value) in { - HVAC_MODE_HEAT, - HVAC_MODE_COOL, - HVAC_MODE_HEAT_COOL, + HVACMode.HEAT, + HVACMode.COOL, + HVACMode.HEAT_COOL, }: min_temp = self.service[CharacteristicsTypes.TEMPERATURE_TARGET].minValue if min_temp is not None: @@ -485,7 +479,7 @@ class HomeKitClimateEntity(HomeKitEntity, ClimateEntity): def max_temp(self) -> float: """Return the maximum target temp.""" value = self.service.value(CharacteristicsTypes.HEATING_COOLING_TARGET) - if (MODE_HOMEKIT_TO_HASS.get(value) in {HVAC_MODE_HEAT_COOL}) and ( + if (MODE_HOMEKIT_TO_HASS.get(value) in {HVACMode.HEAT_COOL}) and ( ClimateEntityFeature.TARGET_TEMPERATURE_RANGE & self.supported_features ): max_temp = self.service[ @@ -494,9 +488,9 @@ class HomeKitClimateEntity(HomeKitEntity, ClimateEntity): if max_temp is not None: return max_temp elif MODE_HOMEKIT_TO_HASS.get(value) in { - HVAC_MODE_HEAT, - HVAC_MODE_COOL, - HVAC_MODE_HEAT_COOL, + HVACMode.HEAT, + HVACMode.COOL, + HVACMode.HEAT_COOL, }: max_temp = self.service[CharacteristicsTypes.TEMPERATURE_TARGET].maxValue if max_temp is not None: @@ -534,7 +528,7 @@ class HomeKitClimateEntity(HomeKitEntity, ClimateEntity): return super().max_humidity @property - def hvac_action(self) -> str | None: + def hvac_action(self) -> HVACAction | None: """Return the current running hvac operation.""" # This characteristic describes the current mode of a device, # e.g. a thermostat is "heating" a room to 75 degrees Fahrenheit. @@ -543,7 +537,7 @@ class HomeKitClimateEntity(HomeKitEntity, ClimateEntity): return CURRENT_MODE_HOMEKIT_TO_HASS.get(value) @property - def hvac_mode(self) -> str: + def hvac_mode(self) -> HVACMode: """Return hvac operation ie. heat, cool mode.""" # This characteristic describes the target mode # E.g. should the device start heating a room if the temperature @@ -553,7 +547,7 @@ class HomeKitClimateEntity(HomeKitEntity, ClimateEntity): return MODE_HOMEKIT_TO_HASS[value] @property - def hvac_modes(self) -> list[str]: + def hvac_modes(self) -> list[HVACMode]: """Return the list of available hvac operation modes.""" valid_values = clamp_enum_to_char( HeatingCoolingTargetValues, diff --git a/tests/components/homekit_controller/test_climate.py b/tests/components/homekit_controller/test_climate.py index 9ca45fd53ac..646804a86d6 100644 --- a/tests/components/homekit_controller/test_climate.py +++ b/tests/components/homekit_controller/test_climate.py @@ -10,14 +10,11 @@ from aiohomekit.model.services import ServicesTypes from homeassistant.components.climate.const import ( DOMAIN, - HVAC_MODE_COOL, - HVAC_MODE_HEAT, - HVAC_MODE_HEAT_COOL, - HVAC_MODE_OFF, SERVICE_SET_HUMIDITY, SERVICE_SET_HVAC_MODE, SERVICE_SET_SWING_MODE, SERVICE_SET_TEMPERATURE, + HVACMode, ) from tests.components.homekit_controller.common import setup_test_component @@ -98,7 +95,7 @@ async def test_climate_change_thermostat_state(hass, utcnow): await hass.services.async_call( DOMAIN, SERVICE_SET_HVAC_MODE, - {"entity_id": "climate.testdevice", "hvac_mode": HVAC_MODE_HEAT}, + {"entity_id": "climate.testdevice", "hvac_mode": HVACMode.HEAT}, blocking=True, ) helper.async_assert_service_values( @@ -111,7 +108,7 @@ async def test_climate_change_thermostat_state(hass, utcnow): await hass.services.async_call( DOMAIN, SERVICE_SET_HVAC_MODE, - {"entity_id": "climate.testdevice", "hvac_mode": HVAC_MODE_COOL}, + {"entity_id": "climate.testdevice", "hvac_mode": HVACMode.COOL}, blocking=True, ) helper.async_assert_service_values( @@ -124,7 +121,7 @@ async def test_climate_change_thermostat_state(hass, utcnow): await hass.services.async_call( DOMAIN, SERVICE_SET_HVAC_MODE, - {"entity_id": "climate.testdevice", "hvac_mode": HVAC_MODE_HEAT_COOL}, + {"entity_id": "climate.testdevice", "hvac_mode": HVACMode.HEAT_COOL}, blocking=True, ) helper.async_assert_service_values( @@ -137,7 +134,7 @@ async def test_climate_change_thermostat_state(hass, utcnow): await hass.services.async_call( DOMAIN, SERVICE_SET_HVAC_MODE, - {"entity_id": "climate.testdevice", "hvac_mode": HVAC_MODE_OFF}, + {"entity_id": "climate.testdevice", "hvac_mode": HVACMode.OFF}, blocking=True, ) helper.async_assert_service_values( @@ -155,7 +152,7 @@ async def test_climate_check_min_max_values_per_mode(hass, utcnow): await hass.services.async_call( DOMAIN, SERVICE_SET_HVAC_MODE, - {"entity_id": "climate.testdevice", "hvac_mode": HVAC_MODE_HEAT}, + {"entity_id": "climate.testdevice", "hvac_mode": HVACMode.HEAT}, blocking=True, ) climate_state = await helper.poll_and_get_state() @@ -165,7 +162,7 @@ async def test_climate_check_min_max_values_per_mode(hass, utcnow): await hass.services.async_call( DOMAIN, SERVICE_SET_HVAC_MODE, - {"entity_id": "climate.testdevice", "hvac_mode": HVAC_MODE_COOL}, + {"entity_id": "climate.testdevice", "hvac_mode": HVACMode.COOL}, blocking=True, ) climate_state = await helper.poll_and_get_state() @@ -175,7 +172,7 @@ async def test_climate_check_min_max_values_per_mode(hass, utcnow): await hass.services.async_call( DOMAIN, SERVICE_SET_HVAC_MODE, - {"entity_id": "climate.testdevice", "hvac_mode": HVAC_MODE_HEAT_COOL}, + {"entity_id": "climate.testdevice", "hvac_mode": HVACMode.HEAT_COOL}, blocking=True, ) climate_state = await helper.poll_and_get_state() @@ -221,7 +218,7 @@ async def test_climate_change_thermostat_temperature_range(hass, utcnow): await hass.services.async_call( DOMAIN, SERVICE_SET_HVAC_MODE, - {"entity_id": "climate.testdevice", "hvac_mode": HVAC_MODE_HEAT_COOL}, + {"entity_id": "climate.testdevice", "hvac_mode": HVACMode.HEAT_COOL}, blocking=True, ) @@ -230,7 +227,7 @@ async def test_climate_change_thermostat_temperature_range(hass, utcnow): SERVICE_SET_TEMPERATURE, { "entity_id": "climate.testdevice", - "hvac_mode": HVAC_MODE_HEAT_COOL, + "hvac_mode": HVACMode.HEAT_COOL, "target_temp_high": 25, "target_temp_low": 20, }, @@ -254,7 +251,7 @@ async def test_climate_change_thermostat_temperature_range_iphone(hass, utcnow): await hass.services.async_call( DOMAIN, SERVICE_SET_HVAC_MODE, - {"entity_id": "climate.testdevice", "hvac_mode": HVAC_MODE_HEAT_COOL}, + {"entity_id": "climate.testdevice", "hvac_mode": HVACMode.HEAT_COOL}, blocking=True, ) @@ -263,7 +260,7 @@ async def test_climate_change_thermostat_temperature_range_iphone(hass, utcnow): SERVICE_SET_TEMPERATURE, { "entity_id": "climate.testdevice", - "hvac_mode": HVAC_MODE_HEAT_COOL, + "hvac_mode": HVACMode.HEAT_COOL, "temperature": 22, "target_temp_low": 20, "target_temp_high": 24, @@ -287,7 +284,7 @@ async def test_climate_cannot_set_thermostat_temp_range_in_wrong_mode(hass, utcn await hass.services.async_call( DOMAIN, SERVICE_SET_HVAC_MODE, - {"entity_id": "climate.testdevice", "hvac_mode": HVAC_MODE_HEAT}, + {"entity_id": "climate.testdevice", "hvac_mode": HVACMode.HEAT}, blocking=True, ) @@ -344,7 +341,7 @@ async def test_climate_check_min_max_values_per_mode_sspa_device(hass, utcnow): await hass.services.async_call( DOMAIN, SERVICE_SET_HVAC_MODE, - {"entity_id": "climate.testdevice", "hvac_mode": HVAC_MODE_HEAT}, + {"entity_id": "climate.testdevice", "hvac_mode": HVACMode.HEAT}, blocking=True, ) climate_state = await helper.poll_and_get_state() @@ -354,7 +351,7 @@ async def test_climate_check_min_max_values_per_mode_sspa_device(hass, utcnow): await hass.services.async_call( DOMAIN, SERVICE_SET_HVAC_MODE, - {"entity_id": "climate.testdevice", "hvac_mode": HVAC_MODE_COOL}, + {"entity_id": "climate.testdevice", "hvac_mode": HVACMode.COOL}, blocking=True, ) climate_state = await helper.poll_and_get_state() @@ -364,7 +361,7 @@ async def test_climate_check_min_max_values_per_mode_sspa_device(hass, utcnow): await hass.services.async_call( DOMAIN, SERVICE_SET_HVAC_MODE, - {"entity_id": "climate.testdevice", "hvac_mode": HVAC_MODE_HEAT_COOL}, + {"entity_id": "climate.testdevice", "hvac_mode": HVACMode.HEAT_COOL}, blocking=True, ) climate_state = await helper.poll_and_get_state() @@ -379,7 +376,7 @@ async def test_climate_set_thermostat_temp_on_sspa_device(hass, utcnow): await hass.services.async_call( DOMAIN, SERVICE_SET_HVAC_MODE, - {"entity_id": "climate.testdevice", "hvac_mode": HVAC_MODE_HEAT}, + {"entity_id": "climate.testdevice", "hvac_mode": HVACMode.HEAT}, blocking=True, ) @@ -399,7 +396,7 @@ async def test_climate_set_thermostat_temp_on_sspa_device(hass, utcnow): await hass.services.async_call( DOMAIN, SERVICE_SET_HVAC_MODE, - {"entity_id": "climate.testdevice", "hvac_mode": HVAC_MODE_HEAT_COOL}, + {"entity_id": "climate.testdevice", "hvac_mode": HVACMode.HEAT_COOL}, blocking=True, ) helper.async_assert_service_values( @@ -436,7 +433,7 @@ async def test_climate_set_mode_via_temp(hass, utcnow): { "entity_id": "climate.testdevice", "temperature": 21, - "hvac_mode": HVAC_MODE_HEAT, + "hvac_mode": HVACMode.HEAT, }, blocking=True, ) @@ -453,7 +450,7 @@ async def test_climate_set_mode_via_temp(hass, utcnow): SERVICE_SET_TEMPERATURE, { "entity_id": "climate.testdevice", - "hvac_mode": HVAC_MODE_HEAT_COOL, + "hvac_mode": HVACMode.HEAT_COOL, "temperature": 22, }, blocking=True, @@ -516,7 +513,7 @@ async def test_climate_read_thermostat_state(hass, utcnow): ) state = await helper.poll_and_get_state() - assert state.state == HVAC_MODE_HEAT + assert state.state == HVACMode.HEAT assert state.attributes["current_temperature"] == 19 assert state.attributes["current_humidity"] == 50 assert state.attributes["min_temp"] == 7 @@ -536,7 +533,7 @@ async def test_climate_read_thermostat_state(hass, utcnow): ) state = await helper.poll_and_get_state() - assert state.state == HVAC_MODE_COOL + assert state.state == HVACMode.COOL assert state.attributes["current_temperature"] == 21 assert state.attributes["current_humidity"] == 45 @@ -552,7 +549,7 @@ async def test_climate_read_thermostat_state(hass, utcnow): ) state = await helper.poll_and_get_state() - assert state.state == HVAC_MODE_HEAT_COOL + assert state.state == HVACMode.HEAT_COOL async def test_hvac_mode_vs_hvac_action(hass, utcnow): @@ -661,7 +658,7 @@ async def test_heater_cooler_change_thermostat_state(hass, utcnow): await hass.services.async_call( DOMAIN, SERVICE_SET_HVAC_MODE, - {"entity_id": "climate.testdevice", "hvac_mode": HVAC_MODE_HEAT}, + {"entity_id": "climate.testdevice", "hvac_mode": HVACMode.HEAT}, blocking=True, ) helper.async_assert_service_values( @@ -674,7 +671,7 @@ async def test_heater_cooler_change_thermostat_state(hass, utcnow): await hass.services.async_call( DOMAIN, SERVICE_SET_HVAC_MODE, - {"entity_id": "climate.testdevice", "hvac_mode": HVAC_MODE_COOL}, + {"entity_id": "climate.testdevice", "hvac_mode": HVACMode.COOL}, blocking=True, ) helper.async_assert_service_values( @@ -687,7 +684,7 @@ async def test_heater_cooler_change_thermostat_state(hass, utcnow): await hass.services.async_call( DOMAIN, SERVICE_SET_HVAC_MODE, - {"entity_id": "climate.testdevice", "hvac_mode": HVAC_MODE_HEAT_COOL}, + {"entity_id": "climate.testdevice", "hvac_mode": HVACMode.HEAT_COOL}, blocking=True, ) helper.async_assert_service_values( @@ -700,7 +697,7 @@ async def test_heater_cooler_change_thermostat_state(hass, utcnow): await hass.services.async_call( DOMAIN, SERVICE_SET_HVAC_MODE, - {"entity_id": "climate.testdevice", "hvac_mode": HVAC_MODE_OFF}, + {"entity_id": "climate.testdevice", "hvac_mode": HVACMode.OFF}, blocking=True, ) helper.async_assert_service_values( @@ -718,7 +715,7 @@ async def test_heater_cooler_change_thermostat_temperature(hass, utcnow): await hass.services.async_call( DOMAIN, SERVICE_SET_HVAC_MODE, - {"entity_id": "climate.testdevice", "hvac_mode": HVAC_MODE_HEAT}, + {"entity_id": "climate.testdevice", "hvac_mode": HVACMode.HEAT}, blocking=True, ) await hass.services.async_call( @@ -737,7 +734,7 @@ async def test_heater_cooler_change_thermostat_temperature(hass, utcnow): await hass.services.async_call( DOMAIN, SERVICE_SET_HVAC_MODE, - {"entity_id": "climate.testdevice", "hvac_mode": HVAC_MODE_COOL}, + {"entity_id": "climate.testdevice", "hvac_mode": HVACMode.COOL}, blocking=True, ) await hass.services.async_call( @@ -771,7 +768,7 @@ async def test_heater_cooler_read_thermostat_state(hass, utcnow): ) state = await helper.poll_and_get_state() - assert state.state == HVAC_MODE_HEAT + assert state.state == HVACMode.HEAT assert state.attributes["current_temperature"] == 19 assert state.attributes["min_temp"] == 7 assert state.attributes["max_temp"] == 35 @@ -789,7 +786,7 @@ async def test_heater_cooler_read_thermostat_state(hass, utcnow): ) state = await helper.poll_and_get_state() - assert state.state == HVAC_MODE_COOL + assert state.state == HVACMode.COOL assert state.attributes["current_temperature"] == 21 # Simulate that we are in auto mode @@ -805,7 +802,7 @@ async def test_heater_cooler_read_thermostat_state(hass, utcnow): ) state = await helper.poll_and_get_state() - assert state.state == HVAC_MODE_HEAT_COOL + assert state.state == HVACMode.HEAT_COOL async def test_heater_cooler_hvac_mode_vs_hvac_action(hass, utcnow):