My scripts writes a message to the log ánd turns on a switch (the same switch that triggered the action, but that is irrelevant as far as I can tell).
Code: Select all
return {
active = true,
on = {
devices = {
85 -- this is a switch for a lamp
}
},
execute = function(domoticz, roomSwitch)
if (roomSwitch.state == 'On') then
domoticz.log('Switch 85 has been turned on') -- write a message to the log
domoticz.devices[85].switchOn() -- switch a device on (the same device, actually)
end
end
}Code: Select all
2017-09-30 20:44:42.881 dzVents: Info: Handling events for: "Woonkamer schemerlamp (K1)", value: "On"
2017-09-30 20:44:42.881 dzVents: Info: ------ Start internal script: dztest: Device: "Woonkamer schemerlamp (K1) (RFXCOM zender)", Index: 85
2017-09-30 20:44:42.881 dzVents: Info: Switch 85 has been turned on
2017-09-30 20:44:42.881 Error: dzVents: Error: An error occured when calling event handler dztest
2017-09-30 20:44:42.881 Error: dzVents: Error: ...pi/domoticz/scripts/dzVents/generated_scripts/dztest.lua:11: attempt to index field 'devices' (a function value)
2017-09-30 20:44:42.881 dzVents: Info: ------ Finished dztest
If I try switching another devices too, or another call like 'domoticz.variables['anotherVar'].set(15)'.
Probably I'm overlooking something very obvious. Help would be greatly appreciated.
(Sidenote: What I actually intend to do is have every 'on-command' for a switch trigger a burst of 5 on-commands (with a small interval), so I can be quite sure that my switches actually receive the signal. Currently I do that my placing the switch in a Group, and adding the same switch to that group with delay 0, 1, 2, 3, 4.)