mirror of
https://github.com/home-assistant/core.git
synced 2025-07-21 04:07:08 +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,
|
WaterHeaterEntityFeature,
|
||||||
)
|
)
|
||||||
from homeassistant.const import ATTR_TEMPERATURE, UnitOfTemperature
|
from homeassistant.const import ATTR_TEMPERATURE, UnitOfTemperature
|
||||||
|
from homeassistant.util import dt as dt_util
|
||||||
|
|
||||||
from .. import OverkizDataUpdateCoordinator
|
from .. import OverkizDataUpdateCoordinator
|
||||||
from ..entity import OverkizEntity
|
from ..entity import OverkizEntity
|
||||||
@ -153,11 +154,11 @@ class AtlanticDomesticHotWaterProductionMBLComponent(OverkizEntity, WaterHeaterE
|
|||||||
async def async_turn_away_mode_on(self) -> None:
|
async def async_turn_away_mode_on(self) -> None:
|
||||||
"""Turn away mode on.
|
"""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
|
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})
|
{'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,
|
The dict is then passed as an actual device date, the away mode start date, and then as an end date,
|
||||||
so the away mode is getting turned on for the next year.
|
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,
|
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
|
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.
|
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,
|
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.
|
the API is not choking and the transition is smooth without the unavailability state.
|
||||||
"""
|
"""
|
||||||
now_date = cast(
|
now = dt_util.now()
|
||||||
dict,
|
now_date = {
|
||||||
self.executor.select_state(OverkizState.CORE_DATETIME),
|
"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(
|
await self.executor.async_execute_command(
|
||||||
OverkizCommand.SET_ABSENCE_MODE,
|
OverkizCommand.SET_DATE_TIME,
|
||||||
OverkizCommandParam.PROG,
|
now_date,
|
||||||
refresh_afterwards=False,
|
refresh_afterwards=False,
|
||||||
)
|
)
|
||||||
await self.executor.async_execute_command(
|
await self.executor.async_execute_command(
|
||||||
@ -183,7 +190,11 @@ class AtlanticDomesticHotWaterProductionMBLComponent(OverkizEntity, WaterHeaterE
|
|||||||
await self.executor.async_execute_command(
|
await self.executor.async_execute_command(
|
||||||
OverkizCommand.SET_ABSENCE_END_DATE, now_date, refresh_afterwards=False
|
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()
|
await self.coordinator.async_refresh()
|
||||||
|
|
||||||
async def async_turn_away_mode_off(self) -> None:
|
async def async_turn_away_mode_off(self) -> None:
|
||||||
|
Loading…
x
Reference in New Issue
Block a user