We have moved at community.getvera.com

Author Topic: Verasecure notification if power loss  (Read 477 times)

Offline uros76

  • Newbie
  • *
  • Posts: 17
  • Karma: +0/-0
Verasecure notification if power loss
« on: January 17, 2019, 03:55:12 am »
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?

Offline rigpapa

  • Beta Testers
  • Hero Member
  • *****
  • Posts: 1121
  • Karma: +187/-3
Re: Verasecure notification if power loss
« Reply #1 on: January 17, 2019, 07:36:10 am »
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?

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.
Author of Reactor, DelayLight, SiteSensor, Rachio, Deus Ex Machina II, Intesis WMP Gateway, Auto Virtual Thermostat and VirtualSensor plugins. Vera Plus w/100+ Z-wave devices. Vera3, Lite. Hassio, Slapdash.

Offline uros76

  • Newbie
  • *
  • Posts: 17
  • Karma: +0/-0
Re: Verasecure notification if power loss
« Reply #2 on: January 17, 2019, 09:11:52 am »
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 :).

Offline rigpapa

  • Beta Testers
  • Hero Member
  • *****
  • Posts: 1121
  • Karma: +187/-3
Re: Verasecure notification if power loss
« Reply #3 on: January 17, 2019, 09:37:14 am »
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 :).

Choose the Reactor master device, and you'll see two variables listed: SystemPowerSource (possible values are "battery" and "utility"), and SystemBatteryLevel (0-100, percent).
Author of Reactor, DelayLight, SiteSensor, Rachio, Deus Ex Machina II, Intesis WMP Gateway, Auto Virtual Thermostat and VirtualSensor plugins. Vera Plus w/100+ Z-wave devices. Vera3, Lite. Hassio, Slapdash.

Offline uros76

  • Newbie
  • *
  • Posts: 17
  • Karma: +0/-0
Re: Verasecure notification if power loss
« Reply #4 on: January 17, 2019, 10:01:06 am »
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.


Offline rigpapa

  • Beta Testers
  • Hero Member
  • *****
  • Posts: 1121
  • Karma: +187/-3
Re: Verasecure notification if power loss
« Reply #5 on: January 17, 2019, 12:00:30 pm »
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.

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.
Author of Reactor, DelayLight, SiteSensor, Rachio, Deus Ex Machina II, Intesis WMP Gateway, Auto Virtual Thermostat and VirtualSensor plugins. Vera Plus w/100+ Z-wave devices. Vera3, Lite. Hassio, Slapdash.

Offline wilme2

  • Hero Member
  • *****
  • Posts: 1302
  • Karma: +33/-13
Re: Verasecure notification if power loss
« Reply #6 on: February 19, 2019, 03:29:17 pm »
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.

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.

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?
Long Live UI5!  (OK finally made the switch to UI7 in January 2018, and am pretty happy....)

Offline rigpapa

  • Beta Testers
  • Hero Member
  • *****
  • Posts: 1121
  • Karma: +187/-3
Re: Verasecure notification if power loss
« Reply #7 on: February 19, 2019, 03:37:36 pm »
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.

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.

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?

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.
Author of Reactor, DelayLight, SiteSensor, Rachio, Deus Ex Machina II, Intesis WMP Gateway, Auto Virtual Thermostat and VirtualSensor plugins. Vera Plus w/100+ Z-wave devices. Vera3, Lite. Hassio, Slapdash.

Offline wilme2

  • Hero Member
  • *****
  • Posts: 1302
  • Karma: +33/-13
Re: Verasecure notification if power loss
« Reply #8 on: February 19, 2019, 04:22:46 pm »

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:


Code: [Select]
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...
Long Live UI5!  (OK finally made the switch to UI7 in January 2018, and am pretty happy....)

Offline rigpapa

  • Beta Testers
  • Hero Member
  • *****
  • Posts: 1121
  • Karma: +187/-3
Re: Verasecure notification if power loss
« Reply #9 on: February 19, 2019, 04:31:02 pm »

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:


Code: [Select]
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...

That code is similar to mine. So, I'm lost here. What, if any, problem are we trying to solve, or question to answer?
Author of Reactor, DelayLight, SiteSensor, Rachio, Deus Ex Machina II, Intesis WMP Gateway, Auto Virtual Thermostat and VirtualSensor plugins. Vera Plus w/100+ Z-wave devices. Vera3, Lite. Hassio, Slapdash.

Offline wilme2

  • Hero Member
  • *****
  • Posts: 1302
  • Karma: +33/-13
Re: Verasecure notification if power loss
« Reply #10 on: February 19, 2019, 05:00:30 pm »
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
Code: [Select]
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
Code: [Select]
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...
Long Live UI5!  (OK finally made the switch to UI7 in January 2018, and am pretty happy....)