Is there a way to access low battery alarm?

If I do a trigger based on battery on the device that alarmed, it returns null as the current battery value.

If I do it on a device that hasn't alarmed, I get a value of 100.
So, maybe if I test the battery for [null], I'd know if it was in alarm.

Try adding below the capabilities in the driver:

attribute "alarm 1", "number"

So something like:

capability "Configuration"
capability "actuator"
capability "refresh"

attribute "alarm 1",      "number"

That gives me the alarm 1 custom attribute..
Value still appears to be null, though.
Even if I went with my battery testing idea, how would I test the numeric value against [null]? It's not letting me do it.

That may be because it has not changed.... Not sure how best to test that, beyond creating a test command to set it to something else, probably beyond my ability to explain on my phone... Hopefully others can step in...

1 Like

Well, I have some "power houses" at least giving it a once-over now. :slight_smile:

1 Like

It's annoyingly close, but probably far away in terms of time for me to provide a proper answer. If you look through other drivers, including mine, you may see the inclusion of a "command" in the metadata section, simply with a name. You need one of those, call the command what you want. Then create a method, like

def myCommand () {
sendEvent(...)
}

I would need to lookup a sendEvent example, but this would be where you set the alarm 1 attribute to, say 5, I e. something different to 1. Then let the device report 1 as an event. I know this isn't a complete solution, but may give you or others some ideas.

1 Like

I think I may have figured it out.
Maybe I'll test it when changing out the device's batteries, and another's who isn't reporting at all.

I went to the notification app and selected the water leak sensors to report on a battery level of less than 1. Null seems to evaluate to less than 1...go figure.

If you want to pull it from the event record you could use something like:

String lastEvent(evtName){
    evt = device.events()
    foundIt = false
    retValue = ''
    evt.each {
        if(it.name == "$evtName" && foundIt == false){
            retValue = it.value
            foundIt = true
        }
    }
    return retValue
    
}

Note that the above code only looks at the last 10 events by default so if you want to look at more you could change the second line to:

evt=device.events([max:50])
1 Like

I might try grafting that onto that old driver, but I'm pretty shaky.

I just replaced the batteries in the Utilitech leak sensor.
The old ones were at 1.14v, so alarm is justified.
I put new ones in, tripped the sensor, then put the old ones back in.
The Alarm 1 went away with the new batteries and came right back with the old.
BTW, Alarm 2 is tamper.
My rule didn't fire.
Normally, there seems a be a (bogus) battery report every 20 minutes.
Maybe I have to wait 20 minutes with the good batteries, get a battery report, and then switch out.
I'll try that.

edit: I take that back. Seems like every 2 or 3 days is more like it, lol.

1 Like

I replaced all but 1 of the 12 sensors' batteries.
I'm going to let it run down to alarm, and see what happens.
It's at 60% now.

Maybe mess with the event record, as above.
Event records accessibility should be a standard feature, in my opinion.

i have a couple of these and batteries last years as you say it basically reports nothing unless it is an alert.. i think it has c batteries? anyway are your sure the blinking light is not lite after a water report.. i just once a yr test mine and i have only found it dead i think once in 6 yrs. mine is running the std generic zwave water sensor driver.

Some were dead, some alarming, some were not.
About three years old.
Three AAA batteries.
It beeps with water on sensor; probably also rapidly blinks too, but I don't see it because bent over the sensor with saliva on my fingers, lol.
It definitely blinks every 30 seconds when Alarm 1, battery, is set

1 Like