Unknown error in script

Moderator: leecollings

Post Reply
User avatar
phoenixblue
Posts: 76
Joined: Friday 25 November 2016 11:20
Target OS: Windows
Domoticz version:
Contact:

Unknown error in script

Post 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?
User avatar
jvdz
Posts: 2269
Joined: Tuesday 30 December 2014 19:25
Target OS: Raspberry Pi / ODroid
Domoticz version: 4.107
Location: Netherlands
Contact:

Re: Unknown error in script

Post 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
New Garbage collection scripts: https://github.com/jvanderzande/GarbageCalendar
User avatar
phoenixblue
Posts: 76
Joined: Friday 25 November 2016 11:20
Target OS: Windows
Domoticz version:
Contact:

Re: Unknown error in script

Post by phoenixblue »

Hi,

That is correct, I run it inside of Domoticz.
But also runs it as an "Time" event.
User avatar
jvdz
Posts: 2269
Joined: Tuesday 30 December 2014 19:25
Target OS: Raspberry Pi / ODroid
Domoticz version: 4.107
Location: Netherlands
Contact:

Re: Unknown error in script

Post by jvdz »

Ok... Then you can't use the table devicechanged as that is only provided with device event scripts!

Jos
New Garbage collection scripts: https://github.com/jvanderzande/GarbageCalendar
User avatar
phoenixblue
Posts: 76
Joined: Friday 25 November 2016 11:20
Target OS: Windows
Domoticz version:
Contact:

Re: Unknown error in script

Post 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.
User avatar
jvdz
Posts: 2269
Joined: Tuesday 30 December 2014 19:25
Target OS: Raspberry Pi / ODroid
Domoticz version: 4.107
Location: Netherlands
Contact:

Re: Unknown error in script

Post by jvdz »

I can help when you show what you have and explain what you like it to do. ;)
New Garbage collection scripts: https://github.com/jvanderzande/GarbageCalendar
User avatar
phoenixblue
Posts: 76
Joined: Friday 25 November 2016 11:20
Target OS: Windows
Domoticz version:
Contact:

Re: Unknown error in script

Post 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.
User avatar
jvdz
Posts: 2269
Joined: Tuesday 30 December 2014 19:25
Target OS: Raspberry Pi / ODroid
Domoticz version: 4.107
Location: Netherlands
Contact:

Re: Unknown error in script

Post 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
New Garbage collection scripts: https://github.com/jvanderzande/GarbageCalendar
Post Reply

Who is online

Users browsing this forum: No registered users and 1 guest