Python plugin: Battery Level for Z-Wave Devices

Python and python framework
User avatar
heggink
Posts: 621
Joined: Tuesday 08 September 2015 21:44
Target OS: Raspberry Pi
Domoticz version: V4.9999
Location: NL
Contact:

Re: Python plugin: Battery Level for Z-Wave Devices

Post by heggink » Monday 13 August 2018 20:58

Plugin works great but sometimes, after changing batteries, the old battery level persists and does not get updated (not even after reboot). Thoughts?
Pi3, latest beta
RFXCOM, z-wave (AEOTEC, switches, temhum, pir, contacts),
Plugwise2py, P1 'smart'meter & solar panel
Alexa, Wifi Cams motion detection
ESP: relays, PIR & Temp/TempHum
Geofence iCloud, Bluetooth & Wifi ping
Harmony hub, Nest

Logread
Posts: 204
Joined: Sunday 28 August 2016 7:48
Target OS: Raspberry Pi
Domoticz version:
Location: France
Contact:

Re: Python plugin: Battery Level for Z-Wave Devices

Post by Logread » Saturday 18 August 2018 10:02

heggink wrote:
Monday 13 August 2018 20:58
Plugin works great but sometimes, after changing batteries, the old battery level persists and does not get updated (not even after reboot). Thoughts?
The plugin reads the battery level from openzwave. Indeed openzwave sometimes takes time to update it. This is unrelated to the plugin.

multinet
Posts: 136
Joined: Friday 05 December 2014 23:52
Target OS: Raspberry Pi
Domoticz version:
Contact:

Re: Python plugin: Battery Level for Z-Wave Devices

Post by multinet » Monday 27 August 2018 8:53

Hello i have the same trouble (no battery update after changing them)

I change the battery 2 weeks ago, I think there is a pb in openzwave because indeed the openzwave xml file does not have the correct battery level
PI 2 - Domoticz 3.9208
RFXCOM - RFXtrx433 USB 433.92MHz Transceiver (5 DIO 54755 + 2 DIO 54756 + 3 DIO 54798)
Z-Wave.Me ZME_UZB1 USB Stick (6 FGSD002 + 2 FGRM222 + 1 FGS223 + 1 FGMS001-ZW5 + 1 FGRGBWM441 + 1 FGBS001 + 2 FGFS101)
6 sondes DS18B20

Martinq
Posts: 22
Joined: Wednesday 09 March 2016 18:20
Target OS: Linux
Domoticz version: 3.8153
Contact:

Re: Python plugin: Battery Level for Z-Wave Devices

Post by Martinq » Thursday 20 September 2018 13:55

Great plugin!!

Somehow Notifications are not working. In the Utility page I have a sensor with a battery level from 90%. So I made a notification like this:
Type: Usage
When: Less
Value: 81
Ignore Interval: Enabled

But no notifications.

Also tried to make a dzVents script, but no luck with it. It seems the Battery level from the plugin is in the sValue field. But I can't find how to extract this in dzVents. Tried it with this:

Code: Select all

return {
   on = {
      timer = {'Every minute'}
   },
   execute = function(domoticz)
      if (domoticz.devices('Battery - Deursensor Berging').sValue < 80) then
        domoticz.log(domoticz.devices('Battery - Deursensor Berging').sValue)
      end
   end
}
But this gives an error:

Code: Select all

Status: dzVents: Error (2.4.6): An error occured when calling event handler Testbat
Status: dzVents: Error (2.4.6): ...o/domoticz/scripts/dzVents/generated_scripts/Testbat.lua:6: attempt to compare nil with number
Status: dzVents: Info: ------ Finished Testbat
Somebody knows how to get notifications working with this plugin?

Logread
Posts: 204
Joined: Sunday 28 August 2016 7:48
Target OS: Raspberry Pi
Domoticz version:
Location: France
Contact:

Re: Python plugin: Battery Level for Z-Wave Devices

Post by Logread » Thursday 20 September 2018 18:41

@Martinq,

I remember reading somewhere (on the forum or on GitHub) that devices created by python plugins do not work well with notifications (or dzvents ?). Or possibly because these are « custom » type of devices that show the battery levels.

Anyway, there is a global setting in domoticz for low battery that works with notifications (I am using this). Alternatively you could write a script that polls the battery level devices for levels, at regular intervals ?

Martinq
Posts: 22
Joined: Wednesday 09 March 2016 18:20
Target OS: Linux
Domoticz version: 3.8153
Contact:

Re: Python plugin: Battery Level for Z-Wave Devices

Post by Martinq » Thursday 20 September 2018 20:10

I just got a notification from the sensors in Domoticz. Changed the When from Less to Less or Equal. Don't know why it was not working with only Less, but will wait a little bit longer.

