Skip to content

fix: add timezone selector to quiet hours in web UI - #76

Open
jampick wants to merge 1 commit into
mainfrom
fix/quiet-hours-timezone-ui
Open

fix: add timezone selector to quiet hours in web UI#76
jampick wants to merge 1 commit into
mainfrom
fix/quiet-hours-timezone-ui

Conversation

@jampick

@jampick jampick commented Apr 19, 2026

Copy link
Copy Markdown
Owner

Summary

  • Quiet hours config only showed timezone as static read-only text (Pi system clock, not selectable). Users on a different timezone than the Pi had no way to configure it.
  • Adds a full <select> dropdown with 40 IANA timezone options (plus a System default entry that preserves existing behaviour).
  • Wires the value all the way from the form → validation → config file → watch loop → _is_in_quiet_hours() using zoneinfo.

Files changed:

  • pi/appliance.py"quiet_tz": "" added to default_config()
  • pi/webapp/server.pySELECTABLE_TIMEZONES list; quiet_tz validation & persistence; _quiet_hours_active() is now tz-aware; both render_template calls pass timezones=
  • pi/webapp/templates/index.html<select name="quiet_tz"> replaces the static help text
  • printpulse/app.py--quiet-tz CLI argument
  • printpulse/watch.pytz param on _is_in_quiet_hours(); quiet_tz param on run_watch_loop()
  • printpulse/pi_launcher.py — passes --quiet-tz from appliance config to run()

Test plan

  • test_appliance.pyquiet_tz present in default config and defaults to ""
  • test_validation.py — valid IANA zone accepted; unknown zone rejected with error; empty string (system default) accepted; injection attempt rejected
  • test_watch.py_is_in_quiet_hours with valid tz uses zoneinfo; invalid tz falls back to local time without raising
  • All 249 existing tests still pass

Fixes #37

🤖 Generated with Claude Code

The quiet hours section showed timezone as static read-only text
(system local only). Users had no way to choose a different timezone,
so quiet hours always fired against the Pi's local clock.

Changes:
- pi/appliance.py: add quiet_tz="" to default_config()
- pi/webapp/server.py: add SELECTABLE_TIMEZONES list; validate and
  save quiet_tz from the form; pass timezones= to both render_template
  calls; update _quiet_hours_active() to use configured tz via zoneinfo
- pi/webapp/templates/index.html: replace static "Timezone: {{ timezone }}"
  help text with a <select> dropdown (System default + 40 IANA zones)
- printpulse/app.py: add --quiet-tz CLI argument, thread to run_watch_loop
- printpulse/watch.py: add tz param to _is_in_quiet_hours(), add
  quiet_tz param to run_watch_loop(), pass tz to all call sites
- printpulse/pi_launcher.py: pass --quiet-tz from appliance config

Tests added: default_config has quiet_tz key; valid/invalid tz validation;
tz-aware quiet hours check; invalid tz falls back to local time.

Fixes #37

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant