Quick question. I am very new to LUA and dzVents. I have a simple script generating a classic nil value error but I just cannot get why I have this error ...
Basically, when my squeezebox is playing, it switches on a sonoff connected to my subwoofer.
Script :
Code: Select all
return {
active = true, -- set to false to disable this script
on = {
devices = {
-- scripts is executed if the device that was updated matches with one of these triggers
368, -- id Squeezebox
},
},
execute = function(domoticz, device)
local caisson = domoticz.devices(527) -- sonoff caisson
local musique = domoticz.devices('Squeezebox')
if (device.state == 'Off') then
caisson.switchOff()
elseif (device.state == 'Stopped') then
caisson.switchOff().after_min(10)
musique.switchOff().after_min(10)
else
caisson.switchOn()
end
end
}
switchOff too
From the log :
Code: Select all
2017-09-07 08:12:33.083 dzVents: Info: ------ Start internal script: Caisson_Musique: Device: "Squeezebox (Logitech Media Server)", Index: 368
2017-09-07 08:12:33.083 Error: dzVents: Error: An error occured when calling event handler Caisson_Musique
2017-09-07 08:12:33.083 Error: dzVents: Error: ...cz/scripts/dzVents/generated_scripts/Caisson_Musique.lua:40: attempt to call field 'after_min' (a nil value)
2017-09-07 08:12:33.083 dzVents: Info: ------ Finished Caisson_Musique
