Scene triggers unwanted a LUA script

Moderator: leecollings

Post Reply
mischa
Posts: 74
Joined: Tuesday 07 April 2015 20:32
Target OS: Raspberry Pi / ODroid
Domoticz version: 3.8872
Location: Heerhugowaard, The Netherlands
Contact:

Scene triggers unwanted a LUA script

Post by mischa »

I have the following script which set on a light based on the dim value of another light. see below

Code: Select all

commandArray = {}
if (otherdevices_svalues['Overloop 1e etage'] > '10' and otherdevices['Trap'] == 'Off') then
	commandArray['Trap']='Set Level 1'
	elseif 
	(devicechanged['Overloop 1e etage'] == 'Off') then
	commandArray['Trap']='Off'
end

return commandArray
I also have made a "all off" scene with a timer which set all my lights off, but somehow this scene triggers the script above and set the ['Trap'] lights to level 1

I don't understand why this happens, can anyone point me in a direction.

Thanks,

Mischa
Pi 2 - Pi 1 - Razzbery 2.0 - Fibaro FGD-211 - Fibaro FGD-212 - Fibaro FGRGBWM-441 (RGBW Module) - Fibaro FGBS321 (Universal Switch) - FGWPF-102 - TBK Home TZ67-G - Synology DS1515+ - Esp Easy (with wemos D1 mini)
User avatar
Westcott
Posts: 423
Joined: Tuesday 09 December 2014 17:04
Target OS: Raspberry Pi / ODroid
Domoticz version: Beta
Location: UK - Glos
Contact:

Re: Scene triggers unwanted a LUA script

Post by Westcott »

Should it be -
if (tonumber(otherdevices_svalues['Overloop 1e etage']) > 10 and ...
Zwave - Sigma Z+ stick, Fibaro, Horstmann, Neo Coolcam, EUROtronic
RFlink - IR detectors and temperatures
Wifi - YeeLights, ESP32s, Anoop sockets
Zigbee - lots with zigbee2mqtt and ZbBridge
mischa
Posts: 74
Joined: Tuesday 07 April 2015 20:32
Target OS: Raspberry Pi / ODroid
Domoticz version: 3.8872
Location: Heerhugowaard, The Netherlands
Contact:

Re: Scene triggers unwanted a LUA script

Post by mischa »

Westcott wrote:Should it be -
if (tonumber(otherdevices_svalues['Overloop 1e etage']) > 10 and ...
This is also working, but my scene still triggers the LUA script.

Don't think it matters using tonumber or the string value, as far as i know the svalues are stored as a string variable.
Pi 2 - Pi 1 - Razzbery 2.0 - Fibaro FGD-211 - Fibaro FGD-212 - Fibaro FGRGBWM-441 (RGBW Module) - Fibaro FGBS321 (Universal Switch) - FGWPF-102 - TBK Home TZ67-G - Synology DS1515+ - Esp Easy (with wemos D1 mini)
User avatar
Dnpwwo
Posts: 820
Joined: Sunday 23 March 2014 9:00
Target OS: Raspberry Pi / ODroid
Domoticz version: Beta
Location: Melbourne, Australia
Contact:

Re: Scene triggers unwanted a LUA script

Post by Dnpwwo »

When a device value is set Domoticz will call 'device' scripts one after the other so if your Scene sets a device state your script will be called. This is expected behavior.

You need to extend your logic to make it only work when you want it to. Something like:

Code: Select all

commandArray = {}
if (devicechanged['Overloop 1e etage'] ~= nil) then
  if (otherdevices_svalues['Overloop 1e etage'] > '10' and otherdevices['Trap'] == 'Off') then
     commandArray['Trap']='Set Level 1'
     elseif 
     (devicechanged['Overloop 1e etage'] == 'Off') then
     commandArray['Trap']='Off'
  end
end
return commandArray
The reasonable man adapts himself to the world; the unreasonable one persists to adapt the world to himself. Therefore all progress depends on the unreasonable man. George Bernard Shaw
mischa
Posts: 74
Joined: Tuesday 07 April 2015 20:32
Target OS: Raspberry Pi / ODroid
Domoticz version: 3.8872
Location: Heerhugowaard, The Netherlands
Contact:

Re: Scene triggers unwanted a LUA script

Post by mischa »

So if I do not check the device state (as I did in my script) the script will be executed when another device state is changed. Am I understand this correctly?
Pi 2 - Pi 1 - Razzbery 2.0 - Fibaro FGD-211 - Fibaro FGD-212 - Fibaro FGRGBWM-441 (RGBW Module) - Fibaro FGBS321 (Universal Switch) - FGWPF-102 - TBK Home TZ67-G - Synology DS1515+ - Esp Easy (with wemos D1 mini)
mischa
Posts: 74
Joined: Tuesday 07 April 2015 20:32
Target OS: Raspberry Pi / ODroid
Domoticz version: 3.8872
Location: Heerhugowaard, The Netherlands
Contact:

Re: Scene triggers unwanted a LUA script

Post by mischa »

@Dnpwwo If i try your script I get the same behavior when scene is activated, deleted the scene and added again. But still the same behavior.
only my ['Trap'] lights are witched on, the are on a Fibaro RGB module.
Pi 2 - Pi 1 - Razzbery 2.0 - Fibaro FGD-211 - Fibaro FGD-212 - Fibaro FGRGBWM-441 (RGBW Module) - Fibaro FGBS321 (Universal Switch) - FGWPF-102 - TBK Home TZ67-G - Synology DS1515+ - Esp Easy (with wemos D1 mini)
jannl
Posts: 673
Joined: Thursday 02 October 2014 6:36
Target OS: Raspberry Pi / ODroid
Domoticz version: 2022.2
Location: Geleen
Contact:

Re: RE: Re: Scene triggers unwanted a LUA script

Post by jannl »

mischa wrote:So if I do not check the device state (as I did in my script) the script will be executed when another device state is changed. Am I understand this correctly?
Correct
mischa
Posts: 74
Joined: Tuesday 07 April 2015 20:32
Target OS: Raspberry Pi / ODroid
Domoticz version: 3.8872
Location: Heerhugowaard, The Netherlands
Contact:

Re: RE: Re: Scene triggers unwanted a LUA script

Post by mischa »

jannl wrote:
mischa wrote:So if I do not check the device state (as I did in my script) the script will be executed when another device state is changed. Am I understand this correctly?
Correct
Why is it then that only this scene triggers my script and every other device change does not?
Pi 2 - Pi 1 - Razzbery 2.0 - Fibaro FGD-211 - Fibaro FGD-212 - Fibaro FGRGBWM-441 (RGBW Module) - Fibaro FGBS321 (Universal Switch) - FGWPF-102 - TBK Home TZ67-G - Synology DS1515+ - Esp Easy (with wemos D1 mini)
jannl
Posts: 673
Joined: Thursday 02 October 2014 6:36
Target OS: Raspberry Pi / ODroid
Domoticz version: 2022.2
Location: Geleen
Contact:

Re: Scene triggers unwanted a LUA script

Post by jannl »

Every device change triggers every script. Only some exceptions when a script changes a device.
Post Reply

Who is online

Users browsing this forum: Google [Bot] and 1 guest