The Low Battery function in the Domoticz settings doesn't work well. Many times the device battery is already empty without giving a warning. This script is the first one that gives the correct level. For instance I have a smoke detector. In Domoticz device page the battery level is still 100%. But in the zwcfxxxx.xml the level is 80%. So Domoticz still thinks the battery is full. Also when I check on the Nodes page the Control Page I see the level is 80%.

I am still trying to get the level in dzvents.

Martinq
Posts: 22
Joined: Wednesday 09 March 2016 18:20
Target OS: Linux
Domoticz version: 3.8153
Contact:

Re: Python plugin: Battery Level for Z-Wave Devices

Post by Martinq » Thursday 20 September 2018 21:19

Oke, got it working in both Notifications from the Custom Sensor as in the dzVents.

In dzVents you can use the .state attribute to get the Battery Level, like this:

Code: Select all

return {
   on = {
      timer = {'Every minute'}
   },
   execute = function(domoticz)
       local LEVEL = tonumber(domoticz.devices('Battery - Deursensor Berging').state)
       
      if (LEVEL < 95) then
        domoticz.log('Battery level Low!! Level = ' .. LEVEL)
      else
        domoticz.log('Battery Level = ' .. LEVEL)
      end

   end
}
It's important to use the "tonumber". State returns a string, otherwise you get an error: attempt to compare string with number

madvisionz
Posts: 8
Joined: Tuesday 25 September 2018 12:38
Target OS: NAS (Synology & others)
Domoticz version: 4.10007
Contact:

Re: Python plugin: Battery Level for Z-Wave Devices

Post by madvisionz » Sunday 21 October 2018 22:39

I can't get this plugin to work unfortunately.
I'm running Domoticz on Synology and the install commandlines doesn't work in Putty (in Windows) so I downloaded and copied the files with WinSCP to the BatteryLevel folder on my Syno manually, but I guess that isn't enough.

What am I missing here?

Domoticz 4.10007
DSM 6.2.1

Next day...Battery Monitoring still not visible in Hardware.

Logread
Posts: 204
Joined: Sunday 28 August 2016 7:48
Target OS: Raspberry Pi
Domoticz version:
Location: France
Contact:

Re: Python plugin: Battery Level for Z-Wave Devices

Post by Logread » Tuesday 23 October 2018 8:19

@madvisionz, I have no clue about where domoticz python plugins should reside in a synology install so difficult for me to assess if you chose the right location... do you successfully use other python plugins ?

Also, did you make the plugin.py file executable (sudo chmod +x plugin.py) ?

Last, did you restart domoticz ?

madvisionz
Posts: 8
Joined: Tuesday 25 September 2018 12:38
Target OS: NAS (Synology & others)
Domoticz version: 4.10007
Contact:

Re: Python plugin: Battery Level for Z-Wave Devices

Post by madvisionz » Tuesday 23 October 2018 21:16

@Logread, this is my first python plugin.. the location is /volume1/@appstore/domoticz/var/plugins. I created the "BatteryLevel" folder with mkdir and copied the files to this folder manually (apt-get and git clone isn't working). After that I did run the commandline to make plugin.py executable and restart Domoticz and Synology.

Also running Python 3.5.1.

Any ideas?

##Edit##
I installed another Domoticz incl. Python and now I can add the Battery Monitoring. Thx!! :D
No zwave devices found, but ok... we're getting somewhere.

dextm80
Posts: 134
Joined: Tuesday 24 October 2017 18:32
Target OS: Linux
Domoticz version: 4.10159
Contact:

Re: Python plugin: Battery Level for Z-Wave Devices

Post by dextm80 » Wednesday 14 November 2018 23:46

i've this error sometimes:

Code: Select all

 2018-11-14 12:13:24.602 Error: (Battery Level Zwave Devices) Ignoring controller ./Config/zwcfg_0xef422f8f.xml since presumed dead (not updated for more than 2 hours) 
can you help me ?
Domoticz on AsRock j3455-ITX 8gb ram - Aeotec ZWave Usb Stick - RFLink 433Mhz
1x Fibaro Wall Plug
1x Fibaro Motion Sensor
x NeoCoolcam Wall Plug
Netatmo Weather Station - Netatmo Thermostat
Philips Hue Bridge

Logread
Posts: 204
Joined: Sunday 28 August 2016 7:48
Target OS: Raspberry Pi
Domoticz version:
Location: France
Contact:

Re: Python plugin: Battery Level for Z-Wave Devices

Post by Logread » Thursday 15 November 2018 9:12

dextm80 wrote:
Wednesday 14 November 2018 23:46
i've this error sometimes:

Code: Select all

 2018-11-14 12:13:24.602 Error: (Battery Level Zwave Devices) Ignoring controller ./Config/zwcfg_0xef422f8f.xml since presumed dead (not updated for more than 2 hours) 
can you help me ?
If it is only from time to time then it is no big deal... It just means your zwave controller has not been updating its data for a while. Not sure why but I assume your zwave network does not poll devices that often.

Post Reply

Who is online

Users browsing this forum: No registered users and 0 guests