VnutZ Domain
Copyright © 1996 - 2026 [Matthew Vea] - All Rights Reserved

2026-09-09
Featured Article

Automating APRS Station Restarts with Zwave and Home Assistant

[index] [253 page views]
Tagged As: APRS, HAM Radio, and How To

Introduction

My daughter's APRS station provides iGate coverage for our local area. We set the system up about four years ago using an ICOM 2730 and a Raspberry Pi. The other day, I noticed my Jeep wasn't appearing on the APRS map despite being close to home and upon checking, found the station was off-line for more than two weeks.

This wasn't the usual case of just requiring a restart of the Direwolf service. Rather, the Raspberry Pi itself just seemed to be in a bad state and unresponsive to SSH attempts. So I rebooted the unit and looked at the syslog. The last entry was from August 16th and showed errors that halted the overall system ... though the reboot seemed to fix that.

I needed a solution that would keep the Raspberry Pi up even when I wasn't paying attention to it. The easy way would simply be scheduling a recurring reboot with a cron job or having an Amazon Plug toggle itself on a schedule. Neither solution is elegant and the latter can even introduce unnecessary potential data corruption. Fortunately, if you are willing to deal the nuances of an overly flexible system, Home Assistant can handle this.

How will this work? The Raspberry Pi will beacon to the Home Assistant every five minutes as a digital "proof of life." That beacon will be used by Home Assistant to save a timestamp. Simultaneously, the Home Assistant will keep a running time delta between the current time and the last beacon timestamp. Also simultaneously, the Home Assistant will periodically tell a wireless plug using a Zwave mesh to toggle itself but only if the last seen beacon was longer ago than a predefined threshold. This prevents unnecessary power cycling as it will only happen if the Raspberry Pi enters a bad state that internal scripting cannot recover from.

That said ... configuring all that is a pain in the ass.

Schedule a Heartbeat

In order to let the Home Assistant know the Raspberry Pi is alive, it needs to send a heartbeat of sorts. Fortunately, within Home Assistant, you can create what is called a webhook. This is simply a URL that can be called on the Home Assistant's web server API that will perform an action. Accessing that URL can be as simple as using a command-line tool like curl or wget and doing it on a defined interval. Since the Raspberry Pi is a little Linux box, this can easily be done with a crontab and shell script.

Save the following one liner as send_heartbeat.sh and set it's executable bit.


#!/bin/bash
/usr/bin/curl -X POST http://192.168.1.200:8123/api/webhook/heartbeat_aprs

Edit the user's crontab to periodically execute the heartbeat shell script. Calling it every five minutes is an easy way to make sure the Home Assistant is aware the Raspberry Pi is on-line.


*/5 * * * * /home/aprs/send_heartbeat.sh

Configure a Date/Time Helper

The rest of the configurations will take place on Home Assistant through it's web page. At the time of this article, Home Assistant versions are Core 2026.9.1, Supervisor 2026.09.0, Operating System 18.2 and Frontend 20260826.6.

Although setting up the webhook seems to be the next logical step, it's not. In order the webhook to work, a date/time helper needs to exist for it to act on. Thus, setting up the helper is next. The following sequence of steps will navigate the system to set that up.

  • Click the "Settings" icon from the left pane
  • Click "Devices & Services" from the presented options
  • Click the "Helpers" tab from the top pane
  • Click the blue "+Create Helper" button at the bottom right
  • Scroll the helpers and select "Date and/or Time"
  • Name the helper "Heartbeat - APRS"
  • Choose an icon ... I recommend typing "heart" and selecting one
  • Check the radio button for "Date and Time"
  • Click the blue "Create" button

Configure a Webhook

Now that a date/time helper exists, the webhook will have something to modify when it is activated. Creating a webhook basically establishes a named URL in the Home Assistant's API that can be tied to an action. When this webhook is accessed, it will update the previously created date/time helper.

  • Click the "Settings" icon from the left pane
  • Click "Automations & Scenes" from the presented options
  • Click the blue "Create Automation" button at the bottom right
  • Click the "Create New Automation" option
  • Click the blue "Add Trigger" button
  • Either type "webhook" in the search bar or click "By Type" and scroll the left menu to "Webhook"
  • A single trigger option is presented, click it.
  • A pane opens on the right that is pre-populated with a random string in the "Webhook ID" field. Replace the text with "heartbeat_aprs"
  • Click the blue "Add Action" button
  • Either type "input datetime" in the search bar or click "By Type" and scroll the left menu to "Input Datetime"
  • Two options are presented, click "Input Datetime: Set Input Datetime Value"
  • A pane opens on the right side.
    • Click the blue "Add Target" button
    • Type "Heartbeat - APRS" in the search bar and click that entity
  • Check the "Date & Time" box
  • Enter {{ now().strftime('%Y-%m-%d %H:%M:%S') }} into the text box
  • Click the blue "Save" button
  • A popup will appear asking to name the automation - call it "Heartbeat Hook - APRS"

