Page 1 of 1
LUA Script not running, at all
Posted: Sunday 21 February 2016 14:33
by Eloque
I am trying to make a few simple lua scripts, but so far, I can't even get the simplest to run.
I've followed the instructions of renaming the demo scripts, but they never ever seem to trigger.
cat script_time_test.lua
Code: Select all
print('this will end up in the domoticz log')
and cat script_device_light.lua
Code: Select all
print('Light Test One')
commandArray = {}
if (devicechanged['Trap/Gang Licht'] == 'Off' then
commandArray['Trap/Gang Licht']='On'
end
return commandArray
Both never seem to run, nothing shows in the logs, no devices change state, nothing. Is there something I am missing?
Re: LUA Script not running, at all
Posted: Sunday 21 February 2016 14:48
by Holland
Are these placed in the directory? ; ~/domoticz/scripts/lua
Re: LUA Script not running, at all
Posted: Sunday 21 February 2016 16:33
by Eloque
Yes. Same place as the demo scripts were.
Re: LUA Script not running, at all
Posted: Sunday 21 February 2016 16:35
by jannl
Not sure if the '/' is allowed in the name of a switch
Re: LUA Script not running, at all
Posted: Sunday 21 February 2016 16:39
by NickHead
Try this:
My scripts are bracketed different.
May work, I am not an expert.
Code: Select all
print('Light Test One')
commandArray = {}
if (devicechanged['Trap/Gang Licht'] == 'Off') then
commandArray[1]={['Trap/Gang Licht']='On'}
end
return commandArray
Re: LUA Script not running, at all
Posted: Sunday 21 February 2016 17:17
by Eloque
Trying that now. I'd be happy if even the log line appears

Re: LUA Script not running, at all
Posted: Sunday 21 February 2016 17:17
by paulvha
does the script have the right permission?
Re: LUA Script not running, at all
Posted: Sunday 21 February 2016 17:26
by Eloque
Nope. Nothing. The scripts don't seem to get executed at all.
What permission should they have? I'll try chmod'ing them to 777 to try just in case.
Re: LUA Script not running, at all
Posted: Sunday 21 February 2016 17:29
by martijnhiemstra
When you create the file script_time_test.lua domoticz expects a device called test to exist. The file name system works like this:
script_time_devicename.lua
This by the way will execute the script every minute. If you want to execute the script on every change then rename the script to:
script_device_devicename.lua
Re: LUA Script not running, at all
Posted: Sunday 21 February 2016 17:38
by niceandeasy
Check your settings/other. Probably the event system is disabled.
Re: LUA Script not running, at all
Posted: Sunday 21 February 2016 17:47
by NickHead
Mine was called device_script_test.lua and i haven't got a switch called test.
It was to my belief that any script other than demo was run, the command being extracted
with the "devicechanged" section and acted upon.
Hence why I never included a filename.
As long as the device changed name is equal to the switch name ( as you said ) the script should act
accordingly.
Re: LUA Script not running, at all
Posted: Sunday 21 February 2016 17:49
by NickHead
As previously said:
Check Setup-Settings-Other, at the bottom is a Script-Enable/Disable Radio Button
Re: LUA Script not running, at all
Posted: Sunday 21 February 2016 17:54
by Eloque
NickHead, I found the setting, it was not disabled, blocky scripts are working btw.
I tried the old standby of turning it off and on again, and this showed up in the log;
Code: Select all
2016-02-21 17:52:27.160 EventSystem: Stopped...
2016-02-21 17:52:27.168 Active notification subsystems: (0/8)
2016-02-21 17:52:33.027 (RFXCOM) Temp + Humidity (Sensor Reinder)
2016-02-21 17:52:41.826 EventSystem: reset all events...
2016-02-21 17:52:41.826 EventSystem: reset all device statuses...
2016-02-21 17:52:41.826 EventSystem: Started
2016-02-21 17:52:41.828 Active notification subsystems: (0/8)
2016-02-21 17:52:47.661 (RFXCOM) Temp + Humidity (Sensor Woonkamer)
And the scripts don't trigger. I'll try renaming the file next.
Re: LUA Script not running, at all
Posted: Sunday 21 February 2016 17:59
by NickHead
MMM Strange.
I am going to leave it with you for now as I have to go to work.
I will look back in later.
Regards
Re: LUA Script not running, at all
Posted: Sunday 21 February 2016 18:00
by Siewert308SW
Are you on the latest beta?
if so, check the forum...

Re: LUA Script not running, at all
Posted: Sunday 21 February 2016 18:28
by niceandeasy
Indeed. I also discovered a bug in my system. Some things still work, some don't. Luckily, my lights are controlled by curl commands.
My time script gets triggered according to the log but it does not do anything.
(running newest beta)
Re: LUA Script not running, at all
Posted: Sunday 21 February 2016 19:19
by Eloque
About Domoticz
Version: 2.3029
Build Hash: 3b588dd
Compile Date: 2015-09-15 13:32:45
I'll try upgrading next.
Re: LUA Script not running, at all
Posted: Sunday 21 February 2016 22:42
by Eloque
Upgrading worked. Scripts run.
Re: LUA Script not running, at all
Posted: Sunday 21 February 2016 22:48
by Siewert308SW
Eloque wrote:Upgrading worked. Scripts run.
Upgrading to what version?
Re: LUA Script not running, at all
Posted: Sunday 21 February 2016 23:04
by Eloque
About Domoticz
Version: 2.4692
Build Hash: f42a1df
Compile Date: 2016-02-21 14:33:51
But, now Blocky scripts don't work at all

Also, I can't set my SmartWares radiators to a temp, the devices don't show up. I can do it manually via the webinterface, but not via scripts.