diff --git a/docs/architecture.md b/docs/architecture.md index 4859c4af..e67b7d31 100644 --- a/docs/architecture.md +++ b/docs/architecture.md @@ -207,7 +207,7 @@ hole from the monitoring VLAN into the monitored one. | `phoenix` (10.0.30.70) | ๐ŸŸข 30 | *(none โ€” a toolchain host, no Docker)* | The deployment host, built 2026-09-20: a Proxmox API token, an SSH key and a checkout, so that the Packer, OpenTofu and Ansible work after [#436](https://github.com/Gerrrt/HomeLab/issues/436) has somewhere to run from. A guest on `Saruman`, placed by [ADR-0043](adr/0043-keep-the-ca-on-prometheus-and-build-phoenix-as-the-deployment-host.md), which also decides that the estate's CA key stays on `prometheus` and does not follow the toolchain here. It holds no age key and runs no continuous convergence (what it configures, it configures on demand, below); it is the WireGuard endpoint of [ADR-0042](adr/0042-terminate-the-remote-path-on-the-lab-and-route-it.md), built 2026-09-22 ([#442](https://github.com/Gerrrt/HomeLab/issues/442)); the one thing it is meant to reach that no other guest does is `8006` on `Saruman`, by a single host-firewall rule โ€” written 2026-09-20, when [#566](https://github.com/Gerrrt/HomeLab/issues/566) enabled the firewall the build had found disabled and narrowed the `local_network` alias that was admitting the whole segment underneath it. Its Alloy pushes to `alexander`, never to VLAN 99; the build is [`build-the-jumpbox.md`](runbooks/build-the-jumpbox.md). The first toolchain on it is [`packer/`](../packer/README.md), the lab's VM templates at VMIDs 901โ€“912, with 903โ€“909 for the dotfiles OS layers ([ADR-0090](adr/0090-test-the-dotfiles-os-layers-on-on-demand-saruman-guests.md)) ([ADR-0074](adr/0074-build-the-lab-templates-with-packer-from-phoenix.md), [`build-the-lab-templates.md`](runbooks/build-the-lab-templates.md)). The second is [`ansible/`](../ansible/README.md), which configures ADR-0029's six over SSH and touches nothing else ([ADR-0077](adr/0077-configure-the-lab-domain-with-ansible-from-phoenix.md), [#448](https://github.com/Gerrrt/HomeLab/issues/448)). Its own way in is decided by [ADR-0117](adr/0117-give-phoenix-a-key-only-sshd-and-a-default-deny-inbound-policy.md): `sshd` takes keys only, and `ufw` admits `22` from Hicks and the tunnel's peers, the tunnel's port, and `8800` from VLAN 30 for the length of a Debian or Kali template build. Applying it on the host is [#1496](https://github.com/Gerrrt/HomeLab/issues/1496). Alloy agent (native package, `scripts/deploy-agent.sh`) | | `golem` (10.0.30.80) | ๐ŸŸข 30 | *(none โ€” an appliance, no Docker)* | Proxmox Backup Server 4.2, built 2026-10-03 by [`build-the-backup-guest.md`](runbooks/build-the-backup-guest.md) ([#485](https://github.com/Gerrrt/HomeLab/issues/485)): the lab's backups, placed by [ADR-0053](adr/0053-run-pbs-on-saruman-with-its-datastore-on-smaug-over-nfs.md). A guest on `Saruman`, VMID 180, whose only datastore, `erebor`, is `smaug`'s `erebor/pbs` over NFSv4 through one `2049` pass, with `atime` on because garbage collection depends on it, and the mountpoint made immutable so an unmounted share cannot fill the OS disk. Every backup is encrypted on `Saruman` before it leaves, with a key made on `Saruman` and copied, on 2026-10-03, into `secrets/lab.sops.yaml` and onto paper (the runbook's ยง7), so a lost `Saruman` does not take the backups' readability with it; `Saruman` writes through a token that can back up and cannot prune. PBS prunes (7 daily, 4 weekly, 3 monthly), collects garbage on Saturdays and verifies on Sundays; TrueNAS keeps fourteen daily snapshots of the dataset as the copy PBS cannot prune. The nightly job takes `odin`, `garuda` and the domain's six, the guests tagged `backup`; `alexander`, `phoenix`, `fenrir` and `golem` itself are rebuilt from this repository and stay out, and so does `eden`, whose graph is one collection run from rebuilt (the runbook's ยง8). `scripts/collect-pbs-task-state.py` publishes every job's last outcome and the snapshots' verify state hourly, and seven rules in `stacks/lab` read them; the first nightly run, 2026-10-03, was verified the next morning. Its Alloy pushes to `alexander`, never to VLAN 99, since 2026-10-03. Alloy agent (native package, `scripts/deploy-agent.sh`) | | `oracle` (10.0.99.30) | ๐Ÿ”ด 99 | [`stacks/wiki`](../stacks/wiki) | The Lemmiwinks wiki and its Postgres, since 2025-11-12 ([ADR-0011](adr/0011-keep-the-wiki-internal.md)), hand-run containers until [#251](https://github.com/Gerrrt/HomeLab/issues/251) wrote them down as a stack deployed by hand from `main`, like `smaug`'s. **Cut over 2026-10-07** ([#847](https://github.com/Gerrrt/HomeLab/issues/847), [ADR-0082](adr/0082-serve-the-wiki-over-tls-and-deploy-it-from-a-verified-checkout.md)): deployed by hand from a checkout whose signature is verified first, and served over https from a Caddy on a leaf from the estate's CA, with port 80 only redirecting ([`stacks/wiki/README.md`](../stacks/wiki/README.md#tls)); its database is pulled to `prometheus` nightly as a `pg_dump` (`make backup-wiki`, [ADR-0065](adr/0065-pull-the-wikis-database-to-prometheus-as-a-dump.md)); Alloy agent (Docker, `scripts/deploy-agent.sh`); the off-host copies of the firewall export (`make backup-firewall`), of the weekly volume sets (`make backup`, [#535](https://github.com/Gerrrt/HomeLab/issues/535)) of the media tier's state pulled off `smaug` (`make backup-nas`, [ADR-0045](adr/0045-pull-jellyfins-state-from-a-snapshot-over-ssh.md)), and of `trinity`'s nightly sensitive-tier volume sets and Immich's library ([ADR-0064](adr/0064-copy-immichs-library-to-oracle-until-the-off-estate-copy-exists.md)). The estate's host for small off-host jobs โ€” [ADR-0015](adr/0015-give-oracle-the-off-host-jobs.md) | -| `trinity` (10.0.99.40) | ๐Ÿ”ด 99 | [`stacks/sensitive`](../stacks/sensitive) | ADR-0008's sensitive tier on the ProDesk 600 G4 of [ADR-0034](adr/0034-run-the-sensitive-tier-on-the-prodesk-and-make-it-the-spare-hardware.md). **Built and deployed 2026-09-28** ([#404](https://github.com/Gerrrt/HomeLab/issues/404), [`build-the-sensitive-tier-host.md`](runbooks/build-the-sensitive-tier-host.md)): Ubuntu 26.04 with both disks LUKS-encrypted and the root unlocked by the TPM ([ADR-0054](adr/0054-encrypt-trinitys-disks-and-seal-the-root-key-to-the-tpm.md)), all twelve containers healthy, and since that day AdGuard is the one forwarder behind `morpheus`'s resolver ([ADR-0055](adr/0055-forward-to-adguard-alone.md)). Holding real data since 2026-09-28, Immich's first 615 photographs, which passed the #404 step 10 gate while most of it was open. The library is copied nightly to `oracle`, off-host and not off-estate, until [#455](https://github.com/Gerrrt/HomeLab/issues/455) ([ADR-0064](adr/0064-copy-immichs-library-to-oracle-until-the-off-estate-copy-exists.md)). The stack: Caddy as the published HTTPS port and step-ca issuing beneath the tier's own root rather than the estate's, which is left untouched ([#129](https://github.com/Gerrrt/HomeLab/issues/129), [#130](https://github.com/Gerrrt/HomeLab/issues/130), [ADR-0037](adr/0037-give-the-sensitive-tier-its-own-root-and-issue-beneath-it-over-acme.md)), with AdGuard Home behind Caddy and publishing 53 to the firewall's forwarder alone ([#135](https://github.com/Gerrrt/HomeLab/issues/135), [ADR-0010](adr/0010-keep-the-resolver-on-the-gateway.md)); Home Assistant ([#134](https://github.com/Gerrrt/HomeLab/issues/134)), Immich โ€” four containers behind Caddy with a memory limit on each ([#132](https://github.com/Gerrrt/HomeLab/issues/132)) โ€” Paperless-ngx with a Postgres and a Valkey of its own ([#133](https://github.com/Gerrrt/HomeLab/issues/133)) and Vaultwarden ([#131](https://github.com/Gerrrt/HomeLab/issues/131)) run beside them, with the household's page of links to them at `home.matrix.elysium` and its live numbers on read-only tokens ([#137](https://github.com/Gerrrt/HomeLab/issues/137)) โ€” Homepage until [ADR-0103](adr/0103-retire-homepage-and-serve-the-household-page-from-glance.md) made it a page of Glance's. ntfy ([#136](https://github.com/Gerrrt/HomeLab/issues/136)) is the in-house receiver for Alertmanager's three real channels, **deployed and cut over 2026-09-29** by [`verify-the-alert-path.md`](runbooks/verify-the-alert-path.md#cutting-over-to-the-in-house-ntfy), with `urgent` and `security` also sent to ntfy.sh for a phone away from home. Miniflux, a feed reader with a Postgres of its own, is the tier's first service beyond ADR-0008's nine, **deployed 2026-09-29** ([#147](https://github.com/Gerrrt/HomeLab/issues/147), [ADR-0057](adr/0057-add-miniflux-to-the-sensitive-tier-with-its-fetcher-kept-off-winterfell.md)): the one container here that reaches outward on a timer, with its fetcher refused every private address. Memos, the household's notes, is the second, decided by [ADR-0059](adr/0059-add-memos-to-the-sensitive-tier-for-notes-and-keep-documentation-in-docs.md) ([#145](https://github.com/Gerrrt/HomeLab/issues/145)) and deployed behind Caddy the same day, all sixteen containers healthy after that `make up`. Miniflux holds no real data; Memos holds the household's first real notes since 2026-10-22, ahead of ADR-0023's off-estate copy by the operator's accepted exception, with the nightly volume set on `oracle` its only copy off the host, since the household copy under [#455](https://github.com/Gerrrt/HomeLab/issues/455) does not carry `memos-data` yet. Mealie, the household's recipes at `recipes.matrix.elysium`, is the third, **deployed 2026-09-29** ([#146](https://github.com/Gerrrt/HomeLab/issues/146), [ADR-0060](adr/0060-add-mealie-to-the-sensitive-tier-as-recipes.md)), behind the same Caddy with no new rule, its URL import refused every private address. linkding, a bookmark manager, is the fourth, **deployed 2026-09-29** ([#144](https://github.com/Gerrrt/HomeLab/issues/144), [ADR-0061](adr/0061-add-linkding-to-the-sensitive-tier-behind-one-factor.md)). Actual ([#142](https://github.com/Gerrrt/HomeLab/issues/142)), the household's budget, is the fifth beyond ADR-0008's nine, **deployed 2026-09-29** ([ADR-0062](adr/0062-add-actual-to-the-sensitive-tier.md)), claimed from SOPS before its first start. It holds no real budget before #404 step 10. Stirling-PDF, the household's PDF editor at `pdf.matrix.elysium`, is the sixth, **deployed 2026-09-29** ([#143](https://github.com/Gerrrt/HomeLab/issues/143), [ADR-0063](adr/0063-add-stirling-pdf-to-the-sensitive-tier-and-keep-its-documents-in-memory.md)): its documents live on a tmpfs and never reach a disk. Glance, the operator's browser start page at `start.matrix.elysium`, is **deployed 2026-10-21** ([#1223](https://github.com/Gerrrt/HomeLab/issues/1223), [ADR-0098](adr/0098-add-glance-as-the-operators-start-page-beside-homepage.md)): the estate's alerts, probes and targets read from `prometheus` with the reader token, and feeds read from a Miniflux user of its own. Since [ADR-0100](adr/0100-grow-glance-into-a-homelab-page-and-keep-the-operators-lists-in-sops.md) it has a page per subject โ€” Home, Read, Watch, Sports & Markets, Homelab, Network & Storage and Maintenance โ€” the estate's read from `prometheus`, and the operator's own lists come from SOPS. It also serves the household's page at `home.matrix.elysium` ([ADR-0103](adr/0103-retire-homepage-and-serve-the-household-page-from-glance.md)), which took over from Homepage. The office wall page, static files under `wall/` that Caddy serves at `wall.matrix.elysium` with eight fixed Prometheus questions behind it, is **deployed 2026-11-17** for `heimdall`'s kiosk ([ADR-0119](adr/0119-put-the-office-wall-dashboard-on-a-pi-5-on-hicks.md)), with its host override on `morpheus` and a blackbox probe, `wall`. Mosquitto and ring-mqtt bring the Ring Alarm into Home Assistant, the broker on an internal network that only those two join, **deployed 2026-10-22** ([ADR-0104](adr/0104-bring-the-ring-alarm-into-home-assistant-through-ring-mqtt.md)). Alloy agent (Docker, `scripts/deploy-agent.sh`), pushing to `prometheus` like `oracle`'s | +| `trinity` (10.0.99.40) | ๐Ÿ”ด 99 | [`stacks/sensitive`](../stacks/sensitive) | ADR-0008's sensitive tier on the ProDesk 600 G4 of [ADR-0034](adr/0034-run-the-sensitive-tier-on-the-prodesk-and-make-it-the-spare-hardware.md). **Built and deployed 2026-09-28** ([#404](https://github.com/Gerrrt/HomeLab/issues/404), [`build-the-sensitive-tier-host.md`](runbooks/build-the-sensitive-tier-host.md)): Ubuntu 26.04 with both disks LUKS-encrypted and the root unlocked by the TPM ([ADR-0054](adr/0054-encrypt-trinitys-disks-and-seal-the-root-key-to-the-tpm.md)), all twelve containers healthy, and since that day AdGuard is the one forwarder behind `morpheus`'s resolver ([ADR-0055](adr/0055-forward-to-adguard-alone.md)). Holding real data since 2026-09-28, Immich's first 615 photographs, which passed the #404 step 10 gate while most of it was open. The library is copied nightly to `oracle`, off-host and not off-estate, until [#455](https://github.com/Gerrrt/HomeLab/issues/455) ([ADR-0064](adr/0064-copy-immichs-library-to-oracle-until-the-off-estate-copy-exists.md)). The stack: Caddy as the published HTTPS port and step-ca issuing beneath the tier's own root rather than the estate's, which is left untouched ([#129](https://github.com/Gerrrt/HomeLab/issues/129), [#130](https://github.com/Gerrrt/HomeLab/issues/130), [ADR-0037](adr/0037-give-the-sensitive-tier-its-own-root-and-issue-beneath-it-over-acme.md)), with AdGuard Home behind Caddy and publishing 53 to the firewall's forwarder alone ([#135](https://github.com/Gerrrt/HomeLab/issues/135), [ADR-0010](adr/0010-keep-the-resolver-on-the-gateway.md)); Home Assistant ([#134](https://github.com/Gerrrt/HomeLab/issues/134)), Immich โ€” four containers behind Caddy with a memory limit on each ([#132](https://github.com/Gerrrt/HomeLab/issues/132)) โ€” Paperless-ngx with a Postgres and a Valkey of its own ([#133](https://github.com/Gerrrt/HomeLab/issues/133)) and Vaultwarden ([#131](https://github.com/Gerrrt/HomeLab/issues/131)) run beside them, with the household's page of links to them at `home.matrix.elysium` and its live numbers on read-only tokens ([#137](https://github.com/Gerrrt/HomeLab/issues/137)) โ€” Homepage until [ADR-0103](adr/0103-retire-homepage-and-serve-the-household-page-from-glance.md) made it a page of Glance's. ntfy ([#136](https://github.com/Gerrrt/HomeLab/issues/136)) is the in-house receiver for Alertmanager's three real channels, **deployed and cut over 2026-09-29** by [`verify-the-alert-path.md`](runbooks/verify-the-alert-path.md#cutting-over-to-the-in-house-ntfy), with `urgent` and `security` also sent to ntfy.sh for a phone away from home. Miniflux, a feed reader with a Postgres of its own, is the tier's first service beyond ADR-0008's nine, **deployed 2026-09-29** ([#147](https://github.com/Gerrrt/HomeLab/issues/147), [ADR-0057](adr/0057-add-miniflux-to-the-sensitive-tier-with-its-fetcher-kept-off-winterfell.md)): the one container here that reaches outward on a timer, with its fetcher refused every private address. Memos, the household's notes, is the second, decided by [ADR-0059](adr/0059-add-memos-to-the-sensitive-tier-for-notes-and-keep-documentation-in-docs.md) ([#145](https://github.com/Gerrrt/HomeLab/issues/145)) and deployed behind Caddy the same day, all sixteen containers healthy after that `make up`. Miniflux holds no real data; Memos holds the household's first real notes since 2026-10-22, ahead of ADR-0023's off-estate copy by the operator's accepted exception, with the nightly volume set on `oracle` its only copy off the host, since the household copy under [#455](https://github.com/Gerrrt/HomeLab/issues/455) does not carry `memos-data` yet. Mealie, the household's recipes at `recipes.matrix.elysium`, is the third, **deployed 2026-09-29** ([#146](https://github.com/Gerrrt/HomeLab/issues/146), [ADR-0060](adr/0060-add-mealie-to-the-sensitive-tier-as-recipes.md)), behind the same Caddy with no new rule, its URL import refused every private address. linkding, a bookmark manager, is the fourth, **deployed 2026-09-29** ([#144](https://github.com/Gerrrt/HomeLab/issues/144), [ADR-0061](adr/0061-add-linkding-to-the-sensitive-tier-behind-one-factor.md)). Actual ([#142](https://github.com/Gerrrt/HomeLab/issues/142)), the household's budget, is the fifth beyond ADR-0008's nine, **deployed 2026-09-29** ([ADR-0062](adr/0062-add-actual-to-the-sensitive-tier.md)), claimed from SOPS before its first start. It holds no real budget before #404 step 10. Stirling-PDF, the household's PDF editor at `pdf.matrix.elysium`, is the sixth, **deployed 2026-09-29** ([#143](https://github.com/Gerrrt/HomeLab/issues/143), [ADR-0063](adr/0063-add-stirling-pdf-to-the-sensitive-tier-and-keep-its-documents-in-memory.md)): its documents live on a tmpfs and never reach a disk. Glance, the operator's browser start page at `start.matrix.elysium`, is **deployed 2026-10-21** ([#1223](https://github.com/Gerrrt/HomeLab/issues/1223), [ADR-0098](adr/0098-add-glance-as-the-operators-start-page-beside-homepage.md)): the estate's alerts, probes and targets read from `prometheus` with the reader token, and feeds read from a Miniflux user of its own. Since [ADR-0100](adr/0100-grow-glance-into-a-homelab-page-and-keep-the-operators-lists-in-sops.md) it has a page per subject โ€” Home, Read, Watch, Sports & Markets, Homelab, Network & Storage and Maintenance โ€” the estate's read from `prometheus`, and the operator's own lists come from SOPS. It also serves the household's page at `home.matrix.elysium` ([ADR-0103](adr/0103-retire-homepage-and-serve-the-household-page-from-glance.md)), which took over from Homepage. The office wall page, static files under `wall/` that Caddy serves at `wall.matrix.elysium` with eight fixed Prometheus questions and ten Home Assistant entities behind it (one of them the calendar, gathered by a package), is **deployed 2026-11-17** for `heimdall`'s kiosk ([ADR-0119](adr/0119-put-the-office-wall-dashboard-on-a-pi-5-on-hicks.md)), with its host override on `morpheus` and a blackbox probe, `wall`. Mosquitto and ring-mqtt bring the Ring Alarm into Home Assistant, the broker on an internal network that only those two join, **deployed 2026-10-22** ([ADR-0104](adr/0104-bring-the-ring-alarm-into-home-assistant-through-ring-mqtt.md)). Alloy agent (Docker, `scripts/deploy-agent.sh`), pushing to `prometheus` like `oracle`'s | | `smaug` (10.0.40.30) | ๐ŸŸก 40 | [`stacks/media`](../stacks/media) | [ADR-0008](adr/0008-place-services-by-data-trust.md)'s media tier on the ThinkServer TS150 of [#413](https://github.com/Gerrrt/HomeLab/issues/413), placed and addressed by [ADR-0016](adr/0016-open-casabonita-inward-and-keep-it-terminal-outward.md) and running TrueNAS rather than Ubuntu Server by [ADR-0040](adr/0040-run-truenas-on-smaug-and-keep-the-media-stack-in-this-repository.md). **Built, pooled and deployed**: TrueNAS on its boot SSD, the static above since 2026-09-16, its inbound rules verified in position (four that day; [`network.md`](network.md#casabonita--vlan-40--media) counts them now), the mirror `erebor` since 2026-09-18 and this stack running on it since 2026-09-19 โ€” from a copy of the compose file on the pool, brought up with `docker compose` under TrueNAS's own Docker ([`build-the-nas.md`](runbooks/build-the-nas.md) ยง6). Jellyfin, publishing 8096 to the segment because the televisions reach it natively and no firewall rule is involved at all ([#138](https://github.com/Gerrrt/HomeLab/issues/138)); and Audiobookshelf on 13378, **deployed 2026-09-29**, whose clients are phones on Hicks and which therefore brought a fifth inbound rule by ADR-0050's count, the seventh to exist ([#140](https://github.com/Gerrrt/HomeLab/issues/140), [ADR-0050](adr/0050-add-audiobookshelf-to-the-media-tier-behind-a-fifth-hicks-pass.md)). And Navidrome on 4533 for music, **deployed 2026-09-30** on the same terms, whose Hicks pass was created 2026-09-22, ahead of the service and of Audiobookshelf's ([#141](https://github.com/Gerrrt/HomeLab/issues/141)). The `media` share gets a Hicks pass on `445` for workstations, used by a second SMB user, `samwise`, so the televisions' `bilbo` stays theirs; it was **created on 2026-09-23** ([#523](https://github.com/Gerrrt/HomeLab/issues/523), [ADR-0051](adr/0051-let-hicks-workstations-mount-the-media-share-as-a-user-of-their-own.md)). Scraped by `prometheus` on `9100`; it pushes nothing, and runs no Alloy โ€” the estate's first scraped host, and the reason [#256](https://github.com/Gerrrt/HomeLab/issues/256) was more than a line of YAML. That issue settled the fork TrueNAS opened in it: `node_exporter`, as a digest-pinned container in this stack rather than TrueNAS's own endpoint, so the existing `99 โ†’ 40:9100` pass, the `host-overview` dashboard and seven rules in `host.rules.yaml` all keep working unchanged. MakeMKV, the disc ripper, is in the file behind the compose profile `rip` and is **not yet deployed**: it reads this host's DVD-RW and writes only into `erebor/media/rips`, runs only while someone is ripping, and is reached from Hicks on `5800` through a pass ยง6.11 creates ([ADR-0114](adr/0114-rip-discs-on-smaug-with-makemkv-started-only-to-rip.md)). The `node` job and `prometheus/targets/node.yaml` are live, and the target with them since 2026-09-19, once the exporter answered from the pool. SMART reaches the same scrape by [ADR-0047](adr/0047-collect-smaug-smart-through-a-root-cron-and-the-textfile-collector.md): a root cron job in TrueNAS's UI runs the estate's collector and the exporter serves the file โ€” still no agent, still nothing initiating from 40 โ€” and patch state is deliberately not collected on an appliance ([#483](https://github.com/Gerrrt/HomeLab/issues/483)) | | `bahamut` (10.0.30.50) | ๐ŸŸข 30 | *(none โ€” Windows)* | Windows Server 2025 domain controller, PDC emulator and DNS for `ad.matrix.elysium` โ€” Tier 0. Static, because every member finds a DC through DNS and the DCs *are* the DNS. Built by hand 2026-09-24 to 2026-09-25 ([#414](https://github.com/Gerrrt/HomeLab/issues/414)) and promoted for `ad.matrix.elysium`. Scraped by `alexander` on `9182`; it pushes nothing, and runs no Alloy ([ADR-0029](adr/0029-size-the-lab-domain-and-separate-its-namespace-and-clock.md)) | | `leviathan` (10.0.30.51) | ๐ŸŸข 30 | *(none โ€” Windows)* | Windows Server 2025 second domain controller and DNS โ€” Tier 0. Static, for the same reason. Built by hand 2026-09-24 to 2026-09-25 ([#414](https://github.com/Gerrrt/HomeLab/issues/414)) and promoted for `ad.matrix.elysium`. Scraped by `alexander` on `9182`; it pushes nothing, and runs no Alloy ([ADR-0029](adr/0029-size-the-lab-domain-and-separate-its-namespace-and-clock.md)) | diff --git a/docs/changelog.md b/docs/changelog.md index d824957c..d42394c6 100644 --- a/docs/changelog.md +++ b/docs/changelog.md @@ -19,6 +19,51 @@ docstring gives: it is a record, not a claim about now. ## 2026-11-18 +- **The wall page reads the house and the family calendar from Home + Assistant.** Its header now shows the weather; a Today panel under the + alerts lists today's and tomorrow's events; and its bottom row reads the + Ring Alarm's mode, the four door contacts, the two window contacts and the + office lights. + - **How it reads them:** ten fixed `/api/ha/NAME` handles in the + Caddyfile, each one `GET /api/states/`, with the token of HA's + new non-admin `wall` user (`WALL_HA_TOKEN`, added by #1563). + - **The calendar** is Google Calendar, added to HA through its own + integration. A new package, `wall_calendar.yaml`, gathers today's and + tomorrow's events into `sensor.wall_today` every five minutes. It reads + the calendars labelled `wall_calendar`, or all of them when none is, so no + calendar is named in the repository. Booted on Home Assistant 2026.11.1 + with its demo calendars: the sensor held both events, and with no + calendar it read unavailable. + - **Read-only by narrowing.** HA has no read-only role, so the narrowing + in Caddy is the read-only part. `security.md` names the residual, which + now includes the two-day schedule. + - **No renames.** The alarm's and the office lights' own ids name the city + and a person, so a second package, `wall_house.yaml`, finds them (the + one alarm panel; any light whose id contains `office`) and the Caddyfile + names only its two template entities. + +- **`heimdall` drives the office television at 1080p, and the television + stays on.** This completes the 2026-11-17 `heimdall` entry, which said + the HDMI output, the kiosk and CEC were not yet verified. + - **First light:** HDMI-A-1 `connected`, the wall page full-screen, the + Pi at 49.9 ยฐC with `throttled=0x0`. + - **The mode came up at 1280 ร— 720.** The Changhong's EDID is a generic + one ("DMTF", `CHHWJT*`, serial 1) that prefers 720p and also lists + 1080p. The `video=` boot line sets only the console; labwc takes its + mode from `kanshi`, whose config was empty. A one-output profile now + sets 1920 ร— 1080 at 60 Hz. It is sharp, nothing is cut off, and it + survived a reboot (`build-heimdall.md` ยง5). + - **The set has no HDMI-CEC.** Its manual never mentions it, and the + Pi's probe allocated no logical address and found no topology. So + neither path in ADR-0119 decision 5 works on this television: + - CEC cannot reach it. + - Turning the Pi's output off would leave it in standby, because the + set switches itself off without a signal and nothing could wake it. + + It stays on day and night, which needs its Auto Sleep and Sleep timers Off. + A smart plug or an infrared LED would be a purchase and an ADR of its + own (`build-heimdall.md` ยง8). + - **`eden` no longer asks for an address while it boots, and template `901` stops making guests that do.** `eden` was off when "Every 26.04 lab guest asked the lab's DHCP server for an address while it booted", below, was diff --git a/docs/hardware.md b/docs/hardware.md index 114122dc..97c04dd8 100644 --- a/docs/hardware.md +++ b/docs/hardware.md @@ -343,7 +343,7 @@ The office's dashboard, outside the rack | Part | What | Notes | | --- | --- | --- | -| Screen | Changhong 40" 1080p LED television (2014) | On a SANUS single-stud tilt mount on the office's front wall, above the desk's monitors, since 2026-10-31. About seven feet from the chair | +| Screen | Changhong 40" 1080p LED television (2014) | On a SANUS single-stud tilt mount on the office's front wall, above the desk's monitors, since 2026-10-31. About seven feet from the chair. Driven at 1920 ร— 1080 by a `kanshi` profile, because its generic EDID prefers 1280 ร— 720. **No HDMI-CEC**, so it stays on, and its Auto Sleep and Sleep timers must be Off (`build-heimdall.md` ยง5, ยง8) | | `heimdall` | Raspberry Pi 5, 2 GB, 64 GB microSD | Behind the screen, on Hicks over Wi-Fi. Raspberry Pi OS 13 with its own desktop, Chromium in kiosk mode. Arrived 2026-11-16 | | Power | Official 27 W USB-C supply for the Pi; the screen's own cord | Neither is on the UPS. Which outlet they reach is not yet settled: the office's right wall and alcove have none | diff --git a/docs/runbooks/build-heimdall.md b/docs/runbooks/build-heimdall.md index e3d8eb93..4b48191a 100644 --- a/docs/runbooks/build-heimdall.md +++ b/docs/runbooks/build-heimdall.md @@ -118,6 +118,32 @@ not boot, put the card in `oracle` and restore the `.bak`. After the reboot: cat /sys/class/drm/card1-HDMI-A-1/status # connected ``` +**The desktop's mode comes from `kanshi`, not from that line.** `video=` +sets the boot console and forces the output on. labwc takes whatever mode +the television's EDID calls *preferred*. This Changhong's EDID is a generic +one ("DMTF", model `CHHWJT*`, serial 1, and a 710 ร— 400 mm size that is not +a 40" panel's), and it prefers **1280 ร— 720**, while 1920 ร— 1080 at 60 Hz is +also in its list. Raspberry Pi OS runs `kanshi` to set modes, and an empty +`~/.config/kanshi/config` leaves the preferred one. Give it a profile: + +```bash +cp ~/.config/kanshi/config ~/.config/kanshi/config.bak +cat > ~/.config/kanshi/config <<'KANSHI' +profile wall { + output HDMI-A-1 mode 1920x1080@60.000 position 0,0 +} +KANSHI +sudo reboot +# after the reboot: +WAYLAND_DISPLAY=wayland-0 XDG_RUNTIME_DIR=/run/user/1000 wlr-randr | grep current +# 1920x1080 px, 60.000000 Hz (current) +``` + +Measured on 2026-11-18: sharp at 1080p, no edge cut off (the set's aspect +setting is *Full*, under Picture), and the mode survived a reboot. The page +scales its 1920 ร— 1080 stage to whatever mode it gets, so a wrong mode only +softens the text. It never crops the page. + ## 6. Trust the tier's root, in Chromium's store Chromium on Linux reads its own NSS database, not the system's store, so @@ -158,34 +184,39 @@ URL above. It is the page the kiosk has shown since 2026-11-17 put the Glance URL back by hand: nothing fails over on its own. Switching either way is this line's URL and a reboot, nothing else. `--password-store=basic` stops Chromium asking for a keyring at boot, which would otherwise sit on the screen. -Blanking off keeps the desktop from turning the screen off. ยง8 turns the -television off instead. +Blanking off keeps the desktop from turning the screen off. The screen stays +on day and night (ยง8). **Verify at the wall:** after a reboot, the page fills the screen with no address bar, no padlock warning and no keyring prompt. ## 8. The television, on and off -Ask whether the television takes orders over HDMI-CEC: - -```bash -cec-ctl -d /dev/cec0 --playback -S # the TV appears as device 0 -cec-ctl -d /dev/cec0 --to 0 --standby # it goes off -cec-ctl -d /dev/cec0 --to 0 --image-view-on # it comes back -``` - -If it obeys, schedule those two commands for the hours the office is empty. -If it does not, switch the Pi's output off instead. The television then shows -"no signal" and, on most sets, sleeps: - -```bash -wlr-randr --output HDMI-A-1 --off -wlr-randr --output HDMI-A-1 --on -``` - -`wlr-randr` talks to the running compositor, so run it as the desktop's user -with `WAYLAND_DISPLAY` set (`wayland-0` under labwc). Record which one worked -in the changelog. +**This set has no HDMI-CEC.** Its manual (FCC ID 2ABNO40YD1100UA) never +mentions it, and on 2026-11-18 the Pi's probe found nothing. `cec-ctl -d +/dev/cec0 --playback -S` gave the Pi's own adapter the physical address +`1.0.0.0`, taken from the television's EDID: it says which HDMI input the Pi +is on, not that the set answered. The television, which would be `0.0.0.0`, +never replied. No logical address was allocated, and the topology was empty. +So nothing on the Pi can turn the set off or wake it. + +What the manual does say, and what follows from it: + +- **Without a signal it switches itself off,** after 5 minutes ("TV mode") + or 60 seconds ("PC mode"). So switching the Pi's output off at night + (`wlr-randr --output HDMI-A-1 --off`) would put it in standby with nothing + to wake it in the morning but the remote. +- **Time menu โ†’ Auto Sleep must be Off,** and so must Sleep. Auto Sleep puts + the set in standby after a set time with "no operation", meaning no + remote press, so it would blank the wall part-way through every day while + the picture is fine. + +**The screen therefore stays on, day and night.** The page is dark and still +when nothing is wrong, and an LED panel does not burn in. Turning it off on a +schedule would take a smart plug (only if the set comes back on by itself +when power returns, which is untested) or an infrared LED on the Pi +replaying the remote's power code. Either is a purchase, so it goes through +the roadmap's *Everything still to buy* and an ADR of its own. ## 9. Undo @@ -198,3 +229,5 @@ in the changelog. - **The kiosk:** remove the line from `~/.config/labwc/autostart`. - **The root:** `certutil -d sql:$HOME/.pki/nssdb -D -n "matrix.elysium tier CA"`. - **The boot line:** restore `/boot/firmware/cmdline.txt.bak`. +- **The mode:** restore `~/.config/kanshi/config.bak`. The desktop falls back + to the television's preferred 1280 ร— 720. diff --git a/docs/security.md b/docs/security.md index 69871acb..f33f7f6e 100644 --- a/docs/security.md +++ b/docs/security.md @@ -1145,6 +1145,21 @@ from Home Assistant with *not enough permissions*. firing alerts, per-host CPU, SNMP reachability, WAN traffic and latency, the UPS and `heimdall`'s temperature. That is less than the Homelab page already shows, and the page and the Pi hold no credential. + **Its household half reads ten Home Assistant entities the same way.** + Each `/api/ha/NAME` is one `GET /api/states/` written in the + Caddyfile: the weather, the alarm's mode, four door contacts, two window + contacts, the office lights, and `sensor.wall_today`, which holds today's + and tomorrow's 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 + Caddy's environment alone and Caddy forwards nothing but those GETs. The + 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, and the family's + schedule for two days: each event's title, time and location. That is the + same as the Home Assistant app shows to the household, without its login. + The calendars' names, descriptions and attendees are not passed on. - `snmp-exporter` is never published to a host interface โ€” it is reachable only on the compose network. - Alertmanager binds to `127.0.0.1` only. It is unauthenticated, and a silence diff --git a/scripts/seed-validation-env.sh b/scripts/seed-validation-env.sh index e8170a3e..384ad7de 100755 --- a/scripts/seed-validation-env.sh +++ b/scripts/seed-validation-env.sh @@ -61,6 +61,7 @@ STACK="${REPO_ROOT}/stacks/${2:-observability}" echo "INGEST_TOKEN=validation-only-client" echo "GLANCE_PROMETHEUS_TOKEN=validation-only" echo "HA_PROMETHEUS_AUTHORIZATION=Bearer validation-only" + echo "WALL_HA_TOKEN=validation-only" echo "HA_MEDIATV_MAC=00:00:5e:00:53:00" echo "MQTT_HA_PASSWORD=validation-only-ha" echo "MQTT_RING_PASSWORD=validation-only-ring" diff --git a/secrets/sensitive.example.yaml b/secrets/sensitive.example.yaml index 16959fde..14ca7bfe 100644 --- a/secrets/sensitive.example.yaml +++ b/secrets/sensitive.example.yaml @@ -170,6 +170,21 @@ GLANCE_PAPERLESS_TOKEN: change-me-to-the-homepage-users-token GLANCE_PROMETHEUS_TOKEN: change-me-to-the-reader-token HA_PROMETHEUS_AUTHORIZATION: Bearer change-me-to-the-reader-token +# The office wall page's Home Assistant token (ADR-0119): the long-lived token +# of the non-admin HA user `wall`, minted in a private window while logged in +# as that user (Profile -> Security -> Long-lived access tokens, named +# `wall-caddy`), with "Can only log in from the local network" on. +# +# HOME ASSISTANT HAS NO READ-ONLY ROLE. This token can call services, unlock +# included. What keeps it read-only is where it lives: only in the caddy +# service's environment, which forwards GET alone to the fixed +# /api/states/ paths the Caddyfile's wall.matrix.elysium block lists. +# It is never on heimdall and never in the page. docs/security.md says so. +# +# Rotating it: delete the old token in HA as `wall`, mint a new one, replace +# it here, then `make up STACK=sensitive`. +WALL_HA_TOKEN: change-me-to-the-wall-users-long-lived-token + # The LG TV's full wired MAC, for Home Assistant's Wake-on-LAN call # (ADR-0097, #1218). It is not a credential. It is here because # docs/security.md truncates every MAC in the repository to its OUI, and SOPS diff --git a/stacks/sensitive/Caddyfile b/stacks/sensitive/Caddyfile index 801a7732..20d7b28a 100644 --- a/stacks/sensitive/Caddyfile +++ b/stacks/sensitive/Caddyfile @@ -278,6 +278,10 @@ start.matrix.elysium { # can query and nothing more (ADR-0067); this narrows it again, # to eight 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 +# drops the client's query string, and the `wall` user's token +# is added here (the wall_ha snippet). # # The token is the one Glance already holds, GLANCE_PROMETHEUS_TOKEN, given # to the caddy service in compose.yaml. It is the estate's READER, which @@ -302,6 +306,18 @@ start.matrix.elysium { } } +# The household half of the wall page: Home Assistant, on this network, with +# the token of its non-admin `wall` user added here. HA has no read-only +# role, so the narrowing below is what makes this read-only: one GET of one +# entity's state per handle, and nothing else under /api/ha/. +(wall_ha) { + reverse_proxy home-assistant:8123 { + header_up Authorization "Bearer {$WALL_HA_TOKEN}" + header_up -Cookie + header_down -Set-Cookie + } +} + wall.matrix.elysium { header { Content-Security-Policy "default-src 'none'; script-src 'self'; style-src 'self'; connect-src 'self'; img-src 'self'; font-src 'self'; base-uri 'none'; form-action 'none'; frame-ancestors 'none'" @@ -374,6 +390,65 @@ wall.matrix.elysium { import wall_prometheus } + # The header's weather: condition, temperature, humidity, wind. + handle /api/ha/weather { + rewrite * /api/states/weather.forecast_home? + import wall_ha + } + + # The Ring Alarm's mode, through a template entity in + # home-assistant/packages/wall_house.yaml: the alarm's own id names the city. + handle /api/ha/alarm { + rewrite * /api/states/sensor.wall_alarm? + import wall_ha + } + + # Ring contact sensors: on is open. + handle /api/ha/front_door { + rewrite * /api/states/binary_sensor.front_door? + import wall_ha + } + + handle /api/ha/garage_door { + rewrite * /api/states/binary_sensor.garage_door? + import wall_ha + } + + handle /api/ha/garden_door { + rewrite * /api/states/binary_sensor.garden_door? + import wall_ha + } + + handle /api/ha/patio_door { + rewrite * /api/states/binary_sensor.patio_door? + import wall_ha + } + + handle /api/ha/window_left { + rewrite * /api/states/binary_sensor.window_left? + import wall_ha + } + + handle /api/ha/window_right { + rewrite * /api/states/binary_sensor.window_right? + 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? + import wall_ha + } + + # Today's and tomorrow's events, gathered from the calendars by + # home-assistant/packages/wall_calendar.yaml. A calendar's own API needs + # a moving start and end, which a fixed handle cannot give. + handle /api/ha/today { + rewrite * /api/states/sensor.wall_today? + import wall_ha + } + handle /api/* { respond "no such question" 404 } diff --git a/stacks/sensitive/README.md b/stacks/sensitive/README.md index 5ad7d68c..65abc004 100644 --- a/stacks/sensitive/README.md +++ b/stacks/sensitive/README.md @@ -773,9 +773,34 @@ container of its own: Caddy serves `wall/` as static files. Watchdog that is not firing, is shown in red as exactly that, never as "All quiet". 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. -- **The household half is not here yet.** The calendar, the weather and the - house come through Home Assistant in a later change, the same way: fixed - entities, a token added by Caddy. +- **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 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, and the office lights. + The calendar is `sensor.wall_today` at `/api/ha/today`: the package + `home-assistant/packages/wall_calendar.yaml` asks `calendar.get_events` + every five minutes for today and tomorrow, from the calendars labelled + `wall_calendar` in HA's UI, or from every calendar when none is labelled. + It keeps each event's title, start, end, location and a calendar number for + its colour, and shows them in the Today panel under the alerts. 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 + 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, + and `/api/states/โ€ฆ` directly was 404. - **Adding it to the running tier.** On `trinity`: 1. Add `wall` to `trinity`'s *Additional Names for this Host* on `morpheus` ([`add-a-host-override.md`](../../docs/runbooks/add-a-host-override.md)), diff --git a/stacks/sensitive/compose.yaml b/stacks/sensitive/compose.yaml index d34b63c7..9f18a3db 100644 --- a/stacks/sensitive/compose.yaml +++ b/stacks/sensitive/compose.yaml @@ -150,6 +150,10 @@ services: # secrets/sensitive.example.yaml lists. environment: GLANCE_PROMETHEUS_TOKEN: ${GLANCE_PROMETHEUS_TOKEN:?set in secrets/sensitive.sops.yaml} + # And Home Assistant's `wall` user, for the page's fixed household + # entities, added to GET /api/states/ only. HA has no read-only + # role, so this narrowing is the read-only part. + WALL_HA_TOKEN: ${WALL_HA_TOKEN:?set in secrets/sensitive.sops.yaml} mem_limit: 128m memswap_limit: 128m cap_drop: [ALL] diff --git a/stacks/sensitive/home-assistant/packages/README.md b/stacks/sensitive/home-assistant/packages/README.md index db6c6373..cd15fdf7 100644 --- a/stacks/sensitive/home-assistant/packages/README.md +++ b/stacks/sensitive/home-assistant/packages/README.md @@ -28,6 +28,8 @@ and nothing else. This README is not YAML and Home Assistant ignores it. | `roomba.yaml` | *Roomba: start / stop / dock* scripts that ask the living-room Echo, through `alexa_devices.send_text_command`, to drive the Roomba 105 linked in Alexa. The core `roomba` integration does not support x05 models. One-way, cloud, with phrases editable in the UI | | `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`: today's and tomorrow's events, asked of `calendar.get_events` every five minutes, for the office wall's Today panel (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` and `binary_sensor.wall_office_lights` 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 | There is no `automations.yaml`. The UI automation editor writes that file into `/config` and needs `automation: !include automations.yaml` to load it, and diff --git a/stacks/sensitive/home-assistant/packages/wall_calendar.yaml b/stacks/sensitive/home-assistant/packages/wall_calendar.yaml new file mode 100644 index 00000000..9b547ccd --- /dev/null +++ b/stacks/sensitive/home-assistant/packages/wall_calendar.yaml @@ -0,0 +1,98 @@ +--- +# Today's and tomorrow's events, as one sensor the office wall can read +# (ADR-0119). +# +# The wall reads Home Assistant through fixed `GET /api/states/` +# handles in the Caddyfile. A calendar's own state is only its next event, and +# HA's calendar API needs a moving start and end that a fixed handle cannot +# give. So this asks `calendar.get_events` every five minutes and keeps the +# answer in `sensor.wall_today`, which the wall reads at `/api/ha/today`. +# +# Which calendars: the ones labelled `wall_calendar` in the UI, or every +# calendar when no calendar carries that label. No calendar is named here. +# Google's calendar ids name the people who own them, and docs/security.md +# keeps owner-linked names out of the repository. The label is read at every +# run, so adding or removing it takes effect within five minutes, with no +# restart. +# +# What reaches the wall: each event's title, its start and end, whether it is +# all day, its location, and a calendar number (its place in the sorted list, +# used only to pick a colour). Not the description, not attendees, and not the +# calendar's name. docs/security.md says who can read it: anything that can +# reach wall.matrix.elysium, which is the trusted segments. + +template: + - triggers: + - trigger: time_pattern + minutes: /5 + - trigger: homeassistant + event: start + - trigger: event + event_type: event_template_reloaded + actions: + - variables: + wall_calendars: >- + {% set labelled = label_entities('wall_calendar') + | select('match', 'calendar\.') | sort | list %} + {{ labelled if labelled + else states.calendar | map(attribute='entity_id') | sort | list }} + # A calendar that cannot be read (an expired Google token, the + # integration reloading) fails the whole call. continue_on_error lets + # the run go on, and the sensor below then reads unavailable rather + # than an empty, and wrong, "nothing today". + - action: calendar.get_events + target: + entity_id: "{{ wall_calendars }}" + data: + start_date_time: "{{ today_at() }}" + end_date_time: "{{ today_at() + timedelta(days=2) }}" + response_variable: agenda + continue_on_error: true + - variables: + wall_ok: "{{ agenda is defined and agenda is mapping }}" + wall_events: >- + {% set ns = namespace(items=[]) %} + {% set today = now().date().isoformat() %} + {% if agenda is defined and agenda is mapping %} + {% for cal in wall_calendars %} + {% for e in agenda.get(cal, {}).get('events', []) %} + {% set all_day = 'T' not in e.start %} + {% if all_day %} + {% set start = e.start %} + {% set end = e.end %} + {% set over = end <= today %} + {% set key = start ~ 'T00:00' %} + {% else %} + {% set start = as_local(as_datetime(e.start)).isoformat() %} + {% set end = as_local(as_datetime(e.end)).isoformat() %} + {% set over = as_datetime(e.end) <= now() %} + {% set key = start[:16] %} + {% endif %} + {% if not over %} + {% set ns.items = ns.items + [{ + 'key': key, + 'cal': wall_calendars.index(cal), + 'title': (e.get('summary') or 'Busy')[:80], + 'location': (e.get('location') or '')[:60], + 'all_day': all_day, + 'start': start, + 'end': end, + }] %} + {% endif %} + {% endfor %} + {% endfor %} + {% endif %} + {{ (ns.items | sort(attribute='key'))[:16] }} + sensor: + - name: Wall today + unique_id: wall_today + icon: mdi:calendar-today + availability: "{{ wall_ok }}" + # The state is how many events are left today, so the history graph + # means something. The wall reads the attributes. + state: >- + {{ wall_events | map(attribute='start') | map('regex_replace', 'T.*', '') + | select('le', now().date().isoformat()) | list | count }} + attributes: + calendars: "{{ wall_calendars | count }}" + events: "{{ wall_events }}" diff --git a/stacks/sensitive/home-assistant/packages/wall_house.yaml b/stacks/sensitive/home-assistant/packages/wall_house.yaml new file mode 100644 index 00000000..c026515e --- /dev/null +++ b/stacks/sensitive/home-assistant/packages/wall_house.yaml @@ -0,0 +1,41 @@ +--- +# The alarm's mode and the office lights, as two 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: +# +# - 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. + +template: + - sensor: + - name: Wall alarm + unique_id: wall_alarm + icon: mdi:shield-home + state: >- + {% set panel = states.alarm_control_panel | map(attribute='entity_id') | sort | first %} + {{ states(panel) if panel else 'unavailable' }} + availability: >- + {% 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 }} diff --git a/stacks/sensitive/wall/index.html b/stacks/sensitive/wall/index.html index 74ad0a29..80fba41e 100644 --- a/stacks/sensitive/wall/index.html +++ b/stacks/sensitive/wall/index.html @@ -5,9 +5,9 @@ Static on purpose: no build step, no framework, nothing fetched from anywhere but this site. Every number comes from /api/q/NAME, a fixed - Prometheus question the Caddyfile writes out and adds the token to, so this - page holds no credential. The household half (calendar, weather, the house) - is a later change, through Home Assistant, the same way. + Prometheus question, or /api/ha/NAME, one Home Assistant entity's state. + The Caddyfile writes each one out and adds its token, so this page holds no + credential. It is laid out on a fixed 1920x1080 stage, the television's native size, and scaled to whatever window it is in, so a laptop shows what the wall @@ -32,15 +32,26 @@
--:--
+
+
โ€”
+
โ€”
+
Waiting for Prometheus
-
-

Alerts

-
-
+
+
+

Alerts

+
+
+ +
+

Today

+
+
+

Elysian

@@ -68,8 +79,8 @@

Power

-

Household

-

Today, weather and the house arrive with Home Assistant.

+

Home

+
diff --git a/stacks/sensitive/wall/wall.css b/stacks/sensitive/wall/wall.css index a0fd12a9..f46f1456 100644 --- a/stacks/sensitive/wall/wall.css +++ b/stacks/sensitive/wall/wall.css @@ -56,9 +56,9 @@ html, body { grid-template-columns: 620px 1fr 1fr; grid-template-rows: 140px 1fr 300px 84px 40px; grid-template-areas: - "top top top" - "alerts nodes nodes" - "alerts wan power" + "top top top" + "left nodes nodes" + "left wan power" "house house house" "status status status"; gap: 22px; @@ -116,7 +116,12 @@ html, body { text-transform: uppercase; color: var(--mute); } -.alerts { grid-area: alerts; } +/* The left column: alerts on top, sized to what is firing, and the day's + events in what is left. Alerts come first; a busy alert list squeezes the + calendar, never the other way round. */ +.left { grid-area: left; display: flex; flex-direction: column; gap: 22px; min-height: 0; } +.alerts { flex: 0 1 auto; max-height: 70%; } +.today { flex: 1 1 0; min-height: 200px; } .nodes { grid-area: nodes; } .wan { grid-area: wan; } .power { grid-area: power; } @@ -187,7 +192,35 @@ html, body { .kv div { display: flex; font: 400 28px/1.2 var(--sans); color: var(--fg-dim); } .kv b { margin-left: auto; font: 500 30px/1 var(--mono); color: var(--fg); font-variant-numeric: tabular-nums; } -.placeholder { margin: 0; font: 400 28px/1.3 var(--sans); color: var(--mute); } +/* ---------- home row: one line, quiet unless something is open ---------- */ +.home { display: flex; gap: 48px; align-items: baseline; flex: 1; min-width: 0; } +.home .item { font: 400 28px/1.2 var(--sans); color: var(--fg-dim); white-space: nowrap; } +.home .item b { font-weight: 600; color: var(--fg); margin-left: 10px; } +.home .item.warn b { color: var(--yellow); } +.home .item.alert b { color: var(--red); } +.home .item.unknown b { color: var(--mute); } + +/* ---------- today: the calendar ---------- */ +.agenda { flex: 1; display: flex; flex-direction: column; gap: 14px; min-height: 0; overflow: hidden; } +.ev { display: grid; grid-template-columns: 8px 150px 1fr; column-gap: 16px; align-items: start; } +.ev .bar { grid-row: 1 / 3; align-self: stretch; border-radius: 4px; background: var(--blue); } +.ev .t { font: 500 28px/1.2 var(--mono); color: var(--fg-dim); font-variant-numeric: tabular-nums; white-space: nowrap; } +.ev .what { font: 600 28px/1.2 var(--sans); min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; } +.ev .where { grid-column: 3; font: 400 22px/1.3 var(--sans); color: var(--mute); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; } +.ev.now .t { color: var(--cyan); } +.ev.c1 .bar { background: var(--purple); } +.ev.c2 .bar { background: var(--green); } +.ev.c3 .bar { background: var(--cyan); } +.ev.c4 .bar { background: var(--fg-dim); } +.ev.c5 .bar { background: var(--mute); } +.day { font: 500 20px/1 var(--mono); letter-spacing: 0.14em; text-transform: uppercase; color: var(--mute); margin-top: 6px; } +.agenda .none { font: 400 28px/1.3 var(--sans); color: var(--fg-dim); } + +/* ---------- weather, in the header ---------- */ +.wx { display: flex; align-items: center; gap: 22px; margin-left: auto; margin-right: 40px; } +.wx-temp { font: 500 84px/1 var(--mono); color: var(--cyan); letter-spacing: -0.04em; font-variant-numeric: tabular-nums; } +.wx-desc { font: 600 32px/1.2 var(--sans); } +.wx-sub { font: 400 22px/1.3 var(--mono); color: var(--mute); margin-top: 4px; } /* ---------- status bar ---------- */ .status { diff --git a/stacks/sensitive/wall/wall.js b/stacks/sensitive/wall/wall.js index 32f87988..203f40d0 100644 --- a/stacks/sensitive/wall/wall.js +++ b/stacks/sensitive/wall/wall.js @@ -1,6 +1,8 @@ // The Elysian Wall (ADR-0119). Every number here is the answer to a fixed -// question at /api/q/NAME, written out in the sensitive tier's Caddyfile. The -// page chooses WHICH question, never the PromQL, and holds no token. +// question: /api/q/NAME for Prometheus, /api/ha/NAME for one Home Assistant +// entity's state, each written out in the sensitive tier's Caddyfile. The +// page chooses WHICH question, never the query or the entity, and holds no +// token. // // Every value is written with textContent, never innerHTML: label values come // from Prometheus, and anything that can push a series could otherwise put @@ -31,6 +33,17 @@ ]; const QUESTIONS = ["alerts", "cpu", "snmp", "wan", "wan_hour", "rtt", "ups", "pi_temp"]; + // Home Assistant entities, by the names the Caddyfile gives them. + const DOORS = [ + ["front_door", "Front"], ["garage_door", "Garage"], + ["garden_door", "Garden"], ["patio_door", "Patio"], + ]; + const WINDOWS = [["window_left", "Left"], ["window_right", "Right"]]; + const HOUSE = ["weather", "alarm", "office_light", ...DOORS.map((d) => d[0]), ...WINDOWS.map((w) => w[0])]; + // "today" is sensor.wall_today: the calendars' events for today and + // tomorrow, gathered by home-assistant/packages/wall_calendar.yaml. + const HA = [...HOUSE, "today"]; + const states = {}; // HA name -> the entity's state object const answers = {}; // name -> data.result of the last good answer const lastOk = {}; // name -> Date.now() of the last good answer @@ -82,7 +95,24 @@ } } + // One entity's state from Home Assistant. Kept under its own key in lastOk + // ("ha:NAME") so the status bar can age the house apart from the lab. + async function askHa(name) { + try { + const res = await fetch(`/api/ha/${name}`, { cache: "no-store" }); + if (!res.ok) return; + const body = await res.json(); + if (typeof body.state !== "string") return; + states[name] = body; + lastOk[`ha:${name}`] = Date.now(); + } catch (_) { + // Keep the last state; the status bar shows its age. + } + } + const fresh = (name) => lastOk[name] !== undefined && Date.now() - lastOk[name] < STALE_MS; + const haFresh = (name) => fresh(`ha:${name}`) && states[name] + && states[name].state !== "unavailable" && states[name].state !== "unknown"; // ---------- alerts and the verdict ---------- const SEVERITY_RANK = { critical: 0, warning: 1, info: 2 }; @@ -251,11 +281,19 @@ ["hosts", ["cpu", "snmp"]], ["internet", ["wan", "wan_hour", "rtt"]], ["power", ["ups"]], + ["house", HOUSE.map((n) => `ha:${n}`)], + ["calendar", ["ha:today"]], ]; for (const [label, names] of groups) { const oldest = Math.min(...names.map((n) => lastOk[n] ?? 0)); const span = el("span", "src"); - if (!oldest) { + // HA answers for a calendar it cannot read, with the state + // "unavailable" (an expired Google sign-in, most often). That answer is + // fresh and still says nothing, so it shows as dead. + if (label === "calendar" && oldest && states.today && states.today.state === "unavailable") { + span.classList.add("dead"); + span.textContent = "calendar ยท unavailable"; + } else if (!oldest) { span.classList.add("dead"); span.textContent = `${label} ยท never`; } else { @@ -270,8 +308,152 @@ bar.append(el("span", "push", `heimdall ยท ${fresh("pi_temp") && t ? `${num(t).toFixed(0)}ยฐC` : "โ€”"}`)); } + // ---------- weather (header) ---------- + const CONDITIONS = { + "clear-night": "Clear", cloudy: "Cloudy", exceptional: "Severe weather", fog: "Fog", + hail: "Hail", lightning: "Lightning", "lightning-rainy": "Thunderstorms", + partlycloudy: "Partly cloudy", pouring: "Heavy rain", rainy: "Rain", + snowy: "Snow", "snowy-rainy": "Sleet", sunny: "Sunny", windy: "Windy", + "windy-variant": "Windy", + }; + function renderWeather() { + const w = states.weather; + if (!haFresh("weather")) { + $("wx-temp").textContent = "โ€”"; + $("wx-cond").textContent = "โ€”"; + $("wx-sub").textContent = ""; + return; + } + const a = w.attributes || {}; + const unit = a.temperature_unit || "ยฐ"; + $("wx-temp").textContent = a.temperature !== undefined ? `${Math.round(a.temperature)}${unit.startsWith("ยฐ") ? "ยฐ" : unit}` : "โ€”"; + $("wx-cond").textContent = CONDITIONS[w.state] || w.state; + const bits = []; + if (a.humidity !== undefined) bits.push(`${Math.round(a.humidity)}% humidity`); + if (a.wind_speed !== undefined) bits.push(`wind ${Math.round(a.wind_speed)} ${a.wind_speed_unit || ""}`.trim()); + $("wx-sub").textContent = bits.join(" ยท "); + } + + // ---------- home row ---------- + // Quiet when all is shut: each item says so in neutral text. An open door + // or window turns its item amber; a triggered alarm turns it red. + const ALARM = { + disarmed: ["Disarmed", ""], armed_home: ["Home", ""], armed_away: ["Away", ""], + armed_night: ["Night", ""], arming: ["Arming", "warn"], pending: ["Entry delay", "alert"], + triggered: ["TRIGGERED", "alert"], + }; + function homeItem(label, value, cls) { + const span = el("span", `item ${cls || ""}`, label); + span.append(el("b", null, value)); + return span; + } + function openOf(list) { + let unknown = false; + const open = []; + for (const [name, label] of list) { + if (!haFresh(name)) { unknown = true; continue; } + if (states[name].state === "on") open.push(label); + } + return { open, unknown }; + } + function renderHome() { + const row = $("home"); + row.replaceChildren(); + + if (haFresh("alarm")) { + const [text, cls] = ALARM[states.alarm.state] || [states.alarm.state, "warn"]; + row.append(homeItem("Alarm", text, cls)); + } else { + row.append(homeItem("Alarm", "โ€”", "unknown")); + } + + const doors = openOf(DOORS); + if (doors.open.length) row.append(homeItem("Open", doors.open.join(", "), "warn")); + else row.append(homeItem("Doors", doors.unknown ? "โ€”" : "all closed", doors.unknown ? "unknown" : "")); + + const wins = openOf(WINDOWS); + if (wins.open.length) row.append(homeItem("Window open", wins.open.join(", "), "warn")); + else row.append(homeItem("Windows", wins.unknown ? "โ€”" : "closed", wins.unknown ? "unknown" : "")); + + if (haFresh("office_light")) { + row.append(homeItem("Office lights", states.office_light.state === "on" ? "on" : "off")); + } else { + row.append(homeItem("Office lights", "โ€”", "unknown")); + } + } + + // ---------- today: the calendar ---------- + // Events come as HA wrote them: an all-day event's start is a date + // ("2026-11-18"), which Date would read as UTC midnight, so it is split by + // hand into local midnight. Anything else is an ISO time with its offset. + const localDay = (s) => { const [y, m, d] = s.split("-").map(Number); return new Date(y, m - 1, d); }; + const evStart = (e) => (e.all_day ? localDay(e.start) : new Date(e.start)); + const evEnd = (e) => (e.all_day ? localDay(e.end) : new Date(e.end)); + const hm = (d) => { + const h = d.getHours(); + return `${h % 12 || 12}:${String(d.getMinutes()).padStart(2, "0")} ${h < 12 ? "AM" : "PM"}`; + }; + function eventRow(e, now) { + const start = evStart(e); + const going = start <= now; + const row = el("div", `ev c${Number(e.cal) % 6}${going && !e.all_day ? " now" : ""}`); + const t = e.all_day ? "All day" : going ? "Now" : hm(start); + row.append(el("span", "bar"), el("span", "t", t), el("span", "what", String(e.title || "Busy"))); + if (e.location) row.append(el("span", "where", String(e.location))); + return row; + } + function renderToday() { + const box = $("today"); + box.replaceChildren(); + if (!haFresh("today")) { + box.append(el("div", "none", "โ€”")); + return; + } + const now = new Date(); + const tomorrow = new Date(now.getFullYear(), now.getMonth(), now.getDate() + 1); + // The sensor is up to five minutes old, so drop what has ended since. + const evs = ((states.today.attributes || {}).events || []) + .filter((e) => evEnd(e) > now) + .sort((a, b) => evStart(a) - evStart(b)); + const todays = evs.filter((e) => evStart(e) < tomorrow); + const later = evs.filter((e) => evStart(e) >= tomorrow); + + if (todays.length) for (const e of todays) box.append(eventRow(e, now)); + else box.append(el("div", "none", "Nothing else today")); + if (later.length) { + box.append(el("div", "day", "Tomorrow")); + for (const e of later) box.append(eventRow(e, now)); + } + + // Keep what fits, and say how many did not. A "Tomorrow" heading with + // nothing under it goes too. + let hidden = 0; + while (box.scrollHeight > box.clientHeight && box.children.length > 1) { + if (box.lastElementChild.classList.contains("ev")) hidden += 1; + box.lastElementChild.remove(); + } + if (box.lastElementChild && box.lastElementChild.classList.contains("day")) box.lastElementChild.remove(); + if (hidden) { + const more = el("div", "more", `+${hidden} more`); + box.append(more); + while (box.scrollHeight > box.clientHeight && box.children.length > 1) { + more.remove(); + const last = box.lastElementChild; + if (last.classList.contains("ev")) hidden += 1; + last.remove(); + more.textContent = `+${hidden} more`; + box.append(more); + } + } + } + function render() { + renderWeather(); + renderHome(); renderAlerts(); + // After the alerts: they take the height they need, and the calendar + // fits itself into what is left. + renderToday(); renderNodes(); renderWan(); renderPower(); @@ -279,7 +461,7 @@ } async function poll() { - await Promise.all(QUESTIONS.map(ask)); + await Promise.all([...QUESTIONS.map(ask), ...HA.map(askHa)]); render(); }