Repository navigation
feat: away mode brings the old targets back on its own - #28
Merged
Merged
Conversation
"Away…" lowers every room with a known target to one target until a date and time, then raises each room back to the target it had before. Rooms whose target was changed during away are left alone. Raising the target back follows the rules for the end of airing: it repeats until the thermostat confirms it, never gives up, and the page shows a problem. Away is saved through a new AwayStore port in the SQLite database (migration 0002), so it survives a restart, and an end that passed while the service was down is applied as soon as it runs again. Changes to several rooms are made together: if one room can't be saved, none changes. API: PUT and DELETE /api/away, RoomList.away, and Room.awayState and awayRestoreTarget. The page gets a banner with "Back now" and a native dialog that suggests 17 °C and the next day. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Stacked on #27 (airing in SQLite). Merge that first; GitHub then retargets this PR to
main.Why
When leaving for a few days, every room had to be lowered by hand, and nothing raised the targets again. Away mode does both. Its state is saved, so a restart or release during the trip doesn't lose the return.
What changes
StartAway(until, target)gives every room whose target is known the away target and remembers its old one.EndAway()ends away now.commandFailedshows on the page after about 5 minutes.AwayStoreport, combined withAiringStoreintoStore, holds anAwayvalue created throughRestoreAway.0002_away.sqladds anawaytable. A database created by feat: keep airing in SQLite so it survives a restart #27 is migrated in place.PUT /api/awayanswers 400 for an invalid end or target, 409 if no room's target is known yet, and 500 if the change couldn't be saved.DELETE /api/awayends away now.away; each room gainsawayStateandawayRestoreTarget.api.Activeis nowapi.AiringStateActive) because the new enum shares values with it.<dialog>with adatetime-localfield for the end and a number field for the away target. It suggests 17 °C and the next day.Verification
go build ./...,go vet ./...andgo test -race ./...pass. golangci-lint v2.15.0 (through podman) reports 0 issues.Controller tests (12):
As a check, I removed the never-give-up rule, and its test failed.
SQLite tests: round trip, migrating a database at schema version 1, and a reopen test: away that ends while the service is down still sends the old target after it starts.
Local run against a throwaway Mosquitto (podman) with two fake thermostats:
Not verified: real thermostats, the cluster.
🤖 Generated with Claude Code