Use node-red on you remote pis and use an MQTT node to subscribe to the heart-beat topic and an exec node to send the command sudo reboot
Use a cron rule and the MQTT action to send a heart beat mqtt message
install the MQTT action!!
rule "heart beat every minute"
when
Time cron "1 0 0 ? * * *"
then
publish("broker", "topic", "payload")
end
In node-red:
[
{
"id": "75de1188.8438d",
"type": "mqtt in",
"z": "609ba6ef.24ec1",
"name": "",
"topic": "topic",
"qos": "0",
"broker": "28001b6c.f6c784",
"x": 110,
"y": 80,
"wires": [
[
"195f2dc9.f75c22"
]
]
},
{
"id": "195f2dc9.f75c22",
"type": "trigger",
"z": "609ba6ef.24ec1",
"op1": "1",
"op2": "0",
"op1type": "str",
"op2type": "str",
"duration": "65",
"extend": false,
"units": "s",
"reset": "payload",
"bytopic": "all",
"name": "",
"x": 290,
"y": 80,
"wires": [
[
"409e1ffc.a3e7f"
]
]
},
{
"id": "409e1ffc.a3e7f",
"type": "switch",
"z": "609ba6ef.24ec1",
"name": "",
"property": "payload",
"propertyType": "msg",
"rules": [
{
"t": "eq",
"v": "0",
"vt": "str"
}
],
"checkall": "true",
"repair": false,
"outputs": 1,
"x": 470,
"y": 80,
"wires": [
[
"6e607723.d16088"
]
]
},
{
"id": "6e607723.d16088",
"type": "exec",
"z": "609ba6ef.24ec1",
"command": "sudo reboot",
"addpay": false,
"append": "",
"useSpawn": "false",
"timer": "",
"oldrc": false,
"name": "",
"x": 650,
"y": 80,
"wires": [
[],
[],
[]
]
},
{
"id": "28001b6c.f6c784",
"type": "mqtt-broker",
"z": "",
"name": "broker",
"broker": "brokerIP",
"port": "1883",
"clientid": "openhab-node-red",
"usetls": false,
"compatmode": true,
"keepalive": "60",
"cleansession": true,
"birthTopic": "",
"birthQos": "0",
"birthPayload": "",
"closeTopic": "",
"closeQos": "0",
"closePayload": "",
"willTopic": "",
"willQos": "0",
"willPayload": ""
}
]
The first node subscribe to the topic and passes the payload to the next node. If the second node hasn’t received a payload of “payload” after 65s then it will send a payload of 0 to the next node. The next node will trigger only on a payload of 0. The last node will execute a command line.