I got this error on this script, is someone can help me ?
2017-02-19 22:00:00.128 Error: EventSystem: in script_device_cube.lua: [string "-- script_device_cube.lua..."]:5: attempt to index global 'devicechanged' (a nil value)
=> 2017-02-20 18:16:37.635 Error: EventSystem: in /home/pi/domoticz/scripts/lua/script_device_porte2.lua: /home/pi/domoticz/scripts/lua/script_device_porte2.lua:6: bad argument #1 to 'sub' (string expected, got nil)
Thank you !
Code: Select all
-- script_device_porte2.lua
function lastSeen(device)
t1 = os.time()
s = otherdevices_lastupdate[device]
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)
t2 = os.time{year=year, month=month, day=day, hour=hour, min=minutes, sec=seconds}
return (os.difftime (t1, t2))
end
commandArray = {}
local porteOverte = devicechanged['Xiaomi Door Sensor'] == 'Open'
local pieceVide = lastSeen('Motion entrée') > '5' and lastSeen('Motion Salon') > '5'
local pieceNoire = otherdevices['Lux Salon'] < '10' and otherdevices['Lux entrée'] < '10'
if (porteOuverte and pieceVide and pieceNoire) then
commandArray['Scene Détente'] = "on"
end
return commandArray