Scripts not being triggered

Moderator: leecollings

Post Reply
theplayer777
Posts: 2
Joined: Tuesday 21 March 2017 23:13
Target OS: Raspberry Pi / ODroid
Domoticz version:
Contact:

Scripts not being triggered

Post by theplayer777 »

Hello,

I have some troubles using lua scripts. They aren't working at all, whatever I write. For example here with a dummy switch named "dummy":

commandArray = {}
if (otherdevices['dummy'] == 'On') then
print ("Hello world")
end
return commandArray

nothing happen when I switch on/off my device. I already asked big G about my problem, and was able to exclude some of the common issues:
- scripts are in the right folder with right rights
- EventSystem is enabled in Domoticz

I don't really know what to do now, as nothing seems to be logged except "normal" logs...

Here is my configuration:
- Domoticz V3.5877
- Linux raspberrypi 4.4.50-v7+

Thanks in advance for your help
simonrg
Posts: 329
Joined: Tuesday 16 July 2013 22:54
Target OS: Raspberry Pi / ODroid
Domoticz version: 3.8807
Location: North East England
Contact:

Re: Scripts not being triggered

Post by simonrg »

theplayer777 wrote:

Code: Select all

commandArray = {}
if (otherdevices['dummy'] == 'On') then
   print ("Hello world")
end
return commandArray
Not sure what is causing your problem is, but a few thoughts.

You are currently using otherdevices, you should use devicechanged instead, otherwise when triggering does work then it would print everytime any device changes and dummy is on, not just when the device changes.

Do you have any other devices apart from dummy?

If you create this script then it will print into the log every time any device changes:

Code: Select all

-- /home/pi/domoticz/scripts/lua/script_device_allprint.lua
commandArray = {}
print("Hello world")
return commandArray
Your script with deviceChanged - should print into the log only when dummy is switched on

Code: Select all

-- /home/pi/domoticz/scripts/lua/script_device_dummyprint.lua
commnadArray = {}
if devicechanged['dummy'] == 'On' then
    print("Hello world")
end
return commandArray
How are you switching the dummy switch? There are some differences with dummy switches and triggering scripts, have a search in the forum to get the details.
Raspberry Pi 2 B - 2A@5V PSU - Raspbian + Domoticz + RFXtrx(89), LightwaveRF House(dimmers, sockets, wireless/mood switches), Owl CM113, 4 LaCross Temp / Humidity Sensors, 4 Siemens PIR, Smappee, Solaredge, ESP8266
theplayer777
Posts: 2
Joined: Tuesday 21 March 2017 23:13
Target OS: Raspberry Pi / ODroid
Domoticz version:
Contact:

Re: Scripts not being triggered

Post by theplayer777 »

Thank you for you reply,

I add this dummy switch just to do some testing, but I also tried the same script with another device (door detection) but with the same result. I'm switching the dummy device manually. Nothing special about that, it's just a "default" dummy switch on/off device.

I tried both of your scripts and... I have to say I don't understand why but the 2nd one is working well (even with my dummy device) but the first one isn't doing anything, as expected.... crazy !
simonrg
Posts: 329
Joined: Tuesday 16 July 2013 22:54
Target OS: Raspberry Pi / ODroid
Domoticz version: 3.8807
Location: North East England
Contact:

Re: Scripts not being triggered

Post by simonrg »

The first script may just be firing too often and the print is just getting lost.

You could try this version instead, switch off your dummy switch and then create this script

Code: Select all

-- /home/pi/domoticz/scripts/lua/script_device_allturndummyon.lua
commandArray = {}
commandArray['dummy'] = 'On'
return commandArray
Hopefully dummy should now be turned on.

The second script is the version you want to use anyway, with devicechanged doing the triggering.
Raspberry Pi 2 B - 2A@5V PSU - Raspbian + Domoticz + RFXtrx(89), LightwaveRF House(dimmers, sockets, wireless/mood switches), Owl CM113, 4 LaCross Temp / Humidity Sensors, 4 Siemens PIR, Smappee, Solaredge, ESP8266
Post Reply

Who is online

Users browsing this forum: No registered users and 1 guest