notify_relay and notify_client
Fleet alerts through Home Assistant’s Supernotify, with one host holding the Home Assistant token (decision 31).
- Does:
notify_clientinstallsfleet-notifyon a host; it sends the alert to the relay.notify_relayruns the relay, which calls thesupernotify/notifyaction. - 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_applyon 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) andGET /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.
An icon for fleet alerts
Section titled “An icon for fleet alerts”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.
Setting it up
Section titled “Setting it up”- 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.
- In the fleet repo, tag one host
util: [notify_relay]and the hosts that should send alertsfeat: [notify]. Removefeat: [apprise]from those hosts. - Set
notify_relay_ha_urlandnotify_relay_targetsinconfig/vars/group/util_notify_relay.yml, andnotify_client_urlinconfig/vars/group/feat_notify.yml. - Create two secrets:
notify.relaywithnotify_relay_ha_token, andnotify.clientwithnotify_client_key(a long random value). Runscripts/access.sh sync. - After the hosts reconcile, test from one of them:
fleet-notify "test" "hello"; echo $?.
util: [notify] is something else: the Apprise API server.
What was tested
Section titled “What was tested”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.