Python plugin: Battery Level for Z-Wave Devices

Python and python framework

Moderator: leecollings

User avatar
heggink
Posts: 972
Joined: Tuesday 08 September 2015 21:44
Target OS: Raspberry Pi / ODroid
Domoticz version: 12451
Location: NL
Contact:

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

Post by heggink »

Plugin works great but sometimes, after changing batteries, the old battery level persists and does not get updated (not even after reboot). Thoughts?
Docker in Truenas scale, close to latest beta
DASHTICZ 🙃
RFXCOM, zwavejs2mqtt, zigbee2mqtt,
P1 meter & solar panel
Google home, Wifi Cams motion detection
Geofence iCloud, Bluetooth & Wifi ping
Harmony hub, Nest, lots more :-)
Logread
Posts: 228
Joined: Sunday 28 August 2016 7:48
Target OS: Raspberry Pi / ODroid
Domoticz version:
Location: France
Contact:

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

Post by Logread »

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: 97
Joined: Friday 05 December 2014 22:52
Target OS: Raspberry Pi / ODroid
Domoticz version:
Contact:

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

Post by multinet »

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 2021.1
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: 19
Joined: Wednesday 09 March 2016 17:20
Target OS: Linux
Domoticz version: 3.8153
Contact:

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

Post by Martinq »

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: 228
Joined: Sunday 28 August 2016 7:48
Target OS: Raspberry Pi / ODroid
Domoticz version:
Location: France
Contact:

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

Post by Logread »

@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: 19
Joined: Wednesday 09 March 2016 17:20
Target OS: Linux
Domoticz version: 3.8153
Contact:

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

Post by Martinq »

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: 19
Joined: Wednesday 09 March 2016 17:20
Target OS: Linux
Domoticz version: 3.8153
Contact:

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

Post by Martinq »

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: 12
Joined: Tuesday 25 September 2018 12:38
Target OS: NAS (Synology & others)
Domoticz version: 4.10327
Contact:

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

Post by madvisionz »

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: 228
Joined: Sunday 28 August 2016 7:48
Target OS: Raspberry Pi / ODroid
Domoticz version:
Location: France
Contact:

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

Post by Logread »

@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: 12
Joined: Tuesday 25 September 2018 12:38
Target OS: NAS (Synology & others)
Domoticz version: 4.10327
Contact:

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

Post by madvisionz »

@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: 117
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 »

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: 228
Joined: Sunday 28 August 2016 7:48
Target OS: Raspberry Pi / ODroid
Domoticz version:
Location: France
Contact:

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

Post by Logread »

dextm80 wrote: Wednesday 14 November 2018 22: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: 117
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 »

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: 228
Joined: Sunday 28 August 2016 7:48
Target OS: Raspberry Pi / ODroid
Domoticz version:
Location: France
Contact:

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

Post by Logread »

dextm80 wrote: Monday 10 December 2018 18: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: 117
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 »

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: 228
Joined: Sunday 28 August 2016 7:48
Target OS: Raspberry Pi / ODroid
Domoticz version:
Location: France
Contact:

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

Post by Logread »

dextm80 wrote: Monday 10 December 2018 18: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: 117
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 »

Logread wrote: Monday 10 December 2018 21:23
dextm80 wrote: Monday 10 December 2018 18: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: 228
Joined: Sunday 28 August 2016 7:48
Target OS: Raspberry Pi / ODroid
Domoticz version:
Location: France
Contact:

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

Post by Logread »

dextm80 wrote: Monday 10 December 2018 21: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: 228
Joined: Sunday 28 August 2016 7:48
Target OS: Raspberry Pi / ODroid
Domoticz version:
Location: France
Contact:

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

Post by Logread »

Logread wrote: Monday 10 December 2018 22:38
dextm80 wrote: Monday 10 December 2018 21: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: 132
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 »

If it helps: I'm on beta 4.10267 and the battery plugin is working fine
Domoticz Latest β, RPi 4B with 110Gb SSD for Domoticz, RPi 4B with 110Gb SSD for Node-Red & a RPi 2B for logging / IP addressing. RFXCOM, PiZiGate, Z-Wave, Harmony, Hue lamps and a bit of Broadlink.
Post Reply

Who is online

Users browsing this forum: Amazon [Bot] and 1 guest