for statement - I can't get it to work
Posted: Saturday 02 January 2021 15:44
Dear All,
First of all I want to wish everyone on this board a very good and healthy 2021.
I hope someone can help me with my problem that I don't get the " for i=x to y do" statement to work proper.
It gives me the following error
It would be appreciated when someone can help or guide me how to solve this problem.
Many thanks in advange.
First of all I want to wish everyone on this board a very good and healthy 2021.
I hope someone can help me with my problem that I don't get the " for i=x to y do" statement to work proper.
It gives me the following error
dzVents: Error: (3.0.2) ...s/dzVents/generated_scripts/SendCommandAgainAfterSec.lua:27: attempt to call a nil value
It would be appreciated when someone can help or guide me how to solve this problem.
Many thanks in advange.
Code: Select all
-- #SENDCOMMANDMULTIPLEAFTER SECONDS
local attempts = 20
return {
active = true,
on = {
devices = {
"Tuinlamp",
"Veranda",
"Kerst"
} -- add the list of devices you want to boost here
},
data = {
counter = {initial=0} -- initiate the counter to zero
},
execute = function(domoticz, currentSwitch) -- gives a burst of On/Off signals
if (currentSwitch.state == 'On') then
for i,attempts in counter do
-- for i in (counter:attempts) do
currentSwitch.switchOn().afterSec(i)
domoticz.log('Switch '..currentSwitch..' set SwitchOn after '.. i .. 'seconds', domoticz.LOG_INFO)
i=i+1
end
end
if (currentSwitch.state == 'Off') then
for i,attempts in counter do
currentSwitch.switchOff().afterSec(i)
domoticz.log('Switch '..currentSwitch..' set SwitchOff after '.. i .. 'seconds', domoticz.LOG_INFO)
i=i+1
end
end
end
}