Page 1 of 1

Error with LUA script

Posted: Saturday 06 February 2016 11:38
by Roncalli
Hi all,

I am executing the following LUA script (created via the Domoticz HTML interface):

Code: Select all

commandArray = {}

if (devicechanged['Arm 1 partition'] == 'On') then
    if (otherdevices_svalues['Output:Anzeige S-intern'] == 'Off') then
        commandArray['Scene:AllesAus']='On'
        commandArray['Arbeitszimmer']='On'
        commandArray['Badezimmer']='On'
    end
end
return commandArray
and get the following error message:

"Error: EventSystem: in ExternScharf_AllesAus: [string "-- ..."]:28: attempt to index global 'devicechanged' (a nil value)"

Can anyone tell me what I am doing wrong?

Thanks! F.

Re: Error with LUA script

Posted: Saturday 06 February 2016 12:07
by jvdz
Did you mark this script as Time Event as in that case the whole devicechanged array won't be available?

Jos

Re: Error with LUA script

Posted: Saturday 06 February 2016 12:36
by gertlind1
Also, look at below.
viewtopic.php?f=23&t=9992

Re: Error with LUA script

Posted: Monday 08 February 2016 23:12
by Roncalli
Hi Jos,

Thanks for helping out again. I changed the script to device event. Now it works flawlessly.

Thanks :)
F.

Re: Error with LUA script

Posted: Sunday 14 February 2016 19:29
by Alle
jvdz wrote:Did you mark this script as Time Event as in that case the whole devicechanged array won't be available?

Jos
Maybe a stupid question, but how can you mark a script as Time Event? I have also have "'devicechanged' (a nil value)" in the log.

Re: Error with LUA script

Posted: Sunday 14 February 2016 19:35
by niceandeasy
The question is not stupid, it's just not necessary to ask. The answer is in the Domoticz wiki.
https://www.domoticz.com/wiki/Events chapter 2.