A Home Assistant integration that sends systemd watchdog and ready notifications. If Home Assistant freezes, systemd's watchdog will automatically restart the service.
- Open HACS in Home Assistant
- Go to Integrations and click the three-dot menu
- Select Custom repositories and add:
- Repository:
brianegge/home-assistant-sdnotify - Category: Integration
- Repository:
- Click Download on the sdnotify card
- Restart Home Assistant
- Copy
custom_components/sdnotify/to yourconfig/custom_components/sdnotify/directory - Restart Home Assistant
- Go to Settings > Devices & Services > Add Integration
- Search for systemd Notify and click it
- Click Submit to confirm
No YAML configuration is needed.
Your systemd unit file (e.g., /etc/systemd/system/homeassistant.service) should include watchdog settings:
[Unit]
Description=Home Assistant
After=network-online.target
[Service]
Type=notify
Environment=WATCHDOG_USEC=5000000
User=homeassistant
WorkingDirectory=/home/homeassistant/.homeassistant
ExecStart=/srv/homeassistant/bin/hass -c "/home/homeassistant/.homeassistant"
WatchdogSec=20
Restart=on-failure
RestartSec=10
[Install]
WantedBy=multi-user.targetThen reload systemd:
sudo systemctl daemon-reload
sudo systemctl restart homeassistant.serviceThe integration creates a binary sensor that:
- Sends
READY=1to systemd when Home Assistant has started - Periodically sends
WATCHDOG=1pings (interval based onWATCHDOG_USECenv var, default 5 seconds) - Shows as a problem sensor until the ready notification is sent
If WATCHDOG_USEC is not set (i.e., not running under systemd), the sensor will not poll.
- Go to Settings > Devices & Services
- Find systemd Notify and click the three-dot menu
- Select Delete
- Optionally uninstall via HACS
Originally based on https://gist.github.com/yottatsa/2395de4ea665fecabf1dfb63796a546b