[RELEASE] Device Watchdog

I'm running this app as an activity monitor and battery monitor.
The battery monitor is working as expected and I get a pushover notification when the battery level falls below a certain level.
Unfortunately I'm not getting anything from the activity monitor.
I noticed today that one of my Xiaomi contact sensors has been 'INACTIVE' since the 29th of Dec but I haven't received a report.
When I click on the 'Click Here To Generate A Report' button, a report is sent and it shows the sensor as being INACTIVE.
'Last Device Status Report' I get a message to say that says ' Oops! Something went wrong. Please hit 'Done' and come right back here again.
Still working on what causes this sometimes!'
Any thoughts???

Not sure why you're not getting a report. What happens when you do what the message says and go right back into the report page?

I noticed I had some devices that shouldn't be checked. I've just removed them.
Hit the report button again and the report I now see is good. Only 2 devices in there which I expect to see as one has its battery removed.
tried the last status report again and it is now working OK.
Not sure if it was the devices that should not have been there caused this but it is now OK.
Thanks for responding.

No problem, I see that page every now and then too. That's why I made it, it's an error catching page but I can't figure out why most of the time the report works great but every now and then it has no data. I'll keep searching!

When monitoring battery level, some devices that are listed as a device with battery capability do not actually report battery. When looking at these devices on the devices page, they do not have a "battery" state at all. These devices report their battery as 0 in Device Watchdog. I almost replaced a bunch of batteries before I figured out that it was reporting this way. Can you put "N/A" or something instead of 0 when a device's battery attribute is null/blank/non-existent?

Perhaps something like this (see //RayzurMod for edits):

def myBatteryHandler() {
	log.info "     - - - - - Start (B) ${state.myType} - - - - -     "
	LOGDEBUG("In myBatteryHandler...")
	state.mySensors.each { device ->
		log.info "Working on... ${device}"
		def currentValue = device.currentValue("battery")
		if(currentValue == null) currentValue = -999  //RayzurMod
		LOGDEBUG("In myBatteryHandler...${device} - ${currentValue}")
		if(currentValue < batteryThreshold && currentValue > -999) { //RayzurMod
			if(badORgood == false) {
				log.info "${state.myType} - mySensors: ${device} battery is ${currentValue} less than ${batteryThreshold} threshold."
				state.batteryMap += "${state.myType} - ${device} battery level is ${currentValue}<br>"
				state.batteryMapPhone += "${device} - ${currentValue} - "
		} else {
			if(badORgood == true && currentValue > -999) { //RayzurMod
				log.info "${state.myType} - ${device} battery is ${currentValue}, over threshold."
				state.batteryMap += "${state.myType} - ${device} battery level is ${currentValue}, over threshold.<br>"
				state.batteryMapPhone += "${device} - ${currentValue} - "
			} else
				if (currentValue == -999) { //RayzurMod
					log.info "${state.myType} - ${device} battery hasn't reported in." //RayzurMod
					state.batteryMap += "<i>${state.myType} - ${device} battery level isn't reporting</i><br>" //RayzurMod
					state.batteryMapPhone += "${device} - isn't reporting - " //RayzurMod
				} //RayzurMod
	log.info "     - - - - - End (B) ${state.myType} - - - - -     "

That looks great to me. Let me know how your testing goes and if it's good at your end I'll upload the new code.


The ones noting "battery level isn't reporting" are not reporting battery, so this is accurate.
Front Bathroom motion is an old device and has drained completely so I think 0 is accurate here. It matches what the device's page shows in HE.
If you decide to use the above example or a derivative, feel free to remove the //RayzurMod comments. Those were there just to point out changes.


Looking at the mobile notification, I would also recommend changing the seperator between device and value from - to : or something so it's easier to read.
ie: Battery - Living room motion south : 1 - Dining room motion : isn't reporting - Coffee light : 1 , etc...

Thank you for the improvements. All are welcome. I don't mind having the comments in the code. Good to see the community working together.

New Version on Github...

V1.0.7 - 01/04/19 - Modification by @rayzurbock . Report now shows 'battery level isn't reporting' when a device's battery attribute is null/blank/non-existent. Previously it showed 0. Also adjusted the output on the Push report. Thanks @rayzurbock

1 Like

Nice App! I kind of wish this was a built in function of HE.

For me, the Select All Battery Devices button doesnt seem to. I had to manually check them all to get them to monitor and report.

I found a contact sensor this morning that apparently quit working back on 12/16. Will be installing this app when I get home later this afternoon. I'm using HSM for battery monitoring, so that's not needed, but I want to catch battery powered devices that drop off the mesh for whatever reason. Thanks for the effort on this :slight_smile:

1 Like

Just saved me when my Xiaomi temperature battery died.
Expected has been running for almost 2 years.

1 Like

@bptworld on your github page, the link that says it's the child code contains a duplicate of the parent code.

Sorry about that, correct code has been updated.


1 Like

Working great so far!

Would it be possible to add an option to suppress empty status reports? I'd prefer to only be notified when there are problems.

I was thinking that earlier today. I would like that option too.

1 Like

Great idea. Let me see what I can do.

1 Like

I mean, it is nice to get my "no problems" pushover notification everyday, so I know it is working. But at this point I trust it is running. So switching to actionable alerts only would be good.

Might need a test message button too (can't remember if there is already one - not in front of my hub... sitting in LAX).

New version on Github...

V1.0.9 - 01/17/19 - Toggle switch added, Send or not to send Push notification when there is nothing to report.


That was quick :slight_smile: Will load it up when I get home from work. Thanks!

1 Like

I may be getting the same issue as @jon1

I have version 1.0.7 and I have the battery monitor set to monitor "all" devices. I've had some devices drop below the threshold but it still reports no devices being low.