Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 11 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,20 @@ A small web page to adjust the heating per room from a phone on the home network

<img src="docs/screenshot.png" alt="The heating page on a phone: Office and Bedroom cards, each with the room temperature, whether it is heating, the target and buttons to change it" width="360">

Work in progress.
## Airing

"Airing 15/30/60" sends `system_mode: off`. When the time is up, or on "Heat again", the room gets back the mode and target from before.

The service keeps no saved state, so a restart during airing forgets it: **that room stays off until someone taps "Heat again"**. A target waiting to be sent is lost too. The thermostat's own frost protection still applies.

- A target changed during airing is applied when it ends.
- A thermostat leaving off during airing gets off once more. If it leaves off again, someone is at the radiator, so airing ends.
- Commands repeat until the thermostat confirms them, every 30 s for about 5 minutes. A target then gives up and shows the thermostat's value. Off and heat-again keep trying every 5 minutes and show a problem on the page, because giving up would mean heating with the window open or a cold room.
- A thermostat that is off with no airing is left alone, because it can turn itself off and come back. The page offers "Heat again" for it.

## Deployment

The Helm chart in [`charts/heating-control`](charts/heating-control) is published with every release as `oci://ghcr.io/subpathdev/charts/heating-control`. Set `config.broker` and `config.rooms`; adding a room is one more entry in `config.rooms`. Run one replica only, because the MQTT client ID is fixed.
The Helm chart in [`charts/heating-control`](charts/heating-control) is published with every release as `oci://ghcr.io/subpathdev/charts/heating-control`. Set `config.broker` and `config.rooms`; adding a room is one more entry in `config.rooms`. Run one replica only, and give any other instance its own `config.clientId`: a second client with the same ID disconnects the first.

## API

Expand Down
10 changes: 8 additions & 2 deletions cmd/heating-control/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -49,13 +49,19 @@ func main() {
health.Register(mux, version, checker)
mux.Handle("GET /metrics", m.Handler())
// Probes and scrapes use the pod's IP and stay outside the page's checks.
mux.Handle("/", web.Handler(ctrl, cfg.AllowedHosts))
mux.Handle("/", web.Handler(ctrl, checker, cfg.AllowedHosts))

srv := &http.Server{
Addr: ":8080",
Handler: mux,
ReadHeaderTimeout: 5 * time.Second,
}
controllerDone := make(chan struct{})
go func() {
defer close(controllerDone)
ctrl.Run(ctx)
}()

shutdownDone := make(chan struct{})
go func() {
defer close(shutdownDone)
Expand All @@ -73,5 +79,5 @@ func main() {
}
// ListenAndServe returns as soon as Shutdown starts, so let requests finish.
<-shutdownDone
ctrl.Wait()
<-controllerDone
}
Loading
Loading