Propagate timezone setting to host in OS 16.2 and newer (#6099)

* Propagate timezone setting to host in OS 16.2 and newer

With home-assistant/operating-system#4224, timezone setting in OS can be
peristently set in HAOS as well. Propagate the timezone configured in
Supervisor config (which can be changed through general system settings
in HA Core) through the DBus API for setting the timezone.

* Persist timezone also when it's been obtained from Whoami

* Suppress pylint fixme error
This commit is contained in:
Jan Čermák
2025-08-20 01:30:57 +02:00
committed by GitHub
parent 4109c15a36
commit b49ce96df8
7 changed files with 112 additions and 1 deletions

View File

@@ -82,6 +82,24 @@ async def test_dbus_setntp(
assert timedate.ntp is False
async def test_dbus_set_timezone(
timedate_service: TimeDateService, dbus_session_bus: MessageBus
):
"""Test setting of host timezone."""
timedate_service.SetTimezone.calls.clear()
timedate = TimeDate()
with pytest.raises(DBusNotConnectedError):
await timedate.set_timezone("Europe/Prague")
await timedate.connect(dbus_session_bus)
assert await timedate.set_timezone("Europe/Prague") is None
assert timedate_service.SetTimezone.calls == [("Europe/Prague", False)]
await timedate_service.ping()
assert timedate.timezone == "Europe/Prague"
async def test_dbus_timedate_connect_error(
dbus_session_bus: MessageBus, caplog: pytest.LogCaptureFixture
):