We have moved at community.getvera.com

Author Topic: Battery Low notifications  (Read 43116 times)

Offline FlyBoyBob

  • Full Member
  • ***
  • Posts: 163
  • Karma: +0/-0
Re: Battery Low notifications
« Reply #45 on: April 27, 2011, 01:12:29 pm »
FlyBoy, thanks for the awesome explanation.  I'll dig back into this soon.
Instead of email, I've been using prowl for notifications:
http://forum.micasaverde.com/index.php?topic=4508.0
I'm not sure if I can pass detailed variable in this though. 

I have never used Prowl myself (BlackBerry user ::)) but I would think that if you used the "&description" variable and set it equal to my "message_out" you could send whatever text you want.

Just guessing  ???
bob

Offline FlyBoyBob

  • Full Member
  • ***
  • Posts: 163
  • Karma: +0/-0
Re: Battery Low notifications
« Reply #46 on: April 27, 2011, 01:16:32 pm »
Thanks Bob. I will try that tonight.

One more thing: you only need
Code: [Select]
local message_out = warning..room.." is now at "..low_level.."%"

once - after all devices have been tested.

Or you could get clever and make them message_out1, 2, 3 etc and create a multiline report that shows all devices with low batteries in one email. I just didn't want to make the code too complicated for non-programmers.

bob

Offline ballroller

  • Sr. Member
  • ****
  • Posts: 286
  • Karma: +0/-0
Re: Battery Low notifications
« Reply #47 on: April 27, 2011, 01:34:29 pm »
I'm "that guy" !!!


I just didn't want to make the code too complicated for non-programmers.

bob

Offline ballroller

  • Sr. Member
  • ****
  • Posts: 286
  • Karma: +0/-0
Re: Battery Low notifications
« Reply #48 on: April 28, 2011, 12:56:01 am »
Well, I ended up writing a new scene for each battery to test. I am having problems saving my work with this UI4. It does strange things...

When I tried to edit the LUUP code and save it, when it was done saving it would revert back to the old code (everything I had done was gone!) , and sometimes it would create a whole new scene with the old code. So I would have 2 scenes that were wrong! So I deleted all of the scenes and used the wizard. That seems to work so I made a scene for every battery and added LUUP code to it. It didnt have any problem saving that for some reason.

I am going to let it run for a few days and then change the code to the low level test you originally did.

Thanks again!

Offline Intrepid

  • Hero Member
  • *****
  • Posts: 536
  • Karma: +4/-0
Re: Battery Low notifications
« Reply #49 on: April 28, 2011, 07:00:41 am »
OK, I tried the new code from post 24.  All my wireless devices are less than a week old, so the batteries may be 100%.  I let the trigger at 100 to test.

I get no email.

I see this in the log:
Quote
Scene::RunScene running 80 battery check <0x2c0c>

LuaInterface::CallFunction-3 Scene  80 failed [string "function scene_13()..."]:205: attempt to concatenate global 'low_level' (a nil value) <0x2c0c>

What does this mean?

edit: my battery icons in UI appear full, and I assume they show less full as battery life goes down, so this may be a case of me having full power right now.  I can try some used batteries on the weekend and see what happens.  Or is there a way to print the battery level to the screen, log?
« Last Edit: April 28, 2011, 07:25:43 am by Intrepid »

Offline FlyBoyBob

  • Full Member
  • ***
  • Posts: 163
  • Karma: +0/-0
Re: Battery Low notifications
« Reply #50 on: April 28, 2011, 08:14:21 am »
OK, I tried the new code from post 24.  All my wireless devices are less than a week old, so the batteries may be 100%.  I let the trigger at 100 to test.

I get no email.
You need to set the trigger to *more* than the current value, so as test you can set the trigger to 101 for your 100% batteries. No need to put stale batteries in.

Try the suggestions I put in reply#42 to test each device to give yourself a warm fuzzy feeling that it is working for all devices. Be sure to use the main device number for 3-in-1's = the one that shows "Battery Level" in your Dashboard.

Also test email as I describe in reply#24 independently of the battery level test code. Forum users have been having trouble getting good email notifications for a long time - make sure you can get that working by itself first. I have found it invaluable for testing other things = I can email myself variable values that are difficult to see any other way, for instance.

