Skip to content

Commit 928732a

Browse files
authored
Clean up evohome constants (home-assistant#164102)
1 parent 51dc6d7 commit 928732a

5 files changed

Lines changed: 13 additions & 28 deletions

File tree

homeassistant/components/evohome/climate.py

Lines changed: 5 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -41,14 +41,7 @@
4141
from homeassistant.helpers.typing import ConfigType, DiscoveryInfoType
4242
from homeassistant.util import dt as dt_util
4343

44-
from .const import (
45-
ATTR_DURATION,
46-
ATTR_DURATION_UNTIL,
47-
ATTR_PERIOD,
48-
ATTR_SETPOINT,
49-
EVOHOME_DATA,
50-
EvoService,
51-
)
44+
from .const import ATTR_DURATION, ATTR_PERIOD, ATTR_SETPOINT, EVOHOME_DATA, EvoService
5245
from .coordinator import EvoDataUpdateCoordinator
5346
from .entity import EvoChild, EvoEntity
5447

@@ -179,20 +172,20 @@ def __init__(
179172

180173
async def async_zone_svc_request(self, service: str, data: dict[str, Any]) -> None:
181174
"""Process a service request (setpoint override) for a zone."""
182-
if service == EvoService.RESET_ZONE_OVERRIDE:
175+
if service == EvoService.CLEAR_ZONE_OVERRIDE:
183176
await self.coordinator.call_client_api(self._evo_device.reset())
184177
return
185178

186179
# otherwise it is EvoService.SET_ZONE_OVERRIDE
187180
temperature = max(min(data[ATTR_SETPOINT], self.max_temp), self.min_temp)
188181

189-
if ATTR_DURATION_UNTIL in data:
190-
duration: timedelta = data[ATTR_DURATION_UNTIL]
182+
if ATTR_DURATION in data:
183+
duration: timedelta = data[ATTR_DURATION]
191184
if duration.total_seconds() == 0:
192185
await self._update_schedule()
193186
until = self.setpoints.get("next_sp_from")
194187
else:
195-
until = dt_util.now() + data[ATTR_DURATION_UNTIL]
188+
until = dt_util.now() + data[ATTR_DURATION]
196189
else:
197190
until = None # indefinitely
198191

homeassistant/components/evohome/const.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,6 @@
2828
ATTR_DURATION: Final = "duration" # number of minutes, <24h
2929

3030
ATTR_SETPOINT: Final = "setpoint"
31-
ATTR_DURATION_UNTIL: Final = "duration"
3231

3332

3433
@unique
@@ -39,4 +38,4 @@ class EvoService(StrEnum):
3938
SET_SYSTEM_MODE = "set_system_mode"
4039
RESET_SYSTEM = "reset_system"
4140
SET_ZONE_OVERRIDE = "set_zone_override"
42-
RESET_ZONE_OVERRIDE = "clear_zone_override"
41+
CLEAR_ZONE_OVERRIDE = "clear_zone_override"

homeassistant/components/evohome/entity.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@ async def process_signal(self, payload: dict | None = None) -> None:
4949
return
5050
if payload["service"] in (
5151
EvoService.SET_ZONE_OVERRIDE,
52-
EvoService.RESET_ZONE_OVERRIDE,
52+
EvoService.CLEAR_ZONE_OVERRIDE,
5353
):
5454
await self.async_zone_svc_request(payload["service"], payload["data"])
5555
return

homeassistant/components/evohome/services.py

Lines changed: 5 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -19,20 +19,13 @@
1919
from homeassistant.helpers.dispatcher import async_dispatcher_send
2020
from homeassistant.helpers.service import verify_domain_control
2121

22-
from .const import (
23-
ATTR_DURATION,
24-
ATTR_DURATION_UNTIL,
25-
ATTR_PERIOD,
26-
ATTR_SETPOINT,
27-
DOMAIN,
28-
EvoService,
29-
)
22+
from .const import ATTR_DURATION, ATTR_PERIOD, ATTR_SETPOINT, DOMAIN, EvoService
3023
from .coordinator import EvoDataUpdateCoordinator
3124

3225
# system mode schemas are built dynamically when the services are registered
3326
# because supported modes can vary for edge-case systems
3427

35-
RESET_ZONE_OVERRIDE_SCHEMA: Final = vol.Schema(
28+
CLEAR_ZONE_OVERRIDE_SCHEMA: Final = vol.Schema(
3629
{vol.Required(ATTR_ENTITY_ID): cv.entity_id}
3730
)
3831
SET_ZONE_OVERRIDE_SCHEMA: Final = vol.Schema(
@@ -41,7 +34,7 @@
4134
vol.Required(ATTR_SETPOINT): vol.All(
4235
vol.Coerce(float), vol.Range(min=4.0, max=35.0)
4336
),
44-
vol.Optional(ATTR_DURATION_UNTIL): vol.All(
37+
vol.Optional(ATTR_DURATION): vol.All(
4538
cv.time_period,
4639
vol.Range(min=timedelta(days=0), max=timedelta(days=1)),
4740
),
@@ -166,9 +159,9 @@ async def set_zone_override(call: ServiceCall) -> None:
166159
# The zone modes are consistent across all systems and use the same schema
167160
hass.services.async_register(
168161
DOMAIN,
169-
EvoService.RESET_ZONE_OVERRIDE,
162+
EvoService.CLEAR_ZONE_OVERRIDE,
170163
set_zone_override,
171-
schema=RESET_ZONE_OVERRIDE_SCHEMA,
164+
schema=CLEAR_ZONE_OVERRIDE_SCHEMA,
172165
)
173166
hass.services.async_register(
174167
DOMAIN,

tests/components/evohome/test_services.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -125,7 +125,7 @@ async def test_zone_clear_zone_override(
125125
with patch("evohomeasync2.zone.Zone.reset") as mock_fcn:
126126
await hass.services.async_call(
127127
DOMAIN,
128-
EvoService.RESET_ZONE_OVERRIDE,
128+
EvoService.CLEAR_ZONE_OVERRIDE,
129129
{
130130
ATTR_ENTITY_ID: zone_id,
131131
},

0 commit comments

Comments
 (0)