anonimno

Device monitoring

What do you do when the sensor stops working?

Sometimes devices stop working. Mostly you notice it, because some smarthome function, e.g. turning on the lights, is not available anymore. The trick is to figure out something is wrong, before you or your loved ones notice the smarthome function is not working anymore.
Until now following problems occurred in my setup:

  1. Sensors stopped sending data. This happens mostly when the battery is drained.
  2. Sensor value is stuck. I have one self-made sensor which continues sending data, but the value is frozen.
  3. Some service stops working, e.g. Syncthing, Baikal.

Sensor monitoring with a script

This is the script I wrote to monitor my devices. The script has two parts.

This part here, checks if the monitored devices are sending data to Domoticz. I use the built in function lastUpdate.minutesAgo which is available for all devices. When a device didn't get an update for a defined period of time, I make a log entry and send myself an E-Mail. I also set a user variable with the suffix timeout, which can then be used in other scripts. You can setup the variables under Setup - More options - User variables.

variables.png

This is how the script looks like.

The other part of the script checks if the sensor is changing value. The scripts is called every hour, so if the temperature didn't change for a couple of hours (implemented using a simple counter) I want to be notified.

Service monitoring with Monit

Monit is a great little tool which can be used to monitor all sort of things. You can then restart local services or notify the admin, that is you :), that something is wrong. Here you can find a good explanation how to set it up.
I am using Monit for several things:

  • Local service monitoring: Domoticz, Syncthing.
  • Remote service monitoring: TVheadend, Baikal.
  • Monitoring if my mounted Samba shares are accessible.

If you need help setting up monitoring with Monit or modifying the script, feel free to contact me.

Happy hacking!!

RSS Home


Updated: 2020-12-31 Do 15:14 License: CC BY-SA 4.0