Page 1 of 1

Lua scripts not called

Posted: Sunday 15 November 2015 21:19
by mwpnl
Hi,

I'm running domoticz v2.3598 on CentOs 7.1. I've just started exploring the functionality of lua scripts, but am running into a problem: the lua script doesn't seem to be called.

I've created the following file: /opt/domoticz/scripts/lua/script_time_blaat.lua with the following content:

Code: Select all

print('script loaded')
commandArray = {}
return commandArray
My expectation was that, every minute, a log entry in domoticz would appear (Setup->Log). But this is not the case, the only lines related to the EventSystem are the following:

Code: Select all

2015-11-15 21:07:01.972 EventSystem: reset all device statuses...
2015-11-15 21:07:01.972 EventSystem: Started
Am I missing something trivial here?
I've checked the permissions on both the file and underlying folders, but can't seem to find anything out of the ordinary (owned by the daemon user+group, -rwxr--r--)

Re: Lua scripts not called

Posted: Sunday 15 November 2015 21:30
by jvdz
That is indeed what should happen.
You do have the option in Setup/Setting/Other for EventSystem (Lua/Blockly/Scripts): Disabled: deselected?

Jos

Re: Lua scripts not called

Posted: Sunday 15 November 2015 21:36
by mwpnl
jvdz wrote:That is indeed what should happen.
You do have the option in Setup/Setting/Other for EventSystem (Lua/Blockly/Scripts): Disabled: deselected?

Jos
Yeah, sorry, I indeed have that checkbox unchecked in the settings dialog. Apart from that, I couldn't find any place with instructions.
I've also renamed the lua file to _device_, to see what would happen. But nothing happens then either, no matter how many switches I push :lol:

Re: Lua scripts not called

Posted: Sunday 15 November 2015 21:41
by jvdz
Have you tried just to run the script from a console session to ensure lua is properly installed?

Jos

Re: Lua scripts not called

Posted: Sunday 15 November 2015 21:50
by mwpnl
Affirmative. Running the script (lua script_time_blaat.lua) from the user-context (su domoticz) prints the line of text perfectly in the command-line.

Re: Lua scripts not called

Posted: Sunday 15 November 2015 21:57
by jvdz
All sounds like it should be. Remember one member having issues with this as well and to fix it for him he had to locate the scripts is:
/volume1/@appstore/domoticz/var/scripts/lua/

Maybe something to check, but other that that I am out of ideas.

Jos

Re: Lua scripts not called

Posted: Sunday 15 November 2015 22:37
by mwpnl
I've just did some debugging on the EventSystem.cpp file, and discovered what was wrong.

I'm using the XFS filesystem, and as it turns out, d_type never returns the correct value with XFS (source).
Since the d_type is used in EventSystem.cpp to differentiate between real files and directories, all valid lua-files are ignored.

I've made a few changes into the EventSystem.cpp, to use stat instead of d_type, and now it works like a charm!

Thanks so much for your help Jos!