1
mirror of https://github.com/home-assistant/core synced 2024-08-02 23:40:32 +02:00
ha-core/homeassistant/components/radiotherm/util.py
2022-06-07 14:26:06 -10:00

25 lines
704 B
Python

"""Utils for radiotherm."""
from __future__ import annotations
from radiotherm.thermostat import CommonThermostat
from homeassistant.core import HomeAssistant
from homeassistant.util import dt as dt_util
async def async_set_time(hass: HomeAssistant, device: CommonThermostat) -> None:
"""Sync time to the thermostat."""
await hass.async_add_executor_job(_set_time, device)
def _set_time(device: CommonThermostat) -> None:
"""Set device time."""
# Calling this clears any local temperature override and
# reverts to the scheduled temperature.
now = dt_util.now()
device.time = {
"day": now.weekday(),
"hour": now.hour,
"minute": now.minute,
}