1414import voluptuous as vol
1515
1616from homeassistant .components .climate import DOMAIN as CLIMATE_DOMAIN
17- from homeassistant .const import ATTR_MODE
1817from homeassistant .core import HomeAssistant , ServiceCall , callback
1918from homeassistant .exceptions import ServiceValidationError
2019from homeassistant .helpers import config_validation as cv , service
2120from homeassistant .helpers .dispatcher import async_dispatcher_send
2221from homeassistant .helpers .service import verify_domain_control
2322
24- from .const import ATTR_DURATION , ATTR_PERIOD , ATTR_SETPOINT , DOMAIN , EvoService
23+ from .const import DOMAIN , EVO_DURATION , EVO_MODE , EVO_PERIOD , EVO_SETPOINT , EvoService
2524from .coordinator import EvoDataUpdateCoordinator
2625
2726# System service schemas (registered as domain services)
2827SET_SYSTEM_MODE_SCHEMA : Final [dict [str | vol .Marker , Any ]] = {
2928 # unsupported modes are rejected at runtime with ServiceValidationError
30- vol .Required (ATTR_MODE ): cv .string , # avoid vol.In(SystemMode)
31- vol .Exclusive (ATTR_DURATION , "temporary" ): vol .All (
29+ vol .Required (EVO_MODE ): cv .string , # avoid vol.In(SystemMode)
30+ vol .Exclusive (EVO_DURATION , "temporary" ): vol .All (
3231 cv .time_period ,
3332 vol .Range (min = timedelta (hours = 0 ), max = timedelta (hours = 24 )),
3433 ),
35- vol .Exclusive (ATTR_PERIOD , "temporary" ): vol .All (
34+ vol .Exclusive (EVO_PERIOD , "temporary" ): vol .All (
3635 cv .time_period ,
3736 vol .Range (min = timedelta (days = 1 ), max = timedelta (days = 99 )),
3837 ),
3938}
4039
4140# Zone service schemas (registered as entity services)
4241SET_ZONE_OVERRIDE_SCHEMA : Final [dict [str | vol .Marker , Any ]] = {
43- vol .Required (ATTR_SETPOINT ): vol .All (
42+ vol .Required (EVO_SETPOINT ): vol .All (
4443 vol .Coerce (float ), vol .Range (min = 4.0 , max = 35.0 )
4544 ),
46- vol .Optional (ATTR_DURATION ): vol .All (
45+ vol .Optional (EVO_DURATION ): vol .All (
4746 cv .time_period ,
4847 vol .Range (min = timedelta (days = 0 ), max = timedelta (days = 1 )),
4948 ),
@@ -74,7 +73,7 @@ def _register_zone_entity_services(hass: HomeAssistant) -> None:
7473def _validate_set_system_mode_params (tcs : ControlSystem , data : dict [str , Any ]) -> None :
7574 """Validate that a set_system_mode service call is properly formed."""
7675
77- mode = data [ATTR_MODE ]
76+ mode = data [EVO_MODE ]
7877 tcs_modes = {m [SZ_SYSTEM_MODE ]: m for m in tcs .allowed_system_modes }
7978
8079 # Validation occurs here, instead of in the library, because it uses a slightly
@@ -85,34 +84,34 @@ def _validate_set_system_mode_params(tcs: ControlSystem, data: dict[str, Any]) -
8584 raise ServiceValidationError (
8685 translation_domain = DOMAIN ,
8786 translation_key = "mode_not_supported" ,
88- translation_placeholders = {ATTR_MODE : mode },
87+ translation_placeholders = {EVO_MODE : mode },
8988 )
9089
9190 # voluptuous schema ensures that duration and period are not both present
9291
9392 if not mode_info [SZ_CAN_BE_TEMPORARY ]:
94- if ATTR_DURATION in data or ATTR_PERIOD in data :
93+ if EVO_DURATION in data or EVO_PERIOD in data :
9594 raise ServiceValidationError (
9695 translation_domain = DOMAIN ,
9796 translation_key = "mode_cant_be_temporary" ,
98- translation_placeholders = {ATTR_MODE : mode },
97+ translation_placeholders = {EVO_MODE : mode },
9998 )
10099 return
101100
102101 timing_mode = mode_info .get (SZ_TIMING_MODE ) # will not be None, as can_be_temporary
103102
104- if timing_mode == SZ_DURATION and ATTR_PERIOD in data :
103+ if timing_mode == SZ_DURATION and EVO_PERIOD in data :
105104 raise ServiceValidationError (
106105 translation_domain = DOMAIN ,
107106 translation_key = "mode_cant_have_period" ,
108- translation_placeholders = {ATTR_MODE : mode },
107+ translation_placeholders = {EVO_MODE : mode },
109108 )
110109
111- if timing_mode == SZ_PERIOD and ATTR_DURATION in data :
110+ if timing_mode == SZ_PERIOD and EVO_DURATION in data :
112111 raise ServiceValidationError (
113112 translation_domain = DOMAIN ,
114113 translation_key = "mode_cant_have_duration" ,
115- translation_placeholders = {ATTR_MODE : mode },
114+ translation_placeholders = {EVO_MODE : mode },
116115 )
117116
118117
0 commit comments