Page 1 of 1

Local variables

Posted: Monday 18 October 2021 20:07
by arjan93
Hello,

Im new with Lua programming and im trying to make a little script without the
user variables. Im looking for a solution with local variables.

An example of my code:

commandArray = {}

local variable = uservariables['WhatsappTimer']

if (otherdevices['Test schakelaar 1'] == 'On') then
variable = 1 AFTER 3 SECONDS
commandArray['Test schakelaar 1'] = 'Off'
end

if (variable == 1) then
commandArray['Test schakelaar 2'] = 'On'
variable = (0)
end

return commandArray

Is it possible to make a script like this without the uservariable WhatsappTimer?

Re: Local variables

Posted: Wednesday 20 October 2021 23:17
by jake
Instead of changing the variable to 1 after 3 seconds, why not simply switch the 2nd switch instead? Afterwards you can switch off switch 1.

When you are still learning lua, I'd advise you to use the domoticz dzvents for LUA. Much more straightforward than the original LUA scripting within domoticz.