Skip to content

notify_relay and notify_client

Fleet alerts through Home Assistant’s Supernotify, with one host holding the Home Assistant token (decision 31).

  • Does: notify_client installs fleet-notify on a host; it sends the alert to the relay. notify_relay runs the relay, which calls the supernotify/notify action.
  • Owns settings: this repo and the fleet repo. Who gets what, and how, is configured in Supernotify.
  • Keeps state: none on the relay. A sending host keeps alerts that could not be sent in /var/spool/fleet-notify (readable by root only).
  • Rolls back by: safe_apply on the relay’s code and compose file. The secrets file is not rolled back.
  • Exposes: port 8087 on the relay host’s tailnet address: POST /notify (needs the shared key) and GET /healthz.

There is no second delivery path. If Home Assistant or the relay is down, the alert is not delivered then. fleet-notify exits non-zero, logs ALERT NOT SENT with the reason, keeps the alert, and a timer (fleet-notify-retry, every five minutes) sends it when it can, with its original time in the title. An alert is dropped, with a log line, after 24 hours, when more than 50 are waiting (oldest first), or when the relay refuses its content. The same alert is not queued twice. A retry can arrive twice or out of order. sigcli health shows how many are waiting. Watch the hosts, the relay and Home Assistant from something outside them.

Set notify_relay_icon_url to give fleet alerts their own image, without changing your other Home Assistant notifications. For a file of your own, put it in Home Assistant’s config/www/ folder and use /local/<name>.png (if www did not exist, restart Home Assistant once). Home Assistant serves that folder without a sign-in, so put nothing private there. On iOS the image appears as the sender’s picture; the app’s own icon stays. If Home Assistant rejects a call that carries the icon, the relay sends the alert again without it and says so in its log. VERIFY on your phone: an accepted call does not show that the image appears.

  1. In Home Assistant, make a non-admin user for this and create a long-lived access token for it. As far as we know a token cannot be limited to one action (VERIFY), so treat it as able to control things.
  2. In the fleet repo, tag one host util: [notify_relay] and the hosts that should send alerts feat: [notify]. Remove feat: [apprise] from those hosts.
  3. Set notify_relay_ha_url and notify_relay_targets in config/vars/group/util_notify_relay.yml, and notify_client_url in config/vars/group/feat_notify.yml.
  4. Create two secrets: notify.relay with notify_relay_ha_token, and notify.client with notify_client_key (a long random value). Run scripts/access.sh sync.
  5. After the hosts reconcile, test from one of them: fleet-notify "test" "hello"; echo $?.

util: [notify] is something else: the Apprise API server.

The relay and the rendered fleet-notify script, against a stand-in for Home Assistant (hosts/tests/test_notify_relay.py). Not tested: a real Home Assistant or Supernotify, the roles on a host, and whether Supernotify accepts these priorities and force_resend from this call (VERIFY; the payload follows one Novak’s gateway uses). Unraid and other hosts without a package manager are not supported by notify_client.