Verasecure notification if power loss

Hi. Pretty new to UI7 and VeraSecure and wondering if anyone managed to get this done.

Since Verasecure has its battery it will keep working if I have power loss. I am looking to triger an action when verasecure switches to internal battery power. Is this possbile?
I looked on scene triggers under verasecure device and couldnt find much useful. There is chance to get notified if battery of verasecure drops under certain %. But that cant be instant notification of power loss.

Any ideas?

[quote=“uros76, post:1, topic:200451”]Hi. Pretty new to UI7 and VeraSecure and wondering if anyone managed to get this done.

Since Verasecure has its battery it will keep working if I have power loss. I am looking to triger an action when verasecure switches to internal battery power. Is this possbile?
I looked on scene triggers under verasecure device and couldnt find much useful. There is chance to get notified if battery of verasecure drops under certain %. But that cant be instant notification of power loss.

Any ideas?[/quote]

The Reactor plugin pulls the current power source (utility or battery) and battery charge level. You can make conditions for either (i.e. send you a notification when the unit has been on battery power more than some amount of time, or when the battery level becomes lower than X%). Since I don’t have a VeraSecure, it is an unverified feature, but if you go that direction, I’ll follow it with you and address anything that comes up.

Thanks for reply. I just installed Reactor and trying to find right condition. Attaching screenshot of options visible under verasecure.
Not sure where to go from here. Should I try with status? But then what kind of status is there? Any chance I can see status names change when I disconect power?
Sorry for noob questions :).

[quote=“uros76, post:3, topic:200451”]Thanks for reply. I just installed Reactor and trying to find right condition. Attaching screenshot of options visible under verasecure.
Not sure where to go from here. Should I try with status? But then what kind of status is there? Any chance I can see status names change when I disconect power?
Sorry for noob questions :).[/quote]

Choose the Reactor master device, and you’ll see two variables listed: [tt]SystemPowerSource[/tt] (possible values are “battery” and “utility”), and [tt]SystemBatteryLevel[/tt] (0-100, percent).

Cool, it worked. On newly created reactor sensor I used reactor master device and its SystemPowerSource battery variable as condition. Attaching condition screenshot. Hope your recomendation was going into this direction :).
Takes 20 seconds to get the trigger working after I take off power but this delay doesn’t bother me. By the way I love the untrip action option, brilliant function implemented in plugin.

Thanks a bunch :). Off to next automation tasks.

[quote=“uros76, post:5, topic:200451”]Cool, it worked. On newly created reactor sensor I used reactor master device and its SystemPowerSource battery variable as condition. Attaching condition screenshot. Hope your recomendation was going into this direction :).
Takes 20 seconds to get the trigger working after I take off power but this delay doesn’t bother me. By the way I love the untrip action option, brilliant function implemented in plugin.

Thanks a bunch :). Off to next automation tasks.[/quote]

Yes. The delay is because the power source and battery level are not event-driven data in Vera/Luup, they have to be polled. They are updated every minute.

[quote=“rigpapa, post:6, topic:200451”][quote=“uros76, post:5, topic:200451”]Cool, it worked. On newly created reactor sensor I used reactor master device and its SystemPowerSource battery variable as condition. Attaching condition screenshot. Hope your recomendation was going into this direction :).
Takes 20 seconds to get the trigger working after I take off power but this delay doesn’t bother me. By the way I love the untrip action option, brilliant function implemented in plugin.

Thanks a bunch :). Off to next automation tasks.[/quote]

Yes. The delay is because the power source and battery level are not event-driven data in Vera/Luup, they have to be polled. They are updated every minute.[/quote]

Actually in L_G550Siren.lua the battery is level updated every 15 seconds, hence his indication of a 20 second delay. Which is crazy to me, so I just set it to 120 seconds. I also disabled the cellular usage poll - it was only polling every two hours, but went out to an internet server for that data (which is problematic at startup IMHO)… Maybe your 60 update is at a lower level?

[quote=“wilme2, post:7, topic:200451”][quote=“rigpapa, post:6, topic:200451”][quote=“uros76, post:5, topic:200451”]Cool, it worked. On newly created reactor sensor I used reactor master device and its SystemPowerSource battery variable as condition. Attaching condition screenshot. Hope your recomendation was going into this direction :).
Takes 20 seconds to get the trigger working after I take off power but this delay doesn’t bother me. By the way I love the untrip action option, brilliant function implemented in plugin.

Thanks a bunch :). Off to next automation tasks.[/quote]

Yes. The delay is because the power source and battery level are not event-driven data in Vera/Luup, they have to be polled. They are updated every minute.[/quote]

Actually in L_G550Siren.lua the battery is level updated every 15 seconds, hence his indication of a 20 second delay. Which is crazy to me, so I just set it to 120 seconds. I also disabled the cellular usage poll - it was only polling every two hours, but went out to an internet server for that data (which is problematic at startup IMHO)… Maybe your 60 update is at a lower level?[/quote]

My 60-seconds is me going out with exactly that timing to the OS and running shell commands and parsing their stdout. I doubt those commands poll separately. More likely they’re just wrappers to pull data directly from /sys, which in turn pulls data from I2C, ports, or whatever the implementation interface is. I don’t have a Secure myself, so I can’t dissect them to find out.

What is being executed to update the battery level that is shown in the VeraSecure device:

local function GetBatteryLevel()
	local stdout = io.popen("battery get level 2>&1")
	-- Output example:
	-- level=78
	local batteryLevel = stdout:read("*a") or ""
	stdout:close()
	debug("Battery level: ".. tostring(batteryLevel))
	return tonumber(batteryLevel:match("level=(%d+)") or -1)
end

I think we talked about this already. I just finally noticed it was polling every 15 seconds and decided to look at L_G550Siren.lua to see if I could easily change it…

What is being executed to update the battery level that is shown in the VeraSecure device:

local function GetBatteryLevel()
	local stdout = io.popen("battery get level 2>&1")
	-- Output example:
	-- level=78
	local batteryLevel = stdout:read("*a") or ""
	stdout:close()
	debug("Battery level: ".. tostring(batteryLevel))
	return tonumber(batteryLevel:match("level=(%d+)") or -1)
end

I think we talked about this already. I just finally noticed it was polling every 15 seconds and decided to look at L_G550Siren.lua to see if I could easily change it…[/quote]

That code is similar to mine. So, I’m lost here. What, if any, problem are we trying to solve, or question to answer?

In my case, how to lower the overhead of the VeraSecure device by reducing the battery polling from every 15 seconds to every 2 minutes…

At the top of L_G550Siren.lua change local POLL_INTERVAL = 15 -- Seconds to something less frequent like 120. And if you want to stop cellular polling entirely since you aren’t using it, comment out UpdateCellular() at the very bottom.

I haven’t seen any posts here about how to make modifications to the VeraSecure specific battery/cellular functionality. Probably should be a new thread…