Configure a Binary Sensor

The pieces are starting to come together. You have a named timestamp entity that can be updated when an external device provides a status heartbeat to a webhook and an automation that computes a time delta between "now" and the last heartbeat. To make that more useful, create a binary sensor which basically tracks whether something is good or bad.

  • Click the "Settings" icon from the left pane
  • Click "Devices & Services" from the presented options
  • Click the "Helpers" tab from the top pane
  • Click the blue "+Create Helper" button at the bottom right
  • Scroll the helpers and select "Template"
  • Scroll the templates and select "Binary Sensor"
  • Name the sensor "Offline Alert - APRS"
  • Click the device class dropdown and Choose "Problem"
  • Enter {% set last_seen=state_attr('input_datetime.heartbeat_aprs', 'timestamp') %} {{ last_seen is not none and (now() | as_timestamp) - last_seen > 3600 }} into the state text box
  • Click the blue "Submit" button

Configure a Plug Automation

At this point, you have all the backend pieces to make the final automation. For whatever brand of plug you've chosen, go ahead and install it according to their included instructions. For many Zwave devices, it's just a matter of using a phone camera, a QR code on the device, and your Home Assistant app. The finishing touch is creating an automation to control that plug that behaves in accordance with the created timestamps and sensors.

  • Click the "Settings" icon from the left pane
  • Click "Automations & Scenes" from the presented options
  • Click the blue "Create Automation" button at the bottom right
  • Click the "Create New Automation" option
  • Click the blue "Add Trigger" button
    • Either type "Time Pattern" in the search bar or click "By Type" and scroll the left menu to "Time" and select "Time Pattern"
    • Three fields are presented for Hours, Minutes, and/or Seconds to trigger the automation
    • To run once every hour, put something like "15" into the minutes field (e.g. every hour on the 15th minute
    • To run every fifteen minutes, put "/15" into the minutes field (e.g. runs 4 times an hour)
  • Click the blue "Add Condition" button
    • Either type "Offline Alert - APRS" or select "Offline Alert - APRS" from the by target list and click on the entity
    • Click on state and choose "Problem" from the menu
  • Click the blue "Add Action" button
    • Select the installed Zwave plug from the "By Target" list
    • Select "Turn Off Switch"
  • Click the blue "Add Action" button
    • Select "Wait for Time to Pass" from the "Block" list
    • Put "1" into the minutes field
  • Click the blue "Add Action" button
    • Select the installed Zwave plug from the "By Target" list
    • Select "Turn On Switch"
  • Click the blue "Save" button

    Summary

    The plug will now check every 15 minutes the status of the "Offline Alert - APRS" automation. If the heartbeat timestamp is more than 3600 seconds [6 hours] old, the binary sensor will indicate a problem causing the plug to turn off, pause, and turn on again. Obviously the various timers such as heartbeat interval or seconds to be flagged as a problem or frequency of the plug to check are all configurable. On one hand, doing fancy things with Home Assistant can be a painful experience to figure out what options exist and where they are hidden and how to daisy chain them together. On the other hand, the power of Home Assistant is the ability to create so many custom objects, triggers, and automations to interact in any imaginable way with all the real-world gadgets that can integrate into the ecosystem.

    The bottom line is I no longer need to monitor the APRS station. On board the Raspberry Pi, various scripts can monitor the status of the interfaces and the server itself for faults and automatically restart them. But in the event the hardware gets into a bad state or the automated script fixes don't work, the Home Assistant logic controlling the plug can provide a physical reboot all without any human intervention.



More site content that might interest you:

It's too bad disc-less installation has become the norm.


Try your hand at fate and use the site's continuously updating statistical analysis of the MegaMillions and PowerBall lotteries to choose "smarter" number. Remember, you don't have to win the jackpot to win money from the lottery!


Tired of social media sites mining all your data? Try a private, auto-deleting message bulletin board.


paypal coinbase marcus