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: 211
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: 211
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: 211
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: 138
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: 211
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.

dextm80
Posts: 138
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 » Monday 10 December 2018 19:17

Hi @Logread, my plugin stopped his work! :(

Code: Select all

 2018-12-10 18:09:11.798 Error: (Battery Level ZWave) Error reading openzwave file ./Config/zwcfg_0xcc2f1a61.xml 

Code: Select all

 2018-12-10 18:10:21.726 Error: (Battery Level ZWave) Enable to find a zwave controller configuration file ! 
what appened?

tnx
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: 211
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 » Monday 10 December 2018 19:33

dextm80 wrote:
Monday 10 December 2018 19:17
Hi @Logread, my plugin stopped his work! :(

Code: Select all

 2018-12-10 18:09:11.798 Error: (Battery Level ZWave) Error reading openzwave file ./Config/zwcfg_0xcc2f1a61.xml 
Can you see the file in the Config directory ? Can you read it with a text editor ?
First time this error is reported (it could be a malformed xml format but this would be strange)...

dextm80
Posts: 138
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 » Monday 10 December 2018 19:37

yes it's into config directory and i'm reading it normally
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: 211
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 » Monday 10 December 2018 22:23

dextm80 wrote:
Monday 10 December 2018 19:37
yes it's into config directory and i'm reading it normally
Then it could be that since you are running a very recent beta the open wave config file format has changed ?
Did you successfully run the plugin with prior versions ? Did the plugin stop when you last upgraded ?

dextm80
Posts: 138
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 » Monday 10 December 2018 22:28

Logread wrote:
Monday 10 December 2018 22:23
dextm80 wrote:
Monday 10 December 2018 19:37
yes it's into config directory and i'm reading it normally
Then it could be that since you are running a very recent beta the open wave config file format has changed ?
Did you successfully run the plugin with prior versions ? Did the plugin stop when you last upgraded ?
yes, after 25 november 18 the plugin stops
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: 211
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 » Monday 10 December 2018 23:38

dextm80 wrote:
Monday 10 December 2018 22:28
yes, after 25 november 18 the plugin stops
You have to bear with me... just too busy to check what when wrong with recent Domoticz betas

Logread
Posts: 211
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 11 December 2018 12:31

Logread wrote:
Monday 10 December 2018 23:38
dextm80 wrote:
Monday 10 December 2018 22:28
yes, after 25 november 18 the plugin stops
You have to bear with me... just too busy to check what when wrong with recent Domoticz betas
dextm80, can you send your openzwave config file to me by pm (you might have to change its extension to .txt) ? I might then try to see if breaking changes have been Introduced recently.

alanlsmith
Posts: 124
Joined: Monday 07 August 2017 17:17
Target OS: Linux
Domoticz version: Latest β
Location: Near London (Saaarf!)
Contact:

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

Post by alanlsmith » Tuesday 11 December 2018 14:02

If it helps: I'm on beta 4.10267 and the battery plugin is working fine
Domoticz Latest β, Ubuntu 18.04 on Intel NUC i3, 8Gb ram, 70Gb drive, RFXtrx433, z-wave and a bit of Broadlink/Android

Post Reply

Who is online

Users browsing this forum: No registered users and 1 guest