I see this in the log:
Scene::RunScene running 80 battery check <0x2c0c>
LuaInterface::CallFunction-3 Scene  80 failed [string "function scene_13()..."]:205: attempt to concatenate global 'low_level' (a nil value) <0x2c0c>

What does this mean?
It means you found an error in my sloppy posting. The reporting string should be the variable "level_to_report", which I have now fixed in #24. Thanks for finding that!

Hope that helps,
bob
« Last Edit: April 28, 2011, 08:32:31 am by FlyBoyBob »

Offline Intrepid

  • Hero Member
  • *****
  • Posts: 536
  • Karma: +4/-0
Re: Battery Low notifications
« Reply #51 on: April 30, 2011, 08:16:45 am »
Here is my combined code to test one device.  I took your post #24 and the smtptogo info.

This seems to work.  If I set the test level to 101, I get an email:

The battery in the Garage 3-in-1 is now at 100%

But when I change it back to a lower test limit of 30, I still get an email with blank battery status:

The battery in the  is now at %

Shouldn't the script terminate if it does not pass the test of actual status being greater than the test limit?  What am I missing to make it do nothing if the battery is greater than the test limit?

Thanks.

Code: [Select]

local test_for_below  = 30

local room       = ""
local level_to_report  = ""
local serviceId  = "urn:micasaverde-com:serviceId:HaDevice1"
local variableId = "BatteryLevel"
local warning    = "The battery in the "
local level

-- duplicate these lines for each device to test
level = luup.variable_get(serviceId, variableId, 8) or "0"
level = tonumber(level)
if (level <  test_for_below) then
  room = "Garage 3-in-1"
  level_to_report = level
end
-- end of duplicated lines

local message_out = warning..room.." is now at "..level_to_report.."%"

local myEmail     = "myemailgoeshere"

-- local message_out = "OMG WTF it works!!"
local send_to     = myEmail
local sender      = myEmail
local subject_out = "Battery Low Notification"

local smtp = require("socket.smtp")

local mesgt    = {
      headers  = {
      to       = send_to,
      from     = sender,
      subject  = subject_out},
      body     = message_out}

local result   = smtp.send {
      from     = sender,
      rcpt     =  {send_to},
      source   =  smtp.message(mesgt),
      server   = "smtp2go.com",
      port     = "2525",
      user     = myEmail,
      password = "smtptogopasswordgoeshere"}

Offline umtauscher

  • Full Member
  • ***
  • Posts: 223
  • Karma: +0/-0
Re: Battery Low notifications
« Reply #52 on: May 01, 2011, 12:49:47 pm »
Hi Flybob,

thank you very much for your work. I am very much interrested in sending a battery low notification from my 3in1 sensor as well. Unfortuately the battery level is always reported 100% on the dashboard. Is there something wrong with my sensor, with vera's display or is there a trick to make it show a correct level?
TIA
Umtauscher

Offline wscannell

  • Full Member
  • ***
  • Posts: 157
  • Karma: +0/-0
Re: Battery Low notifications
« Reply #53 on: May 01, 2011, 04:39:13 pm »
The HSM100 battery level seems to drop very quickly once the batteries get weak.  It seems to go from 100% to well under 50% in a week or so.  The batteries seem to last about 4 months when the unit is installed where there is a lot of motion (whether the sensor is armed or not).

Offline kaldoon

  • Sr. Member
  • ****
  • Posts: 258
  • Karma: +0/-0
Re: Battery Low notifications
« Reply #54 on: May 01, 2011, 04:51:01 pm »
The Battery level on the HSM100 Sensors is a little flakey have 6 of them in my system and the level doesn't really seem to change - any place between 96 and 100% with brand new batteries and then 10 to 12 weeks later  the sensor stops transmitting motion - wake up the sensor and the battery level has dropped significantly.  Brand new batteries then everything is good again - keep 48 AAA batteries on hand   :-\

Offline FlyBoyBob

  • Full Member
  • ***
  • Posts: 163
  • Karma: +0/-0
Re: Battery Low notifications
« Reply #55 on: May 02, 2011, 01:37:50 pm »
Intrepid:

You are missing code to exit if there is no message to send:
Code: [Select]
if (room=="") then
  return false
end
Place it just before the line that builds "local message_out". It will exit if the variable "room" is never filled in with text.

I put the code in as a single line myself but made it 3 lines here to make it clear to non-programmers. I probably dropped that out of my code examples because it is "between" the two jobs that they do - I will go back to my original posts again and see if I can put it in a logical place.

Thanks for pointing that out!
bob

Offline umtauscher

  • Full Member
  • ***
  • Posts: 223
  • Karma: +0/-0
Re: Battery Low notifications
« Reply #56 on: May 02, 2011, 01:42:15 pm »
The Battery level on the HSM100 Sensors is a little flakey have 6 of them in my system and the level doesn't really seem to change - any place between 96 and 100% with brand new batteries and then 10 to 12 weeks later  the sensor stops transmitting motion - wake up the sensor and the battery level has dropped significantly.  Brand new batteries then everything is good again - keep 48 AAA batteries on hand   :-\
Thanks for that information. Mine reports still 100% after having changed the batteries about 4 weeks ago.
Cheers
Umtauscher

Offline FlyBoyBob

  • Full Member
  • ***
  • Posts: 163
  • Karma: +0/-0
Re: Battery Low notifications
« Reply #57 on: May 02, 2011, 01:48:14 pm »
The HSM100 battery level seems to drop very quickly once the batteries get weak.  It seems to go from 100% to well under 50% in a week or so.  The batteries seem to last about 4 months when the unit is installed where there is a lot of motion (whether the sensor is armed or not).
This is a characteristic of alkaline batteries fortunately or unfortunately, not the HSM100s or the Vera. They stay at or near 100% for most of their usable life, then drop off rapidly. That's why I need the emails!

I have tried cheap generic-brand alkalines, and name brands other than Duracell, and all give me problems and much shorter life than the Duracells. I own my own airplane and the FAA prohibits the use of anything other than Duracells in my ELT (Emergency Locator Transmitter), which kind of convinced me to stick with the brand whenever I see battery problems. Just an opinion - not an endorsement!

Hope that helps,
bob

Offline pgrover516

  • Beta Testers
  • Hero Member
  • *****
  • Posts: 1013
  • Karma: +0/-0
Re: Battery Low notifications
« Reply #58 on: May 02, 2011, 02:57:33 pm »
I have seven 3-in-1 sensors, 2 schlage locks, and three HM-TS001's and am using NiMH batteries, the only useful battery info seems to come from the locks, the 3-in-1's either read 100 or 90 and never change, the HM-TS001's read either 100 or 50 regardless if the batteries are fresh charged though they may fall lower eventually (sometimes on a unit with fresher batteries), only the locks fall off in the way one would expect, without usable info from the device reporting becomes a secondary issue
V1,V2,V3,VLite,Express Controls HSM-100,Intermatic HA20C, HA04C,HA02C,HA09, Leviton VRP15-1LW, VRS15-1LX,Home Manageables HM-TS001,Schlage FE599, Schlage BE369, Cooper RF9500, Aeon Labs Minimote, Schlage TZEMT400AB32MAA+more

Offline FlyBoyBob

  • Full Member
  • ***
  • Posts: 163
  • Karma: +0/-0
Re: Battery Low notifications
« Reply #59 on: May 02, 2011, 04:23:01 pm »
... am using NiMH batteries... regardless if the batteries are fresh charged though they may fall lower eventually (sometimes on a unit with fresher batteries)...
As reference regarding NiMH rechargeable batteries:

NiMH batteries only put out 1.2vdc vs 1.5vdc for alkaline, so with the 3 in these units you get 3.6v vs 4.5v. A device that takes 4 normal cells to make 6v needs 5 rechargeables to get the same supply voltage.

NiMh batteries lose 25% of their charge per month sitting on the shelf, alkaline batteries have a typical 100% charge shelf life of 5 years. In a device where we would like the batteries to last 6 months 25%/month is significant.

From topic http://forum.mios.com/index.php?topic=629.0:
One more thing to watch for, be careful when using rechargeable batteries with these motion sensors the voltage is a little lower and I found that the reliability of the sensor was not to be trusted.