mirror of
https://github.com/home-assistant/core.git
synced 2025-07-18 18:57:06 +00:00
Sync overkiz Atlantic Water Heater datetime before switching the away mode on (#127408)
Set device datetime before turning on the away mode
This commit is contained in:
parent
883c6121cf
commit
15bf0c728c
@ -13,6 +13,7 @@ from homeassistant.components.water_heater import (
|
||||
WaterHeaterEntityFeature,
|
||||
)
|
||||
from homeassistant.const import ATTR_TEMPERATURE, UnitOfTemperature
|
||||
from homeassistant.util import dt as dt_util
|
||||
|
||||
from .. import OverkizDataUpdateCoordinator
|
||||
from ..entity import OverkizEntity
|
||||
@ -153,11 +154,11 @@ class AtlanticDomesticHotWaterProductionMBLComponent(OverkizEntity, WaterHeaterE
|
||||
async def async_turn_away_mode_on(self) -> None:
|
||||
"""Turn away mode on.
|
||||
|
||||
This requires the start date and the end date to be also set.
|
||||
This requires the start date and the end date to be also set, and those dates have to match the device datetime.
|
||||
The API accepts setting dates in the format of the core:DateTimeState state for the DHW
|
||||
{'day': 11, 'hour': 21, 'minute': 12, 'month': 7, 'second': 53, 'weekday': 3, 'year': 2024})
|
||||
The dict is then passed as an away mode start date, and then as an end date, but with the year incremented by 1,
|
||||
so the away mode is getting turned on for the next year.
|
||||
{'day': 11, 'hour': 21, 'minute': 12, 'month': 7, 'second': 53, 'weekday': 3, 'year': 2024}
|
||||
The dict is then passed as an actual device date, the away mode start date, and then as an end date,
|
||||
but with the year incremented by 1, so the away mode is getting turned on for the next year.
|
||||
The weekday number seems to have no effect so the calculation of the future date's weekday number is redundant,
|
||||
but possible via homeassistant dt_util to form both start and end dates dictionaries from scratch
|
||||
based on datetime.now() and datetime.timedelta into the future.
|
||||
@ -167,13 +168,19 @@ class AtlanticDomesticHotWaterProductionMBLComponent(OverkizEntity, WaterHeaterE
|
||||
With `refresh_afterwards=False` on the first commands, and `refresh_afterwards=True` only the last command,
|
||||
the API is not choking and the transition is smooth without the unavailability state.
|
||||
"""
|
||||
now_date = cast(
|
||||
dict,
|
||||
self.executor.select_state(OverkizState.CORE_DATETIME),
|
||||
)
|
||||
now = dt_util.now()
|
||||
now_date = {
|
||||
"month": now.month,
|
||||
"hour": now.hour,
|
||||
"year": now.year,
|
||||
"weekday": now.weekday(),
|
||||
"day": now.day,
|
||||
"minute": now.minute,
|
||||
"second": now.second,
|
||||
}
|
||||
await self.executor.async_execute_command(
|
||||
OverkizCommand.SET_ABSENCE_MODE,
|
||||
OverkizCommandParam.PROG,
|
||||
OverkizCommand.SET_DATE_TIME,
|
||||
now_date,
|
||||
refresh_afterwards=False,
|
||||
)
|
||||
await self.executor.async_execute_command(
|
||||
@ -183,7 +190,11 @@ class AtlanticDomesticHotWaterProductionMBLComponent(OverkizEntity, WaterHeaterE
|
||||
await self.executor.async_execute_command(
|
||||
OverkizCommand.SET_ABSENCE_END_DATE, now_date, refresh_afterwards=False
|
||||
)
|
||||
|
||||
await self.executor.async_execute_command(
|
||||
OverkizCommand.SET_ABSENCE_MODE,
|
||||
OverkizCommandParam.PROG,
|
||||
refresh_afterwards=False,
|
||||
)
|
||||
await self.coordinator.async_refresh()
|
||||
|
||||
async def async_turn_away_mode_off(self) -> None:
|
||||
|
Loading…
x
Reference in New Issue
Block a user