Adopt Home Assistant's time zone for the API household clock
The deployed API host runs UTC and the household `timezone` setting was never set, so the panel snapshot read UTC: morning quests showed overdue hours early and `today_iso` rolled over at UTC midnight. The integration now reports `hass.config.time_zone` on every panel request (`X-NestQuest-Timezone`). While the admin has not chosen a zone (`timezone_configured` is false) the API adopts and persists it, so the panel, the admin plane, and the missed-sweep scheduler all read the household clock out of the box. An explicit admin choice — including an explicitly chosen empty zone — still wins; an invalid reported zone is logged and ignored. No schema change. Task: 6351b36d-0eef-4e7d-bf5a-96b754cbc883 Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
@@ -327,12 +327,14 @@ class NestQuestSettings:
|
||||
def household_now(self, instant: datetime.datetime) -> datetime.datetime:
|
||||
"""Return the aware ``instant`` expressed in the household's zone.
|
||||
|
||||
The API service has no Home Assistant ``time_zone``, so its one
|
||||
The API service does not run inside Home Assistant, so its one
|
||||
clock read (an aware host-local ``now``) is converted here: with
|
||||
:attr:`timezone` set the SAME instant is re-expressed in that
|
||||
zone, so ``.date()`` and ``.time()`` are the household's wall
|
||||
clock even when the host runs UTC. With :attr:`timezone` empty
|
||||
the instant is returned unchanged (the host's local time).
|
||||
:attr:`timezone` set — the admin's choice, or else the zone the
|
||||
integration reports from Home Assistant — the SAME instant is
|
||||
re-expressed in that zone, so ``.date()`` and ``.time()`` are the
|
||||
household's wall clock even when the host runs UTC. With
|
||||
:attr:`timezone` empty the instant is returned unchanged (the
|
||||
host's local time).
|
||||
"""
|
||||
if not self.timezone:
|
||||
return instant
|
||||
|
||||
Reference in New Issue
Block a user