Can someone explain how to use the setBattery() function? (Or: How to use Device Activity Check)

I installed the Virtual Battery app written by Simon Burke. This app has a setBattery() function. Then I created a virtual water sensor. I'd like to set the battery level of the virtual device I created to test my low battery notification rule. Can someone explain how to make this call with setBattery?

-Thanks

The Virtual Leak Sensor does not support the Battery capability.

To perform your testing, I recommend using a Virtual Battery device instead. You can change the battery level of the Virtual Battery device directly on its device details page.

4 Likes

Before you go too far down this rabbit hole, will you be tracking lithium batteries with this notification?

If so, I wouldn't put too much blood, sweat and tears into it -- lithium batts all have an exceedingly sharp drop-off at EOL. Many of mine go from 100% straight to stone dead when they die. Some of mine might hang out at some percentage >50 after a while, but I honestly don't ever recall seeing a lithium battery report less than 50%.

Not saying that low lithium readings are impossible, but lithiums all die fast & hard -- it's not a predictably & steady linear decline like alkaline (I don't use rechargeables, but I suspect they're somewhere in between).

Since I use lithiums exclusively, I don't even bother trying to track any %s anymore -- I just wait for my Device Activity Check app to tell me when something stopped reporting, and that's when I change its battery.

I do change my door-lock batteries annually no matter what, since that's a pretty important one to have working for certain. For all my other battery stuff, if something is dead for ~24 hrs before I get the no-activity alert, that's no big deal.

6 Likes

My SmartThings/Centralite leak sensors stay at 0% for 5+ months before they finally die. Like you I monitor that devices report at least 12-24 hours.

1 Like

Just a quick reminder: The Ask Anything subcategory is a great place for quick questions and answers on specific topics, and acts as an extension of the FAQ.

If your post is more about sharing experiences or diving into more advanced features—like using custom apps or drivers—it’s best to choose a different, more relevant sub-category. That way, you’ll get the right eyes on your post and more helpful responses.

5 Likes

Better yet! Thank you.

I posted it in the driver category, I thought that was a good fit.

1 Like

I didn't realize the lithium batteries were so fickle. I will certainly keep that in mind.

-Thanks

Devices reporting what? I mean what are you looking a for a trigger?

-Thanks

All of my battery devices either get "actuated" daily, or they do some kind of routine reporting (e.g. periodic temp reporting or perhaps a periodic heart-beat / health-check of some sort). If all that stops, Device Activity Check tells me "Head's-up, I haven't heard from this thing in the last 24 (or whatever you want) hours".

1 Like

Yes, that's a very good point too... I recall jtp10181 saying that he's had devices go for another ~6 months at 0%.

1 Like

That would have been a better fit. However, it looks like you selected the Ask Anything sub-category and added the driver tag:

When you create a post, the category/subcategory fields are on the left and the optional tags on the right:

4 Likes

Same here, I still haven't bothered writing the checks into an app since this is so simple in Webcore. Activity checks are about the only thing I still use Webcore for.

I use different time frames for different devices. The basement door sensor does not get used every day, so I set that activity check for a week. Temp sensors usually report about once an hour, at least, so I just set a two hour check for non-activity with those.

I put for each device loops under an hourly check timer, and it check the condition for each device has not changed in X hours/days, depending on which device list variable I am checking. It is easy to add a device to, or remove a device from, the device array variables as needed for each time frame check.

1 Like

Got it. I thought it was just the optional tags that specified the location of the message.

I went to create a "Device Activity Check" in Rule Machine. Can you tell me what trigger or conditional trigger you use to check a device for activity? I didn't see anything that matches.

-Thanks

1 Like

Great thanks! This definitely sounds useful.

I'll just say there's a reason I wrote the app instead. :slight_smile: You can sort of do something similar if there's only one particular event (or few) that you care about in RM, but it's different approach compared to checking this metadata on the device object itself, which is not accessible from RM.

And as others have alluded to, one reason I created this in the first place is that battery reporting, especially for lithium batteries common in home automation devices, is notoriously unreliable. (I don't even bother looking at these values anymore, just the app.)

Adding on to this, it would keep things cleaner as well if you used the quote feature and consolidated multiple successive replies into the same post (fewer actual posts to scroll through total, plus an easier view of what you're responding to; you can quote more than one post in the same reply, like I did with Bobby's in this one).

6 Likes

Thanks for the info, I had no idea prior to my post that battery monitoring was so flakey. And thanks for writing the app, it sounds very useful!

2 Likes

I installed the app, and selected the devices to monitor. I only selected devices with batteries. So then I removed the battery from one of the leak sensors.

Then when I click on View Current Report it shows 8 of the 10 devices I selected to monitor. Should the device with the battery removed generate a notification? I'm unclear how to implement this for battery monitoring.

Summary

This text will be hidden