I found a Lua Script for Jamming detection.
This script gives me an Error.
Can someone help me with this.
Z-Wave usb stick has IDX=4
Virtual device = Jamming gedetecteerd
Ip adres Domoticz 192.168.1.28:8080 No password in local network
Error: EventSystem: in Jamming gedetecteerd: [string "commandArray = {}..."]:2: attempt to call a nil value/quote]
Code: Select all
commandArray = {} json = (loadfile "/domoticz/scripts/lua/JSON.lua")() local url = string.format("http://192.168.1.28:8080/json.htm?type=openzwavenodes&idx=4") url = string.format("%s %q", "curl", url) local zwavenodes=assert(io.popen(url)) local nodes = zwavenodes:read('*all') zwavenodes:close() local jsonZwave = json:decode(nodes) jammingdetected = false for i, zwavedevice in ipairs(jsonZwave['result']) do if (jsonZwave['result'][i]['PollEnabled'] == 'true') then s = jsonZwave['result'][i]['LastUpdate'] year = string.sub(s, 1, 4) month = string.sub(s, 6, 7) day = string.sub(s, 9, 10) hour = string.sub(s, 12, 13) minutes = string.sub(s, 15, 16) seconds = string.sub(s, 18, 19) t1 = os.time() t2 = os.time{year=year, month=month, day=day, hour=hour, min=minutes, sec=seconds} difference = (os.difftime (t1, t2)) if (difference > 60) then print('Mogelijke jamming! Z-wave product niet bereikbaar: ' .. jsonZwave['result'][i]['Description']) jammingdetected = true end end end if (jammingdetected == true and otherdevices['Jamming gedetecteerd'] == 'Off') then commandArray['Jamming gedetecteerd']='On' elseif (jammingdetected == false and otherdevices['Jamming gedetecteerd'] == 'On') then commandArray['Jamming gedetecteerd']='Off' end return commandArray/code]