Battery level change event

I was wondering whether there are battery state change events fired for devices that support capability.battery
In other words, I am wondering whether code like the following would work (I have no easy way of testing this out with my zwave lock currently)

subscribe(batDev, “battery”, handler)

def handler(event) {
//send user update if battery value below threshold
if(event.device?.currentBattery < 25) {
sendPush(“Battery low for device ${event.deviceId}”)

If I understand what you’re trying to do, there’s an app out there that will notify you of low battery thresholds:

I don’t know if it works, but since the update to 2.0 (I believe), there is a built-in battery app set to send push notification. No clue what the “low” threshold is.
In the IDE, check My Locations > List SmartApps (see “LowBattery Notification”)

@earlenceferns If you want to receive all battery events for the location you can subscribe to the location and then handle finding the device from there. Anything with battery capability should be caught by this.

subscribe(location, "battery", batteryHandler)

def batteryHandler(evt) {
    log.debug "Battery Event value: ${evt.value}%"
    log.debug "Battery Event device: ${evt.device}"

Is this what you are looking for?

1 Like

I may be mistaken, but I believe that most zwave battery operated devices don’t push report battery until they get down to what the manufacturer considered the “panic level”. Typically around 20% with a final warning around 5%, although it varies by manufacture.

Prior to those levels you have to pull them, and the polling doesn’t work the way you expect. You can’t just ask for the battery level. You have to ask for a bunch of things one at a time, basically working your way through a list of status codes. And as it happens battery is almost at the end of that list.

So if you are waiting for a battery report to be initiated by the device, it generally isn’t going to happen until the battery is in fact low.

And if you are forcing a push much more often, you may eat through a lot of the battery. The usual “best practice” is to schedule a “wellness check” once a day that pulls the battery status then.


Thank you all for the input. In fact, last night when my ZWave (Schlage) lock battery value changed from 99 to 98, my SmartApp actually was triggered and it sent out a push notification.

Thank you. This is similar to what I was looking for.