Page 1 of 1

Unknown error in script

Posted: Wednesday 17 June 2020 18:08
by phoenixblue
Hi,

I have (not) yet experience with LUA scripting so I have made the next script to send serval time an command over the night to an push dummy for the ventilation that use an internal timer.

Code: Select all

commandArray = {}
if (devicechanged['Ventilatie hoog'] == 'On') then
   commandArray['Ventilatie']='Set Level: 30 REPEAT 20 INTERVAL 840'
elseif (devicechanged['Ventilatie hoog'] == 'Off') then
   commandArray['Ventilatie']='Set Level: 10' 
return commandArray

But I get in the log file from this script the next error:

Code: Select all

2020-06-17 17:55:00.596 Error: EventSystem: in Ventilatie nacht: [string "commandArray = {} ..."]:2: attempt to index a nil value (global 'devicechanged')
The script works only this error I can not solve.

How can I solve this problem?

Re: Unknown error in script

Posted: Wednesday 17 June 2020 18:39
by jvdz
That's a common asked question. ;)
Just make sure it only triggers on time events by making a change on the script menu. (Assuming this is an internal LUA event script)

Jos

Re: Unknown error in script

Posted: Wednesday 17 June 2020 18:55
by phoenixblue
Hi,

That is correct, I run it inside of Domoticz.
But also runs it as an "Time" event.

Re: Unknown error in script

Posted: Wednesday 17 June 2020 19:00
by jvdz
Ok... Then you can't use the table devicechanged as that is only provided with device event scripts!

Jos

Re: Unknown error in script

Posted: Wednesday 17 June 2020 21:59
by phoenixblue
Ok, I will try to made the script in a other solution that will do the same. I'm hope that this error will not be shown on the log.

Re: Unknown error in script

Posted: Wednesday 17 June 2020 22:05
by jvdz
I can help when you show what you have and explain what you like it to do. ;)

Re: Unknown error in script

Posted: Wednesday 17 June 2020 22:20
by phoenixblue
I have an switch selector ( ventilatie) where status 10 is auto, 20 is low, 30 is med, 40 is high.

Because the fan has an internal timer that I can reset when I send an new (same) status so I can let run the fan continue.

So I want when the dummy switch manual on (Ventilatie hoog) that the script is send every 840 sec an pulse to the switch selector so the timer reset to the start countdown time.
And that for example 20 times, or when the switch manual on is set to off.

Re: Unknown error in script

Posted: Wednesday 17 June 2020 22:50
by jvdz
I do something similar with an ITHO central ventilationbox and also use a dummy selector switch:
10=low; 20=med; 30=high; 40=timer1; 50=timer2; 60=timer3
I use an ESP connected to Domoticz to be able to send commands from Domoticz to the ITHO and also record commands send from the standard remote to update Domoticz. Challenge of course is not to create a deadlock (endless looping commands being send & received)

so ... it really all depends on how you set the switch currently before I can give any suggestion on your request.
Do you also use the selector switch to set the ventilator with a script?
How do you set the ventilator speed from Domoticz and possible manual with a remote?

Jos