Repository navigation
Conversation
A Docker box runs on UTC whatever house it is in, so a car goal of 17:00 was met at 18:00 in a Stockholm winter. Core now reads the household clock from site.time_zone, set once at start, instead of the host's zone. - localzone.Use sets time.Local (and TZ for workers) from the stored zone before any goroutine reads the clock; Name reports it. - site.time_zone is validated, shown under Settings → Site, written by the on-box setup from the browser, and listed as a restart reason. - site.time_zone.propose lets the app and the web client offer their zone. The box takes it only while it keeps none (nothing stored, host on UTC), then restarts once. A kept zone answers E_PRECONDITION with args.tz. - Cached local-day energy is tied to the zone it was computed on; a new zone clears it and the days are computed again from UTC buckets. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Codex Review SummaryThis comment shows the latest Codex review activity on this pull request.
ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings. |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: e3ba1ae786
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
| if zone == "" { | ||
| household = "" | ||
| return nil |
There was a problem hiding this comment.
Restore the host TZ when clearing the stored time zone
On the Home Assistant add-on restart path, clearing site.time_zone in Settings does not restore the host's clock. The preceding boot overwrote TZ with the stored zone, and execCurrentProcess in go/cmd/ftw/reexec.go passes os.Environ() into the replacement process. This empty-zone branch therefore inherits the previous household zone as its supposed host zone, leaving schedules and daily boundaries on the cleared setting until the container is fully restarted. Preserve the original host environment across re-execs, or restrict the household TZ override to worker environments.
AGENTS.md reference: AGENTS.md:L20-L21
Useful? React with 👍 / 👎.
Problem
Erik's car goal said 100 % by 17:00 on Sunday. His box aimed at 18:00. It runs in Docker, and Docker runs on UTC, so Core read 17:00 on a UTC clock. Every wall-clock rule had the same gap: car and charger goals, the import hour, daily history and savings. Core read
time.Local, which comes from the host.Fredrik decided on 31 October 2026 that the home's time zone is a stored fact of the site. This replaces passing
TZinto Docker.Stacked on #1945, which makes "UTC" mean UTC. Merge #1945 first; this PR then targets
master.Change
site.time_zone(IANA name) lives in the settings document Core already keeps instate.db.localzone.Usesetstime.Localfrom it at start, before any goroutine reads the clock, and setsTZfor workers.localzone.Namereports it. Empty keeps the host zone, so native installs run as today.site.time_zone.propose(scopeftw.setup.write). The box takes the offer only while it keeps no zone: nothing stored and a host on UTC. It saves the zone and restarts once to run on it. A box that keeps a zone answersE_PRECONDITIONwithargs.tz, so a phone abroad cannot move a house's clock. The on-box setup writes the browser's zone, and Settings → Site shows the field.RestartRequiredForlistssite.time_zone./site/time_zone. The guide no longer says there is no such field.When the zone changes
energy_daily_partial,history_daily_quality)KeepDailyZonerecords the zone it was built on and clears it on a new zone. Each day is computed again from the UTC buckets on its next read. The first boot records the zone without clearing, so an unchanged box does not pay the cold recompute.first_deadline_ms). Not recomputed.Decisions for Fredrik
minor(new stored setting and op). Please approve or ask forpatch.Evidence
make verifygreen on this Mac.TestABoxOnUTCPlansACarGoalOnTheStoredHouseholdClock(cmd/ftw),TestAStoredZoneIsTheClockOfABoxOnUTC(localzone),TestABoxOnUTCTakesThePhonesZoneAndRestartsand kept-zone cases (api), the op's applied, kept, bad-arg and unavailable answers (appproto),TestANewHouseholdZoneClearsTheCachedDays(state).time_of_day_min1020, days Sunday):household clock zone=Etc/UTC stored=false,target_time 2026-11-01T17:00:00Z(18:00 in Stockholm)Europe/Stockholmthrough Settings, restart:household clock zone=Europe/Stockholm stored=true,household zone changed; daily energy is computed again,target_time 2026-11-01T16:00:00Z(17:00 in Stockholm).datein the container still says UTC./api/energy/dailyand/api/setup/schemareportEurope/Stockholm.Paired PRs
The registry line is byte-identical in all three.
Open PRs that touch
config/config.goorappproto/handler.go(#1792, #1789, #1691, #1051): this PR adds lines and rewrites nothing they change.🤖 Generated with Claude Code