Script execution : nothing happens Topic is solved
Moderator: leecollings
Script execution : nothing happens
Hi,
I have called the lua script through a dummy device, but nothing happens. I use a simple script found in the /script/lua/script_device_demo.lua
2017-03-10 09:20:08.826 (Dummy) Light/Switch (Selector)
2017-03-10 09:20:10.111 Executing script: scripts\lua\script_device_demo.lua
It should appear a text (print('this will end up in the domoticz log')) at least.
I'm running domoticz on windows 7.
---------
note : before, I have associated .lua with sublime text, and when domoticz executed script: scripts\lua\script_device_demo.lua. Sublime text open the lua file. I removed this link, but I didn't get any improvement.
Could you help, please.
I have called the lua script through a dummy device, but nothing happens. I use a simple script found in the /script/lua/script_device_demo.lua
2017-03-10 09:20:08.826 (Dummy) Light/Switch (Selector)
2017-03-10 09:20:10.111 Executing script: scripts\lua\script_device_demo.lua
It should appear a text (print('this will end up in the domoticz log')) at least.
I'm running domoticz on windows 7.
---------
note : before, I have associated .lua with sublime text, and when domoticz executed script: scripts\lua\script_device_demo.lua. Sublime text open the lua file. I removed this link, but I didn't get any improvement.
Could you help, please.
-
- Posts: 7
- Joined: Thursday 03 November 2016 11:53
- Target OS: Raspberry Pi / ODroid
- Domoticz version: beta
- Location: Netherlands
- Contact:
Re: Script execution : nothing happens
If you want to run scripts as on or off action, you need to start the command line with
script://
in your case, the command would look as follows:
script:///home/pi/domoticz/scripts/lua/script_device_demo.lua
I am not sure if you can execute lua scripts directly. If not, your command should look like:
script:///usr/bin/lua /home/pi/domoticz/scripts/lua/script_device_demo.lua
Keep in mind that when running LUA scripts from the command line (this is what you are actually doing here), you don't have access to the domoticz DB using commands such as otherdevices, otherdevices_svalues, etc. If you'd want to access Domoticz status, variables, etc. from a commandline, you have to revert to HTTP requests and processing the JSON return value.
script://
in your case, the command would look as follows:
script:///home/pi/domoticz/scripts/lua/script_device_demo.lua
I am not sure if you can execute lua scripts directly. If not, your command should look like:
script:///usr/bin/lua /home/pi/domoticz/scripts/lua/script_device_demo.lua
Keep in mind that when running LUA scripts from the command line (this is what you are actually doing here), you don't have access to the domoticz DB using commands such as otherdevices, otherdevices_svalues, etc. If you'd want to access Domoticz status, variables, etc. from a commandline, you have to revert to HTTP requests and processing the JSON return value.
-
- Posts: 230
- Joined: Friday 03 April 2015 20:44
- Target OS: Raspberry Pi / ODroid
- Domoticz version:
- Location: Germany (near dutch border)
- Contact:
Re: Script execution : nothing happens
Hi, change the name of the script without the word "demo" ...this "demo" prevents the eventsystem from executing the script..
Cheers,Hans
Cheers,Hans
Re: Script execution : nothing happens
Because i'm running Domoticz on windows, I assume that the command look like :
script://scripts\lua\nameofscript.lua
(found on a french forum : https://easydomoticz.com/domoticz-et-wi ... ction_off/)
I removed the _demo suffix. But I did not get any improvement.
Thank you for your help.
script://scripts\lua\nameofscript.lua
(found on a french forum : https://easydomoticz.com/domoticz-et-wi ... ction_off/)
I removed the _demo suffix. But I did not get any improvement.


Thank you for your help.
- jvdz
- Posts: 2269
- Joined: Tuesday 30 December 2014 19:25
- Target OS: Raspberry Pi / ODroid
- Domoticz version: 4.107
- Location: Netherlands
- Contact:
Re: Script execution : nothing happens
It looks like the script is ran, which you could easily check by writing a line to a log file in your script.
What is the script supposed to do that doesn't happen? Maybe show the script?
This means the script is properly named and put in the LUA subdirectory. Only then you will have all defined Tables available as described in the Event Wiki.
Jos
What is the script supposed to do that doesn't happen? Maybe show the script?
Why do you expect this? I don't think this will work that way and only happen when you use the buildin event handler of Domotics!It should appear a text (print('this will end up in the domoticz log')) at least.
This means the script is properly named and put in the LUA subdirectory. Only then you will have all defined Tables available as described in the Event Wiki.
Jos
New Garbage collection scripts: https://github.com/jvanderzande/GarbageCalendar
Re: Script execution : nothing happens
Code: Select all
print('this will end up in the domoticz log')
commandArray = {}
if (devicechanged['MyDeviceName'] == 'On' and otherdevices['MyOtherDeviceName'] == 'Off') then
commandArray['MyOtherDeviceName']='On'
end
return commandArray
I call the script through the switch dummy device as it :

So, if I understand wright, Lua script can not be executed this way and have to be called from the event handler ?
- jvdz
- Posts: 2269
- Joined: Tuesday 30 December 2014 19:25
- Target OS: Raspberry Pi / ODroid
- Domoticz version: 4.107
- Location: Netherlands
- Contact:
Re: Script execution : nothing happens
Correct, so simply remove the lines in the ON/Off action and things should still be ran by the internal event system as explained in the WikI: https://www.domoticz.com/wiki/Events
Jos
Jos
New Garbage collection scripts: https://github.com/jvanderzande/GarbageCalendar
Re: Script execution : nothing happens
I change the switch type to "selector"
So, I ran the script for the event manager and the script work. But not only the event script but also the one in action.
Then, I have deleted the script in the event manager and let the script in the action in place as describe in : https://forum.mysensors.org/topic/4933/ ... tutorial/2
Here is the action place on level 3 :
script://scripts\lua\script_device_try.lua
Here is the script :
Here is the log
As you can see, the script is called whatever level I selected (the log display the print(...) place in the script). When I call the level3, this time, I get a additionnal line : Executing script: scripts\lua\script_device_try.lua
Why are the "LUA: this will end up in the domoticz log" appear even if the script is not called on this level ?
So, I ran the script for the event manager and the script work. But not only the event script but also the one in action.
Then, I have deleted the script in the event manager and let the script in the action in place as describe in : https://forum.mysensors.org/topic/4933/ ... tutorial/2
Here is the action place on level 3 :
script://scripts\lua\script_device_try.lua
Here is the script :
Code: Select all
print('this will end up in the domoticz log')
commandArray = {}
return commandArray
Code: Select all
2017-03-10 12:18:38.872 User: Admin initiated a switch command (9/Selector/Set Level)
2017-03-10 12:18:38.907 LUA: this will end up in the domoticz log
2017-03-10 12:18:38.872 (Dummy) Light/Switch (Selector)
2017-03-10 12:18:41.188 User: Admin initiated a switch command (9/Selector/Set Level)
2017-03-10 12:18:41.298 LUA: this will end up in the domoticz log
2017-03-10 12:18:41.188 (Dummy) Light/Switch (Selector)
2017-03-10 12:18:42.962 User: Admin initiated a switch command (9/Selector/Set Level)
2017-03-10 12:18:43.111 LUA: this will end up in the domoticz log
2017-03-10 12:18:42.978 (Dummy) Light/Switch (Selector)
2017-03-10 12:18:44.908 User: Admin initiated a switch command (9/Selector/Set Level)
2017-03-10 12:18:44.991 LUA: this will end up in the domoticz log
2017-03-10 12:18:44.908 (Dummy) Light/Switch (Selector)
2017-03-10 12:18:46.206 Executing script: scripts\lua\script_device_try.lua
2017-03-10 12:18:46.942 User: Admin initiated a switch command (9/Selector/Set Level)
2017-03-10 12:18:46.980 LUA: this will end up in the domoticz log
2017-03-10 12:18:46.942 (Dummy) Light/Switch (Selector)
Why are the "LUA: this will end up in the domoticz log" appear even if the script is not called on this level ?
- jvdz
- Posts: 2269
- Joined: Tuesday 30 December 2014 19:25
- Target OS: Raspberry Pi / ODroid
- Domoticz version: 4.107
- Location: Netherlands
- Contact:
Re: Script execution : nothing happens
Since this script is a Device script, it will be ran whenever any of your devices have a change of the status.
So the first thing to do is to ensure your device script's logic is only executed when the appropriate device has changed.
Just read all about it in the event wiki I pointed you to.
Jos
So the first thing to do is to ensure your device script's logic is only executed when the appropriate device has changed.
Just read all about it in the event wiki I pointed you to.
Jos
New Garbage collection scripts: https://github.com/jvanderzande/GarbageCalendar
Re: Script execution : nothing happens
Ok,
Thank you for you help !
Thank you for you help !
Who is online
Users browsing this forum: No registered users and 1 guest