How to do Weekly Battery Reports

I've got an array of battery powered devices like water leak detectors and table top buttons. I know that lithium battery level reporting is difficult at best, but just want to see them all on a weekly basis to determine is some are getting weak.

What I want to do in RM is receive a notification once a week, listing all my devices and their current battery levels (e.g., Sensor_Garage: 100%). I can do the notification part, but can't figure out how to get this info into a rule and then send it out as part of the notification. Thanks for your help.

This would be somewhat cumbersome but not impossible. You'd need to save the device attribute (battery, in this case) value to a variable, then use that variable to build a string you'd send in a notification or whatever mechanism you want. As an example:

Trigger: (whatever weekly schedule you want)

Actions to run:

Set variable tmpBattery to device attribute: Sensor 1 battery
Set notifyText to "Sensor 1 battery: %tmpBattery% "
Set variable tmpBattery to device attribute: Sensor 2 battery
Set notifyText to "%notifyText% Sensor 2 battery: %tmpBattery% "
Set variable tmpBattery to device attribute: Sensor 3 battery
Set notifyText to "%notifyText% Sensor 3 battery: %tmpBattery% "
Notify (your phone): '%notifyText%'

This rule also requires you to create two variables. To do it as I do above, you'll make one called tmpBattery of type Number and one called notifyText of type String. Local variables (in the rule) would probably be best, though there's no reason you could use a hub variable if you have a use for them outside the rule too (unlikely).

My "cumbersome" comment above refers to the facts that:

  • each device requires two actions of its own, even though it's nearly the same thing for all of them
  • the second of these actions requires you to manually type the device name and match what you've selected in the previous action (if you want it to make sense, ha)

Also, I think you'll get a new line between each if you just press Enter or Return at the end of the text in the "Set variable..." actions above, though I haven't tested that for sure. (A comma or whatever you want in between would also work.)

This would probably be easier with a custom app. I have one that can almost do what you want, though my intent was for it to notify only of batteries below a certain level (I guess you could set it to 100?) and the battery feature was really secondary to the "Last Activity At" check that I wrote the app for. There may be something more specific out there. Otherwise, you certainly can do it with a rule... :slight_smile:

1 Like

Thanks- I will check this out.

Have you looked at Battery Monitor or Device Watchdog.
They can give daily battery reports or report devices when the battery level drops below a certain value.

2 Likes

@JoeJ I agree with @bobbles. Doing a simple monitor and notification I think would be sufficient. I have HSM notify me of any battery device going below 20%. I figure given how bad accurate battery reporting on devices are that 20% is a safe enough warning to replace the battery in a device.

2 Likes

There seems to be an issue with your suggestion.
Is it because the device attributes of a sensor are always numeric?
See the following screenshot which would not allow me to pick the device attribute(battery):


(It wont let me select any attribute!)

Please note: F01 is a regular temperature/humidity sensor. Is the battery attribute only numeric?

Yes, the battery attribute should only be numeric if the driver implemented it properly. What kind of variable is tmpBatteryLevel in your example? I suspect it won't work if it is String, but it should if it is Number as I suggested above (I just tested and was able to do it in the latter but not the former case; maybe slightly surprising given how easy conversion in this direction should be, but I assume there's a reason).

Also, a further question.
Do you know how to force a new line in the notification? is there a code like %newline% ?

and, as always, Thanks in advance!

I suspect you can just literally type a new line in the text box when setting the value of the string variable or when creating the notification (obviously that last thing won't work if the area you want to put line breaks in is inside the contents of a string variable you've already assembled...). If not, my next guesses would be \n, \r\n, or <br>, but I've never tested any of those and suspect the first two would just show literally and the last would get stripped out.

I realize that it's not reporting/tracking per se, but I went with a dashboard to check on batteries:

2 Likes

Was just going to make the same suggestion. Not a report but informative at a glance.

I also went with the dashboard route with CSS to make it easier at-a-glance. Details in the original thread...

I went with Tile Master myself. That's 2 tiles with a 3rd for the title. Takes up way less space and can be used in other dashboards.
TM Batteries