Repository navigation
Conversation
The display schedule (CEC power-off plus local blanking) used one pair
of on/off times for every active day. Shops rarely keep the same hours
all week: a typical setup is Mon-Fri 07:30-18:00 and Sat 10:00-14:00.
Adds an optional per-weekday override stored as
display_power_day_times ('D=HH:MM-HH:MM', comma-separated). A weekday
without an entry keeps using the shared on/off times, and the default
is empty, so existing schedules behave exactly as before.
- lib/display_power: parse/format helpers and should_be_on() taking the
overrides. An overnight period still belongs to the day it starts,
now with that day's own off time.
- Settings page: a "Different hours per day" toggle that swaps the
shared time fields for one row per weekday (day chip + on/off
times). Switching it on seeds every row from the shared times.
- v2 device settings: new display_power_day_times field on GET and
PATCH (additive; malformed entries or a weekday given twice are a
400).
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01TPcJJqJJ5aMsTa37NG4F7t
vpetersson-bot
left a comment
There was a problem hiding this comment.
LGTM. Approving.
What I checked:
should_be_onrewrite. With no per-day overrides, I compared the new function against the previous implementation on 20,000 random (on, off, days, now) combinations, including overnight windows and partial day sets. The results were identical, so existing schedules behave exactly as before. The new per-day and overnight-tail tests intests/test_display_power.pypass locally. The "tail of yesterday's window first, then today's own window" ordering handles the mixed cases well: a shared overnight window running into an overridden morning, and an override rescuing shared times that can't be used.- Storage/API.
parse_day_timesis lenient for the beat andparse_day_timeis strict for the v2 serializer, which matches howparse_hhmm/parse_daysare already split. Rejecting a weekday given twice with a 400, instead of silently picking one, is the right call. The empty default keeps existing installs unchanged. - Settings form. Each set of day chips is disabled both server-side and through
:disabledwhen it's hidden, sodisplay_power_daysis posted exactly once with or without JS. An invalid per-day row keeps that day's previous hours and shows an error, consistent with the shared time fields.
Non-blocking follow-ups:
website/content/docs/display-schedule.mdstill describes a single on/off pair. The field reference table is missingdisplay_power_day_times(formatD=HH:MM-HH:MM, Monday=0, empty = shared times). The "Days and overnight schedules" section should also say that an overnight period ends on its starting day's off time. The checklist marks docs as done, but this page wasn't touched. Fine as a quick follow-up PR. (website/data/openapi.jsonis regenerated on deploy, so nothing to do there.)- Nit:
import reinsidetest_settings_renders_per_day_hoursshould move to the module imports.
- display-schedule.md: add display_power_day_times to the field reference, a "Different hours per day" section, the overnight rule (a period ends at its starting day's off time) and an API example. - tests: hoist `import re` in test_template_views.py to the module imports instead of importing it inside individual tests. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01TPcJJqJJ5aMsTa37NG4F7t
|
vpetersson-bot
left a comment
There was a problem hiding this comment.
Re-approving at 3d14deb. The dismissal followed the new commit, which only changes docs and test imports.
display-schedule.md: I checked it against the code. The overnight example matchesshould_be_on: Friday 18:00 → 02:00 is still on at Sat 01:00, off at 02:00, and Saturday's own window starts at 10:00. "Switching it off clears the per-day hours" matches_apply_display_power_day_times. The API rules matchvalidate_display_power_day_times: sortedHH:MMoutput, a 400 for a malformed entry, identical on/off times or a duplicate weekday, and blank clears every entry. "The form rejects identical times" matches too: the row is ignored with an error message and the day keeps its previous hours.tests/test_template_views.py: the function-localimport restatements move to a single module-level import. No behaviour change.
| try: | ||
| day, window = display_power.parse_day_time(token) | ||
| except ValueError as exc: | ||
| raise serializers.ValidationError(str(exc)) from exc |
There was a problem hiding this comment.
False positive. str(exc) here is only ever one of the operator-readable ValueError messages raised in display_power.parse_day_time (format, weekday range, HH:MM, on == off). parse_hhmm returns None rather than raising, so no traceback or internal state reaches the response. It's the same 400-with-message pattern validate_display_power_days already uses. Safe to dismiss as "false positive"; my approval at 3d14deb stands.



The display schedule (CEC power-off plus local blanking) used one pair of on/off times for every active day. Shops rarely keep the same hours all week.
Adds an optional per-weekday override stored as
display_power_day_times ('D=HH:MM-HH:MM', comma-separated). A weekday without an entry keeps using the shared on/off times, and the default is empty, so existing schedules behave exactly as before.
Checklist