How to get Zipabox to detect its own zombification and self-reboot
Quite often now (perhaps because I have a lot of rules), I notice that, after synchronising a new set of changes to rules, the Zipabox becomes partially zombified. It will continue to receive data from outside (from sensors, or from Google App Scripts that I have running to send information to it), but the rules that I have running on a constant cycle of ten minutes just stop working.
So I wondered if I could detect this state, and also whether I could get the Zipabox to reboot itself. The answer: yes, and yes :-)
For the reboot you'll need some sort of wireless socket. I deliberately chose one that is not intended for integration into home automation so that it will work completely independently of the Zipabox. I chose the TP-Link HS100/110. At first I just used it to reboot the Zipabox from my smartphone when I saw that it wasn't responding any more, but then I got a little more ambitious.
The TP-Link has the additional advantage of being able to accept commands in the form of HTTP requests, and being able to reboot itself. This is where I found the reboot command:
In order to be able to send it commands, you need to obtain the device ID and the authentication token, and note the URL (which is probably https://eu-wap.tplinkcloud.com for most of us), all of which is explained here:
You just need to get this info once by sending a couple of HTTP commands, and you're ready to send HTTP requests. The reboot command is as follows:
URL: https://eu-wap.tplinkcloud.com/?token=<YOUR AUTHENTICATION TOKEN>
Headers: Content-Type: application/json
"deviceId":"<YOUR DEVICE ID>",
That's the self-reboot part. Just put that in a rule.
Now for the detection of zombification. Since I want to detect when my variable-setting rules are not working, I save a time stamp each time those rules run (see my date-time meter post on creating time stamps). Then I create another rule that detects when that time stamp is out of date. Since my external data sources are still updating even when the box is not responding properly, I can create a rule that reacts to changes in those data sources, have the rule check the time stamp, and if the time stamp is old, reboot the box. See attachment.
The rule checks a selection of external data sources to ensure that it gets called pretty frequently. I disable the check immediately after a reboot because the system takes a while to get itself together.