Central to the system's ability to operate autonomously when needed while preferring manual control when available is the heartbeat mechanism. This elegant solution to the mode-switching problem has been introduced to enhance both reliability and usability.
When operating normally, Home Assistant through AR1 transmits a heartbeat signal at one-hertz frequency over the RS-485 link to AR3. The heartbeat takes the simple form HB:1, indicating that manual control is active and AR1 expects AR3 to remain in remote mode. AR3 continuously monitors the time since the last heartbeat was received, categorizing the link health into three states: fresh (received within the last four seconds), warning (not received for 60 seconds), and failed (not received for 300 seconds).
The deliberate choice of a five-minute timeout before autonomous mode activation prevents spurious transitions due to brief network hiccups while ensuring that genuine communication failures trigger autonomous operation promptly enough to respond to developing fire conditions. During bushfire events, communication infrastructure often fails gradually—power might flicker causing router reboots, smoke might interfere with wireless signals, or extreme heat might damage exposed cabling. A timeout shorter than five minutes would cause the system to oscillate between remote and autonomous modes as connectivity fluctuated, while a timeout longer than five minutes might delay autonomous response during the critical early stages of fire approach.
The 60-second warning state serves primarily diagnostic purposes. When the heartbeat age exceeds 60 seconds but remains below 300 seconds, the system logs the degradation and, on FireSys hardware with the LCD display, shows a warning indicator. This provides advance notice of communication problems while they remain recoverable, enabling operators to investigate and potentially resolve issues before autonomous transition becomes necessary. The warning state does not trigger any defensive actions, recognizing that communication might recover momentarily and that premature response would be counterproductive.
When the heartbeat finally fails to arrive for a full five minutes, AR3 transitions from FS_MODE_REMOTE to FS_MODE_AUTONOMOUS, logging the state change with a timestamp and the phrase "[MODE] ENTER AUTO". In autonomous mode, AR3 takes complete control of all outputs based solely on sensor data from AR2, implementing the fire defence algorithms described later in this essay. The system remains in autonomous mode even if heartbeats briefly reappear, requiring sustained heartbeat presence for 60 seconds before considering a return to remote control. This hysteresis prevents rapid mode oscillation if the communication link is unstable—for instance, if a damaged cable makes intermittent connection, the system won't repeatedly switch modes with each connection and disconnection.
The transition from autonomous back to remote mode requires some sophistication in its handling of state synchronization. Rather than immediately imposing Home Assistant's commanded states, which might differ significantly from what autonomous mode had established, AR1 implements a state adoption mechanism. During the period when heartbeat transmission resumes but before AR1 begins issuing new commands, AR3 continues publishing its current state in telemetry frames every two seconds. AR1 captures the most recent telemetry, extracting the pump state, all four peripheral valve positions, and the water level. It then applies these values to its local state variables and publishes them to MQTT as retained messages, ensuring that Home Assistant's dashboard reflects the actual current system state rather than stale historical values.
This adoption process prevents several problematic scenarios. An example is provided by the case where autonomous mode has activated the pump in response to high external temperature, but the Home Assistant dashboard still shows the pump as off because that was its state when communications failed. Without state adoption, the transition to remote mode would immediately send a pump-off command based on the dashboard state, potentially shutting down active fire defence at a critical moment. With state adoption, AR1 first updates the dashboard to show pump-on, then begins accepting new operator commands from that synchronized starting point.
The heartbeat system also responds to MQTT failures at the AR1 level. If AR1 loses connection to the Home Assistant MQTT broker for more than five minutes, it recognizes that manual control is no longer viable even though AR1 itself remains functional. In this case, AR1 stops transmitting heartbeats over RS-485, deliberately triggering autonomous mode on AR3. The operator loses dashboard visibility and control, but the fire defence system continues operating based on sensor inputs rather than becoming completely non-responsive. This ensures that communication failures anywhere in the chain from operator to pump result in autonomous operation rather than a potentially dangerous lack of response.
<< Communication Protocols | | Sensors >> |Table of Contents>
