Scripting problem with switch - Off works, on does not work

Moderator: leecollings

Post Reply
crashingdutchman
Posts: 21
Joined: Monday 05 December 2016 11:29
Target OS: Raspberry Pi / ODroid
Domoticz version: Latest
Contact:

Scripting problem with switch - Off works, on does not work

Post by crashingdutchman »

I have a problem with setting the On position of a virtual switch through a script (tvswitch.lua). The script is a very simple LUA script that contains the following commands (I am just debugging here):

Code: Select all

commandArray = {}
print("test")
return commandArray
If I remember well, I did a chmod 755 on the tvswitch.lua.

When I set the switch in the Off position, I see the following lines in my Domiticz log:
2019-01-07 15:56:17.632 (@Home) Light/Switch (Televisie woonkamer)
2019-01-07 15:56:17.603 Status: User: admin initiated a switch command (43/Televisie woonkamer/Off)
The print("test") is not visible here (I am not sure if I should expect it in the log-file) and it seems that the script ran fine. Now when I set the switch in the "On" possition I see the following:
2019-01-07 15:57:03.365 (@Home) Light/Switch (Televisie woonkamer)
2019-01-07 15:57:03.336 Status: User: admin initiated a switch command (43/Televisie woonkamer/On)
2019-01-07 15:57:03.344 Error: SQLHelper: Error script not found '/lua/tvswitch.lua'
Both the On and Off scripts are defined in the switch settings as below (note the 3 slashes)

Code: Select all

script:///lua/tvswitch.lua
I have also tried it with 2 slashes instead of 3 for the script On/Off-actions and this results in more or less a similar behavior, the only difference is that settings the switch in the "On" position results in the error below.
2019-01-07 15:59:30.103 Error: Error executing script command (/home/pi/domoticz/scripts/lua/tvswitchon.lua). returned: 512
What am I doing wrong? Should this work? Any help is appreciated!

I have been testing this with Domotics version 4.10303 (which is a beta I think)
User avatar
waaren
Posts: 6028
Joined: Tuesday 03 January 2017 14:18
Target OS: Linux
Domoticz version: Beta
Location: Netherlands
Contact:

Re: Scripting problem with switch - Off works, on does not work

Post by waaren »

crashingdutchman wrote: Monday 07 January 2019 16:04 I have a problem with setting the On position of a virtual switch through a script (tvswitch.lua). The script is a very simple LUA script
What am I doing wrong? Should this work? Any help is appreciated!
This is not how the event System in domoticz works. The use of scripts in On/ Off blocks of switches are meant for OS type of script and the event system is internal domoticz. Please have a look at events wiki first. It is a bit outdated but it should give you an idea.
Debian buster, bullseye on RPI-4, Intel NUC.
dz Beta, Z-Wave, RFLink, RFXtrx433e, P1, Youless, Hue, Yeelight, Xiaomi, MQTT
==>> dzVents wiki
crashingdutchman
Posts: 21
Joined: Monday 05 December 2016 11:29
Target OS: Raspberry Pi / ODroid
Domoticz version: Latest
Contact:

Re: Scripting problem with switch - Off works, on does not work

Post by crashingdutchman »

Okay, thank you very much. I switch to using a lua script from the events section. That solved it.
Post Reply

Who is online

Users browsing this forum: No registered users and 1 guest