Get the Battery Status via API

Discussions about RaZberry - Z-Wave board for Raspberry computer
Post Reply
vvuu
Posts: 39
Joined: 30 Aug 2015 14:22

Get the Battery Status via API

Post by vvuu »

I need get a battery status in percentage from my battery powered devices - via some API (JSON, XML,...)

it is possible ? I couldn't find this battery level in any JSON answer from my devices..
;(
pz1
Posts: 2053
Joined: 08 Apr 2012 13:44

Re: Get the Battery Status via API

Post by pz1 »

This is how I've done it in JS in OpenRemoteHelpers.

Code: Select all

 
// Battery is never in instances
zway.devices[N].Battery.Get();
return zway.devices[N].Battery.data.last.value;
Don't call it to often! Once a week should be quite enough.

Update 14:57:
If you use SmartHome, battery polling App is installed by default to run only once a week.
Then you only need:

Code: Select all

zway.devices[N].Battery.data.last.value;
To get your data
vvuu
Posts: 39
Joined: 30 Aug 2015 14:22

Re: Get the Battery Status via API

Post by vvuu »

why it is so important to call it not too often ?
pz1
Posts: 2053
Joined: 08 Apr 2012 13:44

Re: Get the Battery Status via API

Post by pz1 »

Because it has takes "airtime" to send. Sending data takes much more energy than receiving. Battery devices are optimised to make the send (and awake) period as short as possible.
As an example: most of my 12 Thermostatic Radiator Vlaves are 100% OK according to the timing info in ExpertUI. Two that are at awkward places which apparantly require many transmissions are at 97%. The batteries of those two drain much faster than the others. I had to replace those after some 6 months or so while others have served me around 18 months or more.
Post Reply