Monday, September 10, 2018

Monitoring: the often overlooked automation.

What do I mean by monitoring

Being able to control things like your lights, TV excreta with your voice is nice and seems to be enough for a lot of people. At least till they discover a few well placed sensors with turn those lights off and on automatically. That is making the jump from remote control to automation and in a way could be considered monitoring but is not what I'm referring to. Simple monitoring would be like:

  • What I posted in UPS monitoring to tell me if a UPS monitor is offline.
  • Having IFTTT update a Homeseer virtual timer that triggers an alert if your Fitbit has not posted sleep in over 30 hours to monitoring the system itself. 
  • Having a smart plug power a cycle a camera that has dropped offline for several minutes

Stuff breaks, crashes or batteries simply die. In the case of batteries they might die while the system is still reporting them as good. Unless you are watching for missing data you might not know it is missing until you try and use the data or the control it is linked to.

My ChkSensors.vb script

Inspired by the BLRadar Plug-In for HomeSeer I wrote simple script ChkSensors.vb that is called hourly and looks at any Homeseer device object not in an ignored location and has the HomeSeerAPI.Enums.dvMISC.SET_DOES_NOT_CHANGE_LAST_CHANGE flag unset. The HomeSeerAPI.Enums.dvMISC.SET_DOES_NOT_CHANGE_LAST_CHANGE flag when set only updates the Last Change value if the value is changed from the previous update. The rub of course is that while many hardware devices update all values at the same time not all so and some plugins even set the HomeSeerAPI.Enums.dvMISC.SET_DOES_NOT_CHANGE_LAST_CHANGE flag during updates so those need to be ignored.  Currently my script is checking 449 of my 1788 "devices". Note a device in Homeseer is data stream or control so an Aeon 6in1 sensor for example is 8 Homeseer devices.

That may not seem like much but it covers all my Z-wave, Hue and Harmony devices along with several things monitored via Ethernet / WiFi. For example My alarm panel is seen by Homeseer as 19 devices. 16 zones and 3 other devices. In know "Root" and "Partition 1" change every time I open a door or change modes so that will happen at least a few times a day. Even if I was out of town someone would have to come feed the animals. Anyway that means I really only need to monitor 1 device to confirm Homeseer and the alarm are still talking to each other.
You will notice the script tags the devices (not in ignored locations) that it is not monitoring with a  which is a bit of a hack but makes it easy to know which devices have the flag set without having to open them up. Especially since, as mentioned above, some plugins force that flag unset.
There to you will notice with the Aeon 6in1 above I'm monitoring only Humidity, Luminance, UV and Temperature. Root nodes on Z-wave devices never seem to update. UV never reaches this sensor so it is never sent. Motion and tamper are not monitored because the location is were there should not be any animals and I want to alert me is any get in there. Hence the motion and Home Security devices should not update unless there is a problem.

Note too the script checks devices at 3 age levels. Anything not ignored over 48 hours old, any in the chk24 group over 24 hours old and anything in the chk1 group over 1 hours old.

Reporting

If a device is found to be last updated too long ago has its current Location2 (called Category in my system) saved to the device's UserNote field before setting its Location2 to offline. This makes listing all the devices that need looked at simple. The last thing the script does if there are any devices found offline is to give you a verbal warning. Assuming warnings are not muted. See SayIt.vb. What you get is something like this
To give some examples the Laundry door sensors tell me for some reason I have not opened that door in 24 hours which is odd but not a big deal. Same UPSBox_DC_Sensor_chan4 not getting triggered since yesterday when I went out get a package. Again normally I open the box each evening when filling the south feeder but yesterday it was raining so I skipped it. The WirelessTag ones though are an issue. And a very strange one at that. Looking on the server all the data is there and no errors are in the logs. Even stranger there appears to be no pattern to which data is getting updated and what is not. I have 8 tags linked. Each has 4 data streams (plus battery level which has never worked for some reason). This happened once before. Then tags 0 and 2 were not updating. Rebooting the WirelessTag hub did not help but repowering it did. This time 0 and 1 are the only ones updating. Worse yet only the temp of tag 1 has updated since I repowered this time.
There was an exception in the logs this time at 9/8/2018 at 5:06 PM but nothing before or since which makes me suspect the hub is going out. Though it might be a bad update from what I see here.

Want some more examples of why you might need monitoring?

Last week my Rachio got knocked offline by a storm. It shows in the list. I reboot it and all is well. Better than finding when wondering why the plants are wilting.

Today I had an alert for the north lights in the barn. A Z-wave wall switch. A quick check and I found the breaker had tripped. Better than finding by needing to see in the barn and not having lights that work.

An event example in case you need

If you have read this far you probably already know how to trigger this from an event but in case you are not that deep in the woods yet here is what the event looks like.

Helper methods

There are a couple other helpful things in that script as well to simplify life. For example
fixFlagsByType lets you set the HomeSeerAPI.Enums.dvMISC.SET_DOES_NOT_CHANGE_LAST_CHANGE flag on any device in offline by passing it part of the type name. For instance any BLOnkyo Plug-in device
fixFlagsByRoom does similar by room (dv.Location)

initFlags unsets HomeSeerAPI.Enums.dvMISC.SET_DOES_NOT_CHANGE_LAST_CHANGE flag on all devices not in the filtered locations to get you started.


No comments:

Post a Comment