Page 1 of 1
Ignore device events that are triggered by a script
Posted: Monday 12 February 2018 20:12
by blooop
I have a relay that is triggered by a timer, and also by a hardware event (a button press). If the relay is turned on by the timer script, the device script will fire again. The problem is that I have no way of distinguishing when I physically press the relay button vs when my timer script turns the relay on or off.
I want to use the button to set a user variable that enables and disables that relay.
I have thought of a hacky way around this. I could have the timer script record when it switched the relay state. When the device event fires directly after the timer script I could ignore that event and not set the user variable. The problem is that if I go to press the button and the timer event happen to have run recently, it will ignore my button press.
Is there a less hacky solution to this problem?
Re: Ignore device events that are triggered by a script
Posted: Monday 12 February 2018 20:16
by dannybloe
Use .silent(). See the docs.
Re: Ignore device events that are triggered by a script
Posted: Tuesday 13 February 2018 18:33
by blooop
Thanks for the fast reply. I'm sorry I missed that section of the docs before.
I've tried appending the silent command to the switchOn() function:
domoticz.devices(dev .. ' Radiator').switchOn().silent()
but it crashes with the error:
attempt to call field 'silent' (a nil value)
Re: Ignore device events that are triggered by a script
Posted: Tuesday 13 February 2018 18:36
by dannybloe
Which version of dzvents are you using?
Re: Ignore device events that are triggered by a script
Posted: Tuesday 13 February 2018 18:52
by blooop
Ah, that must be it. I'm on:
Domoticz 3.8153
Dzvents 2.2.0
and silent() was added in 2.3.0.
I did check for updates but it says there are none available. It might be because I'm running on a synoloy.
Re: Ignore device events that are triggered by a script
Posted: Tuesday 13 February 2018 19:47
by blooop
Do you know if there is a workaround for this earlier version of dzvents?
Re: Ignore device events that are triggered by a script
Posted: Tuesday 13 February 2018 20:02
by dannybloe
No because the Domoticz version doesn’t support this at all.
Re: Ignore device events that are triggered by a script
Posted: Wednesday 14 February 2018 13:38
by jake
blooop wrote:Do you know if there is a workaround for this earlier version of dzvents?
A workaround is to let your script set a variable (or dzVents: persistent data), which you can check when you manually switch. In that case there will be no update of the variable
Re: Ignore device events that are triggered by a script
Posted: Wednesday 14 February 2018 19:04
by blooop
jake wrote: ↑Wednesday 14 February 2018 13:38
A workaround is to let your script set a variable (or dzVents: persistent data), which you can check when you manually switch. In that case there will be no update of the variable
Thanks, I've got something working now using this method.