Bugfix evohome converting non-UTC timezones (#32120)
* bugfix: correctly handle non-UTC TZs * bugfix: system mode is always permanent * bugfix: handle where until is none * tweak: improve logging to support above fixes
This commit is contained in:
parent
4717d072c9
commit
ae0ea0f088
4 changed files with 54 additions and 33 deletions
|
@ -20,7 +20,7 @@ from homeassistant.components.climate.const import (
|
|||
)
|
||||
from homeassistant.const import PRECISION_TENTHS
|
||||
from homeassistant.helpers.typing import ConfigType, HomeAssistantType
|
||||
from homeassistant.util.dt import parse_datetime
|
||||
import homeassistant.util.dt as dt_util
|
||||
|
||||
from . import (
|
||||
ATTR_DURATION_DAYS,
|
||||
|
@ -170,21 +170,21 @@ class EvoZone(EvoChild, EvoClimateDevice):
|
|||
return
|
||||
|
||||
# otherwise it is SVC_SET_ZONE_OVERRIDE
|
||||
temp = round(data[ATTR_ZONE_TEMP] * self.precision) / self.precision
|
||||
temp = max(min(temp, self.max_temp), self.min_temp)
|
||||
temperature = max(min(data[ATTR_ZONE_TEMP], self.max_temp), self.min_temp)
|
||||
|
||||
if ATTR_DURATION_UNTIL in data:
|
||||
duration = data[ATTR_DURATION_UNTIL]
|
||||
if duration.total_seconds() == 0:
|
||||
await self._update_schedule()
|
||||
until = parse_datetime(str(self.setpoints.get("next_sp_from")))
|
||||
until = dt_util.parse_datetime(self.setpoints.get("next_sp_from", ""))
|
||||
else:
|
||||
until = dt.now() + data[ATTR_DURATION_UNTIL]
|
||||
until = dt_util.now() + data[ATTR_DURATION_UNTIL]
|
||||
else:
|
||||
until = None # indefinitely
|
||||
|
||||
until = dt_util.as_utc(until) if until else None
|
||||
await self._evo_broker.call_client_api(
|
||||
self._evo_device.set_temperature(temperature=temp, until=until)
|
||||
self._evo_device.set_temperature(temperature, until=until)
|
||||
)
|
||||
|
||||
@property
|
||||
|
@ -244,12 +244,13 @@ class EvoZone(EvoChild, EvoClimateDevice):
|
|||
if until is None:
|
||||
if self._evo_device.setpointStatus["setpointMode"] == EVO_FOLLOW:
|
||||
await self._update_schedule()
|
||||
until = parse_datetime(str(self.setpoints.get("next_sp_from")))
|
||||
until = dt_util.parse_datetime(self.setpoints.get("next_sp_from", ""))
|
||||
elif self._evo_device.setpointStatus["setpointMode"] == EVO_TEMPOVER:
|
||||
until = parse_datetime(self._evo_device.setpointStatus["until"])
|
||||
until = dt_util.parse_datetime(self._evo_device.setpointStatus["until"])
|
||||
|
||||
until = dt_util.as_utc(until) if until else None
|
||||
await self._evo_broker.call_client_api(
|
||||
self._evo_device.set_temperature(temperature, until)
|
||||
self._evo_device.set_temperature(temperature, until=until)
|
||||
)
|
||||
|
||||
async def async_set_hvac_mode(self, hvac_mode: str) -> None:
|
||||
|
@ -292,12 +293,13 @@ class EvoZone(EvoChild, EvoClimateDevice):
|
|||
|
||||
if evo_preset_mode == EVO_TEMPOVER:
|
||||
await self._update_schedule()
|
||||
until = parse_datetime(str(self.setpoints.get("next_sp_from")))
|
||||
until = dt_util.parse_datetime(self.setpoints.get("next_sp_from", ""))
|
||||
else: # EVO_PERMOVER
|
||||
until = None
|
||||
|
||||
until = dt_util.as_utc(until) if until else None
|
||||
await self._evo_broker.call_client_api(
|
||||
self._evo_device.set_temperature(temperature, until)
|
||||
self._evo_device.set_temperature(temperature, until=until)
|
||||
)
|
||||
|
||||
async def async_update(self) -> None:
|
||||
|
@ -345,11 +347,11 @@ class EvoController(EvoClimateDevice):
|
|||
mode = EVO_RESET
|
||||
|
||||
if ATTR_DURATION_DAYS in data:
|
||||
until = dt.combine(dt.now().date(), dt.min.time())
|
||||
until = dt_util.start_of_local_day()
|
||||
until += data[ATTR_DURATION_DAYS]
|
||||
|
||||
elif ATTR_DURATION_HOURS in data:
|
||||
until = dt.now() + data[ATTR_DURATION_HOURS]
|
||||
until = dt_util.now() + data[ATTR_DURATION_HOURS]
|
||||
|
||||
else:
|
||||
until = None
|
||||
|
@ -358,7 +360,10 @@ class EvoController(EvoClimateDevice):
|
|||
|
||||
async def _set_tcs_mode(self, mode: str, until: Optional[dt] = None) -> None:
|
||||
"""Set a Controller to any of its native EVO_* operating modes."""
|
||||
await self._evo_broker.call_client_api(self._evo_tcs.set_status(mode))
|
||||
until = dt_util.as_utc(until) if until else None
|
||||
await self._evo_broker.call_client_api(
|
||||
self._evo_tcs.set_status(mode, until=until)
|
||||
)
|
||||
|
||||
@property
|
||||
def hvac_mode(self) -> str:
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue