diff --git a/docs/changelog.md b/docs/changelog.md index 443f69a7a..77ca0fc6e 100644 --- a/docs/changelog.md +++ b/docs/changelog.md @@ -19,6 +19,27 @@ docstring gives: it is a record, not a claim about now. ## 2026-11-24 +- **The wall page changes after the operator's card-by-card review** + ([ADR-0119](adr/0119-put-the-office-wall-dashboard-on-a-pi-5-on-hicks.md), + `stacks/sensitive/README.md`, *The wall page*). Not yet deployed or seen + on the television when this was written. + - **Tiles:** ten, five to a row. `gandalf` joins by CPU, as it has been + always on since ADR-0125 and already reports to Prometheus, and the eero + mesh is one tile, how many access points answer their ping. The lab's + guests report to `alexander`'s Prometheus and stay off. + - **Internet:** the big figures were the WAN port's traffic at that + moment, which read like a speed test and was not one. They are now + speedtest-tracker's last result and its age; the traffic is the line and + sparkline beneath. The connect time to 1.1.1.1 and `/api/q/rtt` are gone, + as the test's ping replaces them. + - **Dogs:** the card is gone, and `wall_dogs.yaml` with it, its two + buttons and two intervals included. It was not as useful as hoped. + - **Home row:** the office lights and `binary_sensor.wall_office_lights` + are gone. "House empty" shows while presence has marked it so, the + thermostat shows what it is set to, and the Litter-Robot shows always. + - **Status bar:** it names only a source that has fallen behind, and + otherwise reads "all sources live". + - **`heimdall` runs the new §2 steps, and its bootloader is staged on the card, not written by `flashrom`.** This corrects the entry "A re-check of `heimdall` found its bootloader never updates, and nothing watching it", diff --git a/docs/security.md b/docs/security.md index 6021bd82e..e152b5475 100644 --- a/docs/security.md +++ b/docs/security.md @@ -1143,28 +1143,27 @@ from Home Assistant with *not enough permissions*. that difference is accepted. It holds two credentials: the reader token, which can only query, and a Fever key that can only mark items read for a Miniflux user that follows public feeds. -- **The wall page answers ten fixed questions** +- **The wall page answers twelve fixed questions** ([ADR-0119](adr/0119-put-the-office-wall-dashboard-on-a-pi-5-on-hicks.md)): `wall.matrix.elysium` on `trinity`'s Caddy. Each `/api/q/NAME` is one PromQL query written in the Caddyfile, sent with the reader token, which Caddy adds. The caller picks a name, never a query, and its own query string is discarded. Only GET and HEAD are served, because Prometheus would take a POST body's `query=` over the URL's. Like Glance it has no login, so - anything that reaches `trinity:443` can read those ten answers: the - firing alerts, per-host CPU, SNMP reachability, WAN traffic and latency, - the UPS, `heimdall`'s temperature, when each backup, restore test and + anything that reaches `trinity:443` can read those twelve answers: the + firing alerts, per-host CPU, SNMP reachability, which eero units answer + their ping, WAN traffic, the last speed test and when it ran, the UPS, `heimdall`'s temperature, when each backup, restore test and off-site copy last succeeded, and how many security updates and reboots each host is waiting for. That is less than Glance's Homelab and Maintenance pages already show, and the page and the Pi hold no credential. - **Its household half reads twenty Home Assistant entities the same way.** + **Its household half reads nineteen Home Assistant entities the same way.** Each `/api/ha/NAME` is one `GET /api/states/` written in the Caddyfile: the weather, today's forecast, the alarm's mode, four door - contacts, two window contacts, the office lights, the thermostat, the + contacts, two window contacts, whether the house is empty, the thermostat, the Litter-Robot's summary, the next drive, the Shabbat times, the open to-do items, the next trash pickup, the packages to collect by their own labels, what the labelled players are playing (title, artist and app, never the - player's name or room), when the dogs were last walked and fed, and - `sensor.wall_today`, + player's name or room), and `sensor.wall_today`, which holds the next seven days' calendar events. Caddy adds the token of HA's non-admin `wall` user. Home Assistant has no read-only role, so that token could call services, the alarm's included. It is read-only only because it lives in @@ -1172,7 +1171,8 @@ from Home Assistant with *not enough permissions*. residual is that whoever can read that container's environment holds a token that can operate the house. They would already be root on the host that runs Home Assistant. Anything that reaches `trinity:443` can read - whether the doors are open, whether the alarm is set, the family's + whether the doors are open, whether the alarm is set, whether anyone's + phone is home (one boolean, never whose), the family's schedule for the coming week (each event's title, time and location), the open to-do items, and the labels of packages waiting to be collected. That is the same as the Home Assistant app shows to the household, without its diff --git a/stacks/sensitive/Caddyfile b/stacks/sensitive/Caddyfile index 52f67badc..b99d0f7e0 100644 --- a/stacks/sensitive/Caddyfile +++ b/stacks/sensitive/Caddyfile @@ -276,7 +276,7 @@ start.matrix.elysium { # rewrite, so /api/q/cpu?query=anything still asks the CPU # question. Nothing else under /api/ answers. The reader token # can query and nothing more (ADR-0067); this narrows it again, -# to eight answers. The page holds no credential, and neither +# to twelve answers. The page holds no credential, and neither # does the Pi. # /api/ha/NAME one Home Assistant entity's state, the same way: each handle # rewrites to /api/states/ and ends in `?`, which @@ -369,10 +369,36 @@ wall.matrix.elysium { import wall_prometheus } - # TCP connect time to 1.1.1.1:443, the internet anchor. - # probe_duration_seconds{job="blackbox-latency",name="cloudflare"} - handle /api/q/rtt { - rewrite * /api/v1/query?query=probe_duration_seconds%7Bjob%3D%22blackbox-latency%22%2Cname%3D%22cloudflare%22%7D + # speedtest-tracker's last result, scraped from its container on + # `prometheus` every 30 minutes: download and upload in bits per + # second, ping, and the result id. A failed test exports only the id, + # with status="failed" (rules/internet.rules.yaml, SpeedtestStale), so + # the id is asked too: without it a failure reads as no answer. + # {__name__=~"speedtest_tracker_result_id|speedtest_tracker_download_bits|speedtest_tracker_upload_bits|speedtest_tracker_ping_ms",job="speedtest-tracker"} + handle /api/q/speedtest { + rewrite * /api/v1/query?query=%7B__name__%3D~%22speedtest_tracker_result_id%7Cspeedtest_tracker_download_bits%7Cspeedtest_tracker_upload_bits%7Cspeedtest_tracker_ping_ms%22%2Cjob%3D%22speedtest-tracker%22%7D + import wall_prometheus + } + + # When that result landed, to within a few minutes: the last minute in + # three hours at which the result id changed. A first result has no + # change to find, so failing that, the minute the id first appeared, + # provided that was inside the window (more than five minutes after its + # start) rather than at its edge. Empty when neither holds, which means + # no new result in three hours, and the page shows it as stale. + # max_over_time((timestamp(changes(max(speedtest_tracker_result_id{job="speedtest-tracker"})[3m:1m]) > 0))[3h:1m]) + # or (min_over_time(timestamp(max(speedtest_tracker_result_id{job="speedtest-tracker"}))[3h:1m]) > time() - 10500) + handle /api/q/speedtest_at { + rewrite * /api/v1/query?query=max_over_time%28%28timestamp%28changes%28max%28speedtest_tracker_result_id%7Bjob%3D%22speedtest-tracker%22%7D%29%5B3m%3A1m%5D%29%20%3E%200%29%29%5B3h%3A1m%5D%29%20or%20%28min_over_time%28timestamp%28max%28speedtest_tracker_result_id%7Bjob%3D%22speedtest-tracker%22%7D%29%29%5B3h%3A1m%5D%29%20%3E%20time%28%29%20-%2010500%29 + import wall_prometheus + } + + # The eero mesh's tile: each access point's probe, and `up` for every + # configured target, so a probe whose scrape failed (no probe_success + # at all) still counts against the mesh instead of leaving the total. + # {__name__=~"up|probe_success",job="blackbox-eero"} + handle /api/q/eero { + rewrite * /api/v1/query?query=%7B__name__%3D~%22up%7Cprobe_success%22%2Cjob%3D%22blackbox-eero%22%7D import wall_prometheus } @@ -450,10 +476,11 @@ wall.matrix.elysium { import wall_ha } - # The office lights, on when any is on, through a template entity in - # home-assistant/packages/wall_house.yaml: their own ids name a person. - handle /api/ha/office_light { - rewrite * /api/states/binary_sensor.wall_office_lights? + # On once every tracked phone has left the house + # (home-assistant/packages/presence.yaml). One boolean: no person's + # name or location. + handle /api/ha/house_empty { + rewrite * /api/states/input_boolean.house_empty? import wall_ha } @@ -481,7 +508,6 @@ wall.matrix.elysium { # trash the next pickup, from three helpers # deliveries packages to go and get (17TRACK) # media what the players labelled wall_media are playing - # dogs when the dogs were last walked and fed handle /api/ha/commute { rewrite * /api/states/sensor.wall_commute? import wall_ha @@ -512,11 +538,6 @@ wall.matrix.elysium { import wall_ha } - handle /api/ha/dogs { - rewrite * /api/states/sensor.wall_dogs? - import wall_ha - } - # Today's high and low, the next rain and the next sunrise or sunset, # asked of weather.get_forecasts by # home-assistant/packages/wall_weather.yaml: since HA 2024.4 a forecast diff --git a/stacks/sensitive/README.md b/stacks/sensitive/README.md index e6a0824c9..904362e69 100644 --- a/stacks/sensitive/README.md +++ b/stacks/sensitive/README.md @@ -755,8 +755,9 @@ by `heimdall`'s kiosk ([ADR-0119](../../docs/adr/0119-put-the-office-wall-dashboard-on-a-pi-5-on-hicks.md), [`build-heimdall.md`](../../docs/runbooks/build-heimdall.md)). It shows about eight things at a size read from across the room: the time, the firing -alerts, eight hosts, the internet, the UPS, and how old each answer is. No -container of its own: Caddy serves `wall/` as static files. +alerts, ten tiles of hosts and devices, the internet, the UPS, and any source +whose answer is late. No container of its own: Caddy serves `wall/` as +static files. - **The page chooses the question, never the query.** Each `/api/q/NAME` is a `handle` in the Caddyfile that rewrites to one PromQL query written there, @@ -793,26 +794,50 @@ container of its own: Caddy serves `wall/` as static files. succeeded or waiting is amber. What no host reports is left out rather than shown as none, and with neither line, "Nothing is firing." stays ("Nothing that notifies is firing." while an info alert is). A host that stops reporting reads *no data*. The status bar - gives each source's age and turns amber at two and a half minutes. + names only a source that has fallen behind, with its age, amber from two + and a half minutes and red from seven and a half or when it has never + answered; with none behind it reads "all sources live". `heimdall`'s own + temperature sits at its right end. +- **The tiles.** Ten, five to a row: `morpheus`, `neo` and `mjolnir` by + whether they answer SNMP (`/api/q/snmp`); `Saruman`, `gandalf`, + `trinity`, `prometheus`, `oracle` and `smaug` by CPU (`/api/q/cpu`); + and the eero mesh as one tile, how many of its access points answer their + ping out of every configured target (`/api/q/eero` reads `up` as well as + `probe_success`, so a probe whose scrape failed still counts; + `targets/blackbox-eero.yaml`), amber when one is silent and red when all + are. The lab's guests report to `alexander`'s + Prometheus, not this one, so they have no tile. +- **The Internet card is the last speed test.** Download, upload and ping + from speedtest-tracker, which runs every 30 minutes (`/api/q/speedtest`), + and how long ago it landed (`/api/q/speedtest_at`: the last minute in + three hours at which its result id changed, or for a first result the + minute its id appeared). A failed test exports only its result id, which + the page reads to say "last test failed". A figure is amber under the + bars `internet.rules.yaml` alerts on, 400 Mbit/s down and 100 up, and all + of them are when the test is over 90 minutes old. Under them, the WAN + port's traffic now (`/api/q/wan`), and the sparkline is its last hour of + download (`/api/q/wan_hour`). - **The household half comes from Home Assistant, the same way.** Each `/api/ha/NAME` rewrites to `GET /api/states/`. The rewrite ends in `?`, so the client's query string is dropped. Caddy adds `WALL_HA_TOKEN`, the token of HA's non-admin `wall` user. The entities are `weather.forecast_home`, the front, garage, garden and patio door contacts, - the two window contacts, and two template entities from - `home-assistant/packages/wall_house.yaml`: `sensor.wall_alarm` (the - house's one alarm panel) and `binary_sensor.wall_office_lights` (on when - any light whose id contains `office` is on). + the two window contacts, `input_boolean.house_empty` from + `home-assistant/packages/presence.yaml` at `/api/ha/house_empty`, and + `sensor.wall_alarm` from `home-assistant/packages/wall_house.yaml`, the + house's one alarm panel. The page shows them as the header's weather and a one-line Home row: the - alarm's mode, any open door or window in amber, the hallway thermostat's - temperature, humidity and whether it is heating or cooling (read from - `climate.thermostat` at `/api/ha/thermostat`), the office lights, and the - Litter-Robot in amber only when it wants something (`sensor.wall_litter` - at `/api/ha/litter`, from `wall_house.yaml`), and as `—` when it cannot be - read. A row too long for the screen drops the office lights first, then - the thermostat, then an unreadable Litter-Robot's `—`, never an amber - item; if the warnings alone are still too wide, each says how many - instead of which ("6 doors & windows"). + alarm's mode; "House empty" while presence has marked it so, and nothing + otherwise; any open door or window in amber; the hallway thermostat's + temperature and humidity, then what it is set to and whether it is + heating or cooling ("68° · 45% · heating to 70", a range in heat_cool, + "away" while presence holds it there; read from `climate.thermostat` at + `/api/ha/thermostat`); and the Litter-Robot, always: `ok`, what it wants in + amber, or `—` when it cannot be read (`sensor.wall_litter` at + `/api/ha/litter`, from `wall_house.yaml`). A row too long for the screen + shortens the thermostat to its reading and target ("68° → 70"); if the + warnings are still too wide, each says how many instead of which + ("6 doors & windows"). The header's high and low, the next rain and the next sunrise or sunset are `sensor.wall_weather` at `/api/ha/forecast`, from `home-assistant/packages/wall_weather.yaml`, which asks @@ -831,8 +856,7 @@ container of its own: Caddy serves `wall/` as static files. (`/api/ha/commute`); Shabbat or Yom Tov, from six hours before candle lighting to havdalah (`/api/ha/shabbat`); the bins, from 16:00 the evening before pickup to noon on the day (`/api/ha/trash`); packages to go and - get (`/api/ha/deliveries`); the dogs, while a walk or a feeding is overdue - (`/api/ha/dogs`); the open to-do items (`/api/ha/todo`); what is + get (`/api/ha/deliveries`); the open to-do items (`/api/ha/todo`); what is playing on the players labelled `wall_media` (`/api/ha/media`); and otherwise a Hebrew word of the day from a static list in the page. The others that also apply are named on the card's last line. Each source is a @@ -841,18 +865,16 @@ container of its own: Caddy serves `wall/` as static files. `Home`, region US, any destination, its polling off) and the label `wall_commute` on each calendar to route from, the Jewish Calendar integration, a to-do list labelled `wall_todo`, the trash helpers' - pickup day, the 17TRACK integration with the household's account, a - walking or feeding interval above 0 for the dogs, and the label + pickup day, the 17TRACK integration with the household's account, and the label `wall_media` on each player to show. The commute card sends the next labelled event's location to Waze. The UPS's mains or battery, charge and runtime are in its node tile, `mjolnir`. Booted on Home Assistant 2026.11.1 against its demo calendars on 2026-11-18: the sensor held both events, and with no calendar it read unavailable, which - the page shows as `calendar · unavailable`. The real ids of the alarm and the - office lights name the city and a person, so the package finds them and - only its own ids are written here. Booted on Home Assistant 2026.11.1 with - a stand-in alarm and office light, both followed the real ones from - disarmed and off to armed and on. HA has no read-only role, so the narrowing in + the page shows as `calendar · unavailable`. The alarm's real id names the city, + so the package finds it and only its own id is written here. Booted on + Home Assistant 2026.11.1 with a stand-in alarm, it followed the real one + from disarmed to armed. HA has no read-only role, so the narrowing in Caddy is the read-only part (`docs/security.md`). Measured against the pinned Caddy with a stand-in HA on 2026-11-18: each handle reached only its entity with the token, `?x=1` was dropped, POST was refused with 405, diff --git a/stacks/sensitive/home-assistant/packages/README.md b/stacks/sensitive/home-assistant/packages/README.md index 55d98ea6e..780c8cbc2 100644 --- a/stacks/sensitive/home-assistant/packages/README.md +++ b/stacks/sensitive/home-assistant/packages/README.md @@ -29,10 +29,9 @@ and nothing else. This README is not YAML and Home Assistant ignores it. | `thermostat.yaml` | Thermostat alerts, no control: the hallway too cold or hot, humidity out of range, emergency heat switched on, the thermostat gone from Honeywell's cloud, or its gateway gone from the network (from its DHCP renewals in Loki). Each condition is a template binary sensor, so a restart does not lose it. Alerts go to phones labelled `household_phones` and to Home Assistant's notifications. The thermostat keeps its own schedule | | `tv_room_evening.yaml` | At 19:00 the TV comes on with Prime Video open and the TV room at its Mood scene; at 21:00 a bedtime nudge on the living-room Echo and the TV. A pause switch skips both | | `wall_calendar.yaml` | `sensor.wall_today`: the next seven days' events, asked of `calendar.get_events` every five minutes, for the office wall's Today panel, its week below tomorrow and the header's *Up next* (ADR-0119). The calendars are those labelled `wall_calendar` in the UI, or all of them when none is labelled, so no calendar is named here. Unavailable, not empty, when a calendar cannot be read | -| `wall_house.yaml` | `sensor.wall_alarm`, `binary_sensor.wall_office_lights` and `sensor.wall_litter` for the office wall (ADR-0119): the house's one alarm panel's mode, and whether any light whose id contains `office` is on. Their own ids name the city and a person, so the wall reads these instead. Unavailable when nothing matches. `sensor.wall_litter` is `ok` or `attention`, with what in `needs`: the drawer at 90%, the litter under 30% or a cat's weight dropping, `litter_robot.yaml`'s thresholds | +| `wall_house.yaml` | `sensor.wall_alarm` and `sensor.wall_litter` for the office wall (ADR-0119): the house's one alarm panel's mode, whose own id names the city, so the wall reads this instead. Unavailable when nothing matches. `sensor.wall_litter` is `ok` or `attention`, with what in `needs`: the drawer at 90%, the litter under 30% or a cat's weight dropping, `litter_robot.yaml`'s thresholds | | `wall_commute.yaml` | `sensor.wall_commute` for the office wall's context card (ADR-0119): the minutes of the quickest live-traffic route from the home zone to the next timed event within three hours, on a calendar labelled `wall_commute` in the UI, whose location looks like a place (a digit or a comma, and not Teams, Zoom, Meet, Webex or a link), and when to leave, five minutes ahead. Asked of `waze_travel_time.get_travel_times` every five minutes, only while there is such an event; the Waze Travel Time integration has to be added once in the UI for the action to exist. Sends that location to Waze. `none` when there is nothing to drive to | | `wall_deliveries.yaml` | `sensor.wall_deliveries` for the office wall's context card (ADR-0119): the 17TRACK packages delivered today, ready to be picked up or undelivered, by their own labels, and how many are in transit. Asked of `seventeentrack.get_packages` every fifteen minutes. Never the tracking numbers. Unavailable until the 17TRACK integration is added | -| `wall_dogs.yaml` | `sensor.wall_dogs` for the office wall's context card (ADR-0119): when the dogs were last walked and fed, the newest of a dashboard button (`input_button.dogs_walked`, `input_button.dogs_fed`) and an NFC tag labelled `wall_dog_walk` or `wall_dog_feed` in the UI, and how many hours each may go, set in the UI. The state counts what is overdue. Unavailable while both intervals are 0, the default | | `wall_media.yaml` | `sensor.wall_media` for the office wall's context card (ADR-0119): `playing` or `idle`, with the title, artist or series and app of the first playing media player labelled `wall_media` in the UI. Never the player's name or room, and no album art. Unavailable while no player carries the label | | `wall_shabbat.yaml` | `sensor.wall_shabbat` for the office wall's context card (ADR-0119): the upcoming candle lighting as its state, with havdalah, the parsha, the Hebrew date and any Yom Tov's name, from the Jewish Calendar integration's entities, found by what their ids end with. Unavailable until that integration is added | | `wall_todo.yaml` | `sensor.wall_todo` for the office wall's context card (ADR-0119): the open items, title and due date, of the to-do lists labelled `wall_todo` in the UI, asked of `todo.get_items` every minute. Unavailable while no list carries the label | diff --git a/stacks/sensitive/home-assistant/packages/wall_dogs.yaml b/stacks/sensitive/home-assistant/packages/wall_dogs.yaml deleted file mode 100644 index 032a95ecd..000000000 --- a/stacks/sensitive/home-assistant/packages/wall_dogs.yaml +++ /dev/null @@ -1,76 +0,0 @@ ---- -# When the dogs were last walked and fed, for the office wall's context card -# (ADR-0119). No device knows this, so someone records it, either way: -# -# - the two buttons below, on a dashboard, for anyone in the house; -# - an NFC tag, by the leash hook or the food bin, tapped with a phone that -# has the companion app. Each tag is an entity (`tag.*`) whose state is -# when it was last scanned; label it `wall_dog_walk` or `wall_dog_feed` in -# the UI and it counts. The label picks the tags, so none is named here. -# -# The newest of a button press and a labelled tag's scan wins. How long is too -# long is set in the UI, in hours; 0, the default, means not tracked, so the -# wall stays quiet until it is set. -# -# What reaches the wall: two times and two thresholds. Not who pressed or -# scanned, and not the dogs' names. - -input_button: - dogs_walked: - name: Dogs walked - icon: mdi:dog-side - dogs_fed: - name: Dogs fed - icon: mdi:bowl-mix - -input_number: - dogs_walk_every_hours: - name: Walk the dogs every (hours, 0 = not tracked) - icon: mdi:dog-side - min: 0 - max: 24 - step: 0.5 - mode: box - dogs_feed_every_hours: - name: Feed the dogs every (hours, 0 = not tracked) - icon: mdi:bowl-mix - min: 0 - max: 24 - step: 0.5 - mode: box - -template: - - sensor: - # State: how many of the two are overdue. now() makes it re-evaluate - # each minute. The wall works out the ages itself from the attributes. - - name: Wall dogs - unique_id: wall_dogs - default_entity_id: sensor.wall_dogs - icon: mdi:dog - availability: >- - {{ states('input_number.dogs_walk_every_hours') | float(0) > 0 - or states('input_number.dogs_feed_every_hours') | float(0) > 0 }} - state: >- - {% set ns = namespace(n=0) %} - {% for button, label, every in [ - ('input_button.dogs_walked', 'wall_dog_walk', 'input_number.dogs_walk_every_hours'), - ('input_button.dogs_fed', 'wall_dog_feed', 'input_number.dogs_feed_every_hours')] %} - {% set hours = states(every) | float(0) %} - {% set last = ([button] + label_entities(label)) | map('states') - | map('as_datetime', none) | reject('none') | list %} - {% if hours > 0 and (not last or now() - (last | max) > timedelta(hours=hours)) %} - {% set ns.n = ns.n + 1 %} - {% endif %} - {% endfor %} - {{ ns.n }} - attributes: - walked: >- - {% set last = (['input_button.dogs_walked'] + label_entities('wall_dog_walk')) | map('states') - | map('as_datetime', none) | reject('none') | list %} - {{ (last | max).isoformat() if last else none }} - fed: >- - {% set last = (['input_button.dogs_fed'] + label_entities('wall_dog_feed')) | map('states') - | map('as_datetime', none) | reject('none') | list %} - {{ (last | max).isoformat() if last else none }} - walk_hours: "{{ states('input_number.dogs_walk_every_hours') | float(0) }}" - feed_hours: "{{ states('input_number.dogs_feed_every_hours') | float(0) }}" diff --git a/stacks/sensitive/home-assistant/packages/wall_house.yaml b/stacks/sensitive/home-assistant/packages/wall_house.yaml index d5378b2dc..2d9cb6114 100644 --- a/stacks/sensitive/home-assistant/packages/wall_house.yaml +++ b/stacks/sensitive/home-assistant/packages/wall_house.yaml @@ -1,21 +1,18 @@ --- -# The alarm's mode, the office lights and the Litter-Robot, as entities the -# office wall can read by a fixed id (ADR-0119). +# The alarm's mode and the Litter-Robot, as entities the office wall can read +# by a fixed id (ADR-0119). # # The wall reads Home Assistant through fixed `GET /api/states/` # handles in the Caddyfile. The Ring Alarm's own entity id names the city, and -# the office lights' ids name a person, and docs/security.md keeps both out of -# the repository. So the Caddyfile names these two template entities instead, -# and they find the real ones without naming them: +# docs/security.md keeps that out of the repository. So the Caddyfile names +# this template entity instead, and it finds the real one without naming it: +# the house's one `alarm_control_panel`. A second panel would be ignored, and +# the first, sorted by id, kept. It reads unavailable, not "disarmed", when +# nothing matches or what matches is unavailable, so the wall shows "—" +# rather than a wrong all-clear. # -# - the alarm: the house's one `alarm_control_panel`. A second panel would be -# ignored, and the first, sorted by id, kept. -# - the office lights: every light whose id contains `office`, on when any of -# them is on. The Hue room and its bulbs both match, which gives the same -# answer. -# -# Both read unavailable, not "disarmed" or "off", when nothing matches or what -# matches is unavailable, so the wall shows "—" rather than a wrong all-clear. +# The office lights had a template here too until 2026-11-24, when the wall +# stopped showing them. template: - sensor: @@ -29,19 +26,8 @@ template: {% set panel = states.alarm_control_panel | map(attribute='entity_id') | sort | first %} {{ panel is not none and has_value(panel) }} - - binary_sensor: - - name: Wall office lights - unique_id: wall_office_lights - device_class: light - state: >- - {{ states.light | selectattr('entity_id', 'search', 'office') - | selectattr('state', 'eq', 'on') | list | count > 0 }} - availability: >- - {{ states.light | selectattr('entity_id', 'search', 'office') - | rejectattr('state', 'in', ['unavailable', 'unknown']) | list | count > 0 }} - - # The Litter-Robot, for the wall's Home row, which shows it only when it - # wants something: `ok`, or `attention` with what, in `needs`. The + # The Litter-Robot, for the wall's Home row: `ok`, or `attention` with + # what, in `needs`. The # thresholds are litter_robot.yaml's reminder's (drawer at 90%, litter # under 30%) and its weight sensors', so the wall and the phones agree. # Its own sensors' ids are already in that file and name no person; this diff --git a/stacks/sensitive/wall/index.html b/stacks/sensitive/wall/index.html index 782cf0c17..2745478d0 100644 --- a/stacks/sensitive/wall/index.html +++ b/stacks/sensitive/wall/index.html @@ -71,11 +71,14 @@

Elysian

Internet

+
-
—
Mb/s down
-
—
Mb/s up
-
—
ms to 1.1.1.1
+
—
Mb/s down
+
—
Mb/s up
+
—
ms ping
+
diff --git a/stacks/sensitive/wall/wall.css b/stacks/sensitive/wall/wall.css index 573030264..b783e6418 100644 --- a/stacks/sensitive/wall/wall.css +++ b/stacks/sensitive/wall/wall.css @@ -152,7 +152,7 @@ html, body { .node-grid { flex: 1; display: grid; - grid-template-columns: repeat(4, minmax(0, 1fr)); + grid-template-columns: repeat(5, minmax(0, 1fr)); grid-template-rows: repeat(2, minmax(0, 1fr)); gap: 16px; min-height: 0; @@ -161,7 +161,7 @@ html, body { background: var(--panel-2); border: 1px solid var(--line); border-radius: 14px; - padding: 16px 20px; + padding: 16px 16px; display: grid; grid-template-columns: auto 1fr; grid-template-rows: auto auto 1fr; @@ -171,7 +171,7 @@ html, body { min-height: 0; } .node .dot { width: 16px; height: 16px; border-radius: 50%; background: var(--green); } -.node .name { font: 600 26px/1.1 var(--mono); overflow: hidden; text-overflow: ellipsis; } +.node .name { font: 600 24px/1.1 var(--mono); overflow: hidden; text-overflow: ellipsis; } .node .role { grid-column: 1 / 3; font: 400 22px/1.3 var(--sans); color: var(--mute); align-self: start; } .node .val { grid-column: 1 / 3; align-self: end; font: 500 28px/1 var(--mono); color: var(--fg-dim); font-variant-numeric: tabular-nums; } .node .val small { font-size: 22px; color: var(--mute); margin-left: 8px; } @@ -187,6 +187,10 @@ html, body { .hero { font: 500 44px/1 var(--mono); color: var(--cyan); font-variant-numeric: tabular-nums; letter-spacing: -0.03em; } .hero.dim { color: var(--fg-dim); font-size: 40px; } .unit { font: 400 22px/1.4 var(--sans); color: var(--mute); margin-top: 6px; } +.hero.warn { color: var(--yellow); } +.wan-now { font: 400 22px/1.4 var(--sans); color: var(--fg-dim); margin-top: 10px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; } +.wan-now .warn { color: var(--yellow); } +.wan-now .sep { color: var(--mute); } .spark { flex: 1; width: 100%; min-height: 0; margin-top: 14px; } .spark path.line { fill: none; stroke: var(--green); stroke-width: 2.5; vector-effect: non-scaling-stroke; } .spark path.fill { fill: var(--green); fill-opacity: 0.12; stroke: none; } diff --git a/stacks/sensitive/wall/wall.js b/stacks/sensitive/wall/wall.js index 7b6ad1c17..c7cb8a457 100644 --- a/stacks/sensitive/wall/wall.js +++ b/stacks/sensitive/wall/wall.js @@ -18,17 +18,20 @@ // without anyone touching the Pi. const RELOAD_MS = 6 * 60 * 60 * 1000; - // The eight tiles, in the order they sit. `cpu` hosts are node_exporter - // hosts, keyed by `instance`; `snmp` devices by the `device` label in - // prometheus/targets/snmp.yaml. + // The ten tiles, five to a row, in the order they sit. `cpu` hosts are + // node_exporter hosts, keyed by `instance`; `snmp` devices by the `device` + // label in prometheus/targets/snmp.yaml. `eero` is the mesh as one tile: + // how many access points answer their ping (targets/blackbox-eero.yaml). const HOSTS = [ { name: "morpheus", src: "snmp", role: "firewall" }, + { name: "neo", src: "snmp", role: "core switch" }, { name: "Saruman", src: "cpu", role: "hypervisor" }, + { name: "gandalf", src: "cpu", role: "range hypervisor" }, { name: "trinity", src: "cpu", role: "sensitive tier" }, { name: "prometheus", src: "cpu", role: "monitoring" }, { name: "oracle", src: "cpu", role: "wiki, off-host jobs" }, { name: "smaug", src: "cpu", role: "NAS" }, - { name: "neo", src: "snmp", role: "core switch" }, + { name: "eero", src: "eero", role: "Wi-Fi mesh" }, // The UPS's tile carries what the Power card used to: mains or battery, // charge and runtime (renderNodes). { name: "mjolnir", src: "snmp", role: "UPS" }, @@ -36,8 +39,10 @@ // "backups" and "patches" are the quiet Alerts card's two lines: the // backups' proofs, and security updates and reboots waiting (renderLab). - const QUESTIONS = ["alerts", "cpu", "snmp", "wan", "wan_hour", "rtt", "ups", "pi_temp", - "backups", "patches"]; + // "speedtest" and "speedtest_at" are speedtest-tracker's last result and + // when it landed; "wan" and "wan_hour" are the traffic on the WAN port. + const QUESTIONS = ["alerts", "cpu", "snmp", "eero", "wan", "wan_hour", "speedtest", "speedtest_at", + "ups", "pi_temp", "backups", "patches"]; // Home Assistant entities, by the names the Caddyfile gives them. const DOORS = [ ["front_door", "Front"], ["garage_door", "Garage"], @@ -47,15 +52,16 @@ // "forecast" is sensor.wall_weather: today's high and low, the next rain and // the next sunrise or sunset (home-assistant/packages/wall_weather.yaml). // "thermostat" is climate.thermostat itself; "litter" is sensor.wall_litter - // (home-assistant/packages/wall_house.yaml). - const HOUSE = ["weather", "forecast", "alarm", "office_light", "thermostat", "litter", + // (home-assistant/packages/wall_house.yaml); "house_empty" is presence.yaml's + // input_boolean.house_empty, on once every tracked phone has left. + const HOUSE = ["weather", "forecast", "alarm", "house_empty", "thermostat", "litter", ...DOORS.map((d) => d[0]), ...WINDOWS.map((w) => w[0])]; // "today" is sensor.wall_today: the calendars' events for the next seven // days, gathered by home-assistant/packages/wall_calendar.yaml. // The context card's sources (wall_commute, wall_shabbat, wall_todo, // wall_trash, wall_deliveries, wall_media), each unavailable until it is // set up. - const CARDS = ["commute", "shabbat", "todo", "trash", "deliveries", "dogs", "media"]; + const CARDS = ["commute", "shabbat", "todo", "trash", "deliveries", "media"]; const HA = [...HOUSE, "today", ...CARDS]; const states = {}; // HA name -> the entity's state object const answers = {}; // name -> data.result of the last good answer @@ -345,6 +351,26 @@ } else { val.textContent = state === "down" ? "no data" : "—"; } + } else if (h.src === "eero") { + // The total is every configured target, from `up`; an access point + // counts as answering only when its probe ran and succeeded. A probe + // whose scrape failed has no probe_success at all, and still counts + // against the mesh rather than leaving the total. Some silent is a + // warning; all silent is down, as the mesh is then gone. + const rows = fresh("eero") ? answers.eero || [] : []; + const targets = new Set(rows.filter((r) => r.metric.__name__ === "up").map((r) => r.metric.instance)); + const answered = new Set(rows + .filter((r) => r.metric.__name__ === "probe_success" && num(r) === 1) + .map((r) => r.metric.instance)); + const up = [...targets].filter((t) => answered.has(t)).length; + if (!targets.size) state = "unknown"; + else if (up === 0) state = "down"; + else if (up < targets.size) state = "warning"; + if (state === "unknown") val.textContent = "—"; + else { + val.textContent = `${up}/${targets.size}`; + val.append(el("small", null, "up")); + } } else { if (!fresh("snmp")) state = "unknown"; else if (snmp.get(h.name) !== 1) state = "down"; @@ -375,16 +401,43 @@ } // ---------- internet ---------- + // The heroes are the last speed test; the line under them is the WAN port's + // traffic now. Amber below the bars internet.rules.yaml alerts on (400 down, + // 100 up, in Mbit/s), and when the newest test is older than 90 minutes, + // SpeedtestStale's mark: the tracker runs every 30. const mbps = (bits) => (bits >= 100e6 ? Math.round(bits / 1e6) : (bits / 1e6).toFixed(1)); + const SLOW = { download: 400e6, upload: 100e6 }; + const TEST_STALE_S = 90 * 60; function renderWan() { + const st = fresh("speedtest") ? answers.speedtest || [] : []; + const metric = (n) => st.find((r) => r.metric.__name__ === `speedtest_tracker_${n}`); + const failed = st.some((r) => r.metric.status && r.metric.status !== "completed"); + const at = fresh("speedtest_at") ? num((answers.speedtest_at || [])[0]) : NaN; + const age = Number.isFinite(at) ? Date.now() / 1000 - at : NaN; + const old = !(age <= TEST_STALE_S); + const hero = (id, r, slow) => { + const e = $(id); + e.classList.toggle("warn", Boolean(r) && !failed && (old || (slow !== undefined && num(r) < slow))); + if (!r || failed) e.textContent = "—"; + else e.textContent = slow !== undefined ? mbps(num(r)) : Math.round(num(r)); + }; + hero("st-down", metric("download_bits"), SLOW.download); + hero("st-up", metric("upload_bits"), SLOW.upload); + hero("st-ping", metric("ping_ms")); + const wan = answers.wan || []; const dir = (d) => wan.find((r) => r.metric.direction === d); const down = dir("receive"); const up = dir("transmit"); - $("wan-down").textContent = fresh("wan") && down ? mbps(num(down)) : "—"; - $("wan-up").textContent = fresh("wan") && up ? mbps(num(up)) : "—"; - const rtt = (answers.rtt || [])[0]; - $("wan-rtt").textContent = fresh("rtt") && rtt ? Math.round(num(rtt) * 1000) : "—"; + const nowLine = $("wan-now"); + nowLine.replaceChildren(); + const said = !fresh("speedtest") ? "no speed test answer" + : failed ? "last test failed" + : Number.isFinite(age) ? `tested ${ago(Math.max(60, age))} ago` : "no test in 3 h"; + nowLine.append(el("span", !fresh("speedtest") || failed || old ? "warn" : null, said)); + if (fresh("wan") && down && up) { + nowLine.append(el("span", "sep", " · "), document.createTextNode(`now ${mbps(num(down))} down, ${mbps(num(up))} up`)); + } const svg = $("wan-spark"); svg.replaceChildren(); @@ -404,18 +457,21 @@ svg.append(fill, line); } - // ---------- status bar: how old each answer is ---------- + // ---------- status bar: only the sources that have fallen behind ---------- + // Each group is a set of answers; a group whose oldest answer is past + // STALE_MS is named, amber, with its age, and red past three times that or + // when it never answered. With every group live, one quiet line says so. function age(ms) { const s = Math.round(ms / 1000); - return s < 90 ? `${s}s` : `${Math.round(s / 60)}m`; + return s < 90 ? `${s}s` : `${Math.round(s / 60)} min`; } function renderStatus() { const bar = $("status"); bar.replaceChildren(); const groups = [ ["alerts", ["alerts"]], - ["hosts", ["cpu", "snmp"]], - ["internet", ["wan", "wan_hour", "rtt"]], + ["hosts", ["cpu", "snmp", "eero"]], + ["internet", ["speedtest", "speedtest_at", "wan", "wan_hour"]], ["power", ["ups"]], ["house", HOUSE.map((n) => `ha:${n}`)], ["calendar", ["ha:today"]], @@ -433,15 +489,16 @@ span.textContent = "calendar · unavailable"; } else if (!oldest) { span.classList.add("dead"); - span.textContent = `${label} · never`; + span.textContent = `${label} · no answer yet`; } else { const ms = Date.now() - oldest; - if (ms >= 3 * STALE_MS) span.classList.add("dead"); - else if (ms >= STALE_MS) span.classList.add("stale"); - span.textContent = `${label} · ${age(ms)}`; + if (ms < STALE_MS) continue; + span.classList.add(ms >= 3 * STALE_MS ? "dead" : "stale"); + span.textContent = `${label} · ${age(ms)} old`; } bar.append(span); } + if (!bar.childElementCount) bar.append(el("span", "src", "all sources live")); const t = (answers.pi_temp || [])[0]; bar.append(el("span", "push", `heimdall · ${fresh("pi_temp") && t ? `${num(t).toFixed(0)}°C` : "—"}`)); } @@ -526,7 +583,11 @@ if (!items.length) break; items.sort((a, b) => Number(b.dataset.drop) - Number(a.dataset.drop))[0].remove(); } - for (const item of row.querySelectorAll("[data-compact]")) { + // Quiet items shorten before warnings, so what is open stays named for + // as long as the row allows. + const compactable = [...row.querySelectorAll("[data-compact]")] + .sort((a, b) => a.classList.contains("warn") - b.classList.contains("warn")); + for (const item of compactable) { if (!over()) return; item.querySelector("b").textContent = item.dataset.compact; } @@ -551,6 +612,13 @@ row.append(homeItem("Alarm", "—", "unknown")); } + // Only while presence.yaml has marked the house empty. Off, or + // unreadable, it says nothing: the alarm's mode is the item that must + // never be missing, and it is already there. + if (haFresh("house_empty") && states.house_empty.state === "on") { + row.append(homeItem("House", "empty")); + } + // Doors and windows share one item: all shut is one fact, and the row // needs the room. What is open is named, a window as "Left window". const doors = openOf(DOORS); @@ -561,33 +629,44 @@ else row.append(homeItem("Doors & windows", "closed")); // The hallway thermostat. Its own alerts are thermostat.yaml's; this is - // the reading, with what it is doing when it is doing something. + // the reading, then what it is set to: "68° · 45% · heat to 70", or a + // range in heat_cool, and "away" while presence.yaml holds it there. A + // crowded row falls back to the reading and the target alone. if (haFresh("thermostat")) { const t = states.thermostat.attributes || {}; + const mode = states.thermostat.state; + const deg = (v) => `${Math.round(Number(v))}°`; const bits = []; - if (t.current_temperature != null) bits.push(`${Math.round(t.current_temperature)}°`); + if (t.current_temperature != null) bits.push(deg(t.current_temperature)); if (t.current_humidity != null) bits.push(`${Math.round(t.current_humidity)}%`); - if (t.hvac_action === "heating" || t.hvac_action === "cooling") bits.push(t.hvac_action); - row.append(homeItem("Inside", bits.length ? bits.join(" · ") : "—", bits.length ? "" : "unknown", 2)); - } else { - row.append(homeItem("Inside", "—", "unknown", 2)); - } - - if (haFresh("office_light")) { - row.append(homeItem("Office lights", states.office_light.state === "on" ? "on" : "off", "", 3)); + let target = ""; + if (mode === "heat_cool" && t.target_temp_low != null && t.target_temp_high != null) { + target = `${deg(t.target_temp_low)}–${deg(t.target_temp_high)}`; + } else if ((mode === "heat" || mode === "cool") && t.temperature != null) { + target = deg(t.temperature); + } + const doing = t.hvac_action === "heating" ? "heating to" : t.hvac_action === "cooling" ? "cooling to" + : mode === "heat" ? "heat to" : mode === "cool" ? "cool to" : "set"; + if (mode === "off") bits.push("off"); + else if (target) bits.push(`${doing} ${target}`); + if (t.preset_mode === "away") bits.push("away"); + const compact = [bits[0], target && mode !== "off" ? `→ ${target}` : ""].filter(Boolean).join(" "); + row.append(homeItem("Inside", bits.length ? bits.join(" · ") : "—", bits.length ? "" : "unknown", + 0, bits.length > 1 ? compact : undefined)); } else { - row.append(homeItem("Office lights", "—", "unknown", 3)); + row.append(homeItem("Inside", "—", "unknown")); } - // The Litter-Robot when it wants something, in amber, and as "—" when it - // cannot be read, so an outage never looks like all is well. Quiet when - // it is fine. The "—" is the last quiet item a crowded row drops. + // The Litter-Robot, always: "ok", what it wants in amber, or "—" when it + // cannot be read, so an outage never looks like all is well. if (!haFresh("litter")) { - row.append(homeItem("Litter-Robot", "—", "unknown", 1)); + row.append(homeItem("Litter-Robot", "—", "unknown")); } else if (states.litter.state === "attention") { const needs = (states.litter.attributes || {}).needs || []; row.append(homeItem("Litter-Robot", needs.length ? needs.join(", ") : "needs a look", "warn", 0, needs.length > 1 ? `${needs.length} things` : undefined)); + } else { + row.append(homeItem("Litter-Robot", "ok")); } fitRow(row); } @@ -695,7 +774,7 @@ // others that are also true are named on its last line, so nothing that // matters is hidden without a word. The last entry always applies, so the // card is never empty. Later cards (commute, Shabbat, trash, deliveries, - // dogs, now playing) slot in above it as their sources arrive. + // now playing) slot in above it as their sources arrive. const MIN = 60_000; const attrs = (name) => (haFresh(name) && states[name].attributes) || {}; const until = (t) => { @@ -785,26 +864,6 @@ if (Number(a.in_transit) > 0) sub(box, `${a.in_transit} on the way`); } - // Dogs: while a walk or a feeding is overdue. A threshold of 0 is not - // tracked; one never recorded counts as overdue, so a new setup shows. - function dogsDue() { - const a = attrs("dogs"); - return [["Walked", "walk", a.walked, Number(a.walk_hours) || 0], ["Fed", "feed", a.fed, Number(a.feed_hours) || 0]] - .filter(([, , , hours]) => hours > 0) - .map(([label, verb, at, hours]) => { - const t = at ? new Date(at) : null; - const age = t && !isNaN(t) ? (Date.now() - t) / 1000 : null; - return { label, verb, age, due: age === null || age > hours * 3600 }; - }); - } - function dogsLive() { return haFresh("dogs") && dogsDue().some((d) => d.due); } - function renderDogs(box) { - const all = dogsDue(); - const due = all.filter((d) => d.due).map((d) => d.verb); - hero(box, `${due.join(" and ")} the dogs`.replace(/^./, (c) => c.toUpperCase()), "warn"); - for (const d of all) sub(box, d.age === null ? `${d.label}: not recorded yet` : `${d.label} ${ago(d.age)} ago`); - } - // The to-do list, the default when it has anything on it. function todoLive() { return haFresh("todo") && Number(states.todo.state) > 0; } function renderTodo(box) { @@ -835,7 +894,6 @@ short: "shabbat", when: shabbatLive, render: renderShabbat }, { title: "Trash", short: "trash", when: trashLive, render: renderTrash }, { title: "Packages", short: "packages", when: deliveriesLive, render: renderDeliveries }, - { title: "Dogs", short: "dogs", when: dogsLive, render: renderDogs }, { title: "To-do", short: "to-do", when: todoLive, render: renderTodo }, { title: "Now playing", short: "playing", when: mediaLive, render: renderMedia }, { title: "Word of the day", short: "word", when: () => true, render: renderWord },