Battery Level Check Script

Post Reply
User avatar
Brutus
Posts: 322
Joined: Friday 26 September 2014 9:33
Target OS: Windows
Domoticz version:
Location: Heerlen, The Netherlands
Contact:

Battery Level Check Script

Post by Brutus » Thursday 23 November 2017 1:48

I have several Battery powered Fibaro Zwave devices. I would like to know when to change the battery in time before they run out of juice. So I used the "Alternate LUA script" as provided on the Wiki page: http://www.domoticz.com/wiki/Battery_le ... LUA_script

After inserting this in my Windows Domoticz environment and changing my email adres, Domoticz IP, json path, and the day and time so I can test the script at the given time it stops at line 30:

Code: Select all

for i,device in ipairs(devices.result) do
With error:

Code: Select all

2017-11-23 00:34:00.587 Error: EventSystem: in LUA-Batterij: [string "-- =========================================..."]:30: attempt to index global 'devices' (a nil value) 
Do I miss something?
1x Intel NUC D54250WYK (Windows 7 x64)
1x Aeon Labs USB Z-Stick S2
1x P1 Smart Meter USB
19x Fibaro Modules

BakSeeDaa
Posts: 551
Joined: Thursday 17 September 2015 10:13
Target OS: Raspberry Pi
Domoticz version:

Re: Battery Level Check Script

Post by BakSeeDaa » Thursday 23 November 2017 11:33

Brutus wrote:
Thursday 23 November 2017 1:48
Do I miss something?
I'd guess you haven't configured the script properly (Domoticz = "localhost" and DomoticzPort = "8080") or that you haven't configured "Local Networks (no username/password)" properly.

User avatar
emme
Posts: 854
Joined: Monday 27 June 2016 11:02
Target OS: Raspberry Pi
Domoticz version: latest
Location: Milano, Italy
Contact:

Re: Battery Level Check Script

Post by emme » Thursday 23 November 2017 12:17

I'm using the plugin ( viewtopic.php?t=17531 ) with no big problems
except that some devices are NOT sending the right information.... :P :P
The most dangerous phrase in any language is:
"We always done this way"

User avatar
Brutus
Posts: 322
Joined: Friday 26 September 2014 9:33
Target OS: Windows
Domoticz version:
Location: Heerlen, The Netherlands
Contact:

Re: Battery Level Check Script

Post by Brutus » Thursday 23 November 2017 20:44

BakSeeDaa wrote:
Thursday 23 November 2017 11:33
Brutus wrote:
Thursday 23 November 2017 1:48
Do I miss something?
I'd guess you haven't configured the script properly (Domoticz = "localhost" and DomoticzPort = "8080") or that you haven't configured "Local Networks (no username/password)" properly.
I have used several options:

Code: Select all

Domoticz = "192.168.1.5"
Domoticz = "localhost"
Domoticz = "login:password@192.168.1.5"
I also tested the link from the LUA script:

Code: Select all

http://192.168.1.5:8080/json.htm?type=devices&order=name
And that gives me this result in the browser:

Code: Select all

ActTime	1511462217
ServerTime	"2017-11-23 19:36:57"
Sunrise	"08:06"
Sunset	"16:38"
result	[…]
status	"OK"
title	"Devices"
So I think there is no problem with the ip address, port or authentication.
emme wrote:
Thursday 23 November 2017 12:17
I'm using the plugin ( viewtopic.php?t=17531 ) with no big problems
except that some devices are NOT sending the right information.... :P :P
I just installed this plugin successfully and added the corresponding devices. I'm going to monitor the levels for a couple of days.
1x Intel NUC D54250WYK (Windows 7 x64)
1x Aeon Labs USB Z-Stick S2
1x P1 Smart Meter USB
19x Fibaro Modules

Benneton
Posts: 30
Joined: Thursday 08 December 2016 10:46
Target OS: Raspberry Pi
Domoticz version:
Contact:

Re: Battery Level Check Script

Post by Benneton » Saturday 28 July 2018 14:52

Hi,

I installed this script yesterday and got this error message back:
2018-07-28 09:01:31.192 Error: EventSystem: in Batterij_check: /home/pi/domoticz/scripts/lua/JSON.lua:660: html passed to JSON:decode(): <html><head><title>Unauthorized</title></head><body><h1>401 Unauthorized</h1></body></html>

I have no idea what is not authorized in the script JSON.lua

For local Networks no password/user needed.
ohter seetings:
BatteryThreshold = 40
WeeklySummary = true
SummaryDay = 1 -- Sunday is 1
EmailTo = "xxxxx@xxxx.xx"
ReportHour = 9
ReportMinute = 01
Domoticz = "192.168.2.230"
DomoticzPort = "8080"
Message = ''

Domoticz version is 4.9700 stable.

Someone got any idea what I do wrong?

Bernard

Benneton
Posts: 30
Joined: Thursday 08 December 2016 10:46
Target OS: Raspberry Pi
Domoticz version:
Contact:

Re: Battery Level Check Script

Post by Benneton » Sunday 29 July 2018 12:05

Hi,

This morning I received 30 e-mails, 30 times the same stating:
"Flood sensor Keuken battery level is 95%"

Checked log and see 30 entries:
2018-07-29 09:01:02.623 Status: EventSystem: Script event triggered: Batterij_check
2018-07-29 09:01:03.808 Status: LUA: Flood sensor Keuken battery level is 95%

The Flood sensor is connected via- Z-wave

No entries in the Problem log.

What I miss my RFXCom sensors and HUE sensors.
2 Hue ones
7 RFXCom connected battery powered devices

Do I need to do something special to reveive notification for Hue and RFXCom?
Also why do I receive 30 mails for the 1 sensor? 1 message will be more then sufficient :)

Thanks for the support,
Bernard

Benneton
Posts: 30
Joined: Thursday 08 December 2016 10:46
Target OS: Raspberry Pi
Domoticz version:
Contact:

Re: Battery Level Check Script

Post by Benneton » Monday 30 July 2018 11:11

Hi,

And today, yet again 30 mails but now with 'encrypted' data:

----------------734275898421037446387058
Content-type: text/plain; charset=utf-8; format=flowed
Content-transfer-encoding: 7bit
X-CMAE-Envelope: MS4wfC7CWojMvysNEhSYBCX/oISiVqalFtnR+9ciMzbKgpc6V9DMdCrWCYMrWulJtKmCYWtnPOuVdwQMve2Tm1TIWUl1/0YWqOxPG5vApJl6j10oGpxi0t+r
2emTGn6u68SqxKSH/8pxUuKLq63wEb1b01GEVYLo0joaOiXGVa9NKtzz

No idea what I do wrong, some support greatly appreciated.

Bernard

Post Reply

Who is online

Users browsing this forum: atagesson and 3 guests