Page 1 of 1

Event triggered automatically

Posted: Friday 25 September 2020 21:10
by armaster
Hi,

I'm new in Domoticz/Blockly and I have a problem setting a push button acting as switch.

1. From "Learn Light/Switch" I created a "Push On Button" with name "BlackButton".
2. I created user variable "BlackButtonVariable", type = "String", default value = "on".
3. I created a Blockly script with name "BlackButtonScript" which should make push button acting as switch:
Screen Shot 2020-09-25 at 20.50.21.png
Screen Shot 2020-09-25 at 20.50.21.png (126.49 KiB) Viewed 797 times
If I click "BlackButton" in Domoticz or if I push physical button, It works as expected.
This is log:
2020-09-25 20:59:29.066 (RfxCom) Lighting 4 (BlackButton)
2020-09-25 20:59:29.079 EventSystem: Event triggered: BlackButtonScript_2
2020-09-25 20:59:29.037 Status: User: Admin initiated a switch command (2344/BlackButton/On)
2020-09-25 20:59:29.079 Status: EventSystem: Fetching URL http://192.168.1.11/relay/0?turn=off after 0.2 seconds...
2020-09-25 20:59:30.108 Status: Set UserVariable BlackButtonVariable = off
2020-09-25 20:59:31.540 (RfxCom) Lighting 4 (BlackButton)
2020-09-25 20:59:31.552 EventSystem: Event triggered: BlackButtonScript_1
2020-09-25 20:59:31.511 Status: User: Admin initiated a switch command (2344/BlackButton/On)
2020-09-25 20:59:31.552 Status: EventSystem: Fetching URL http://192.168.1.11/relay/0?turn=on after 0.2 seconds...
2020-09-25 20:59:32.583 Status: Set UserVariable BlackButtonVariable = on

The problem is, that script is periodically triggered by system after about each half minute which changes state of switch (I did not press button):
2020-09-25 21:02:26.520 EventSystem: Event triggered: BlackButtonScript_1
2020-09-25 21:02:26.520 Status: EventSystem: Fetching URL http://192.168.1.11/relay/0?turn=on after 0.2 seconds...
2020-09-25 21:02:27.559 Status: Set UserVariable BlackButtonVariable = on

2020-09-25 21:03:09.764 EventSystem: Event triggered: BlackButtonScript_2
2020-09-25 21:03:09.764 Status: EventSystem: Fetching URL http://192.168.1.11/relay/0?turn=off after 0.2 seconds...
2020-09-25 21:03:10.788 Status: Set UserVariable BlackButtonVariable = off
Is it a problem in my script?

Thanks for your help.

Re: Event triggered automatically

Posted: Friday 25 September 2020 23:37
by waaren
armaster wrote: Friday 25 September 2020 21:10 Is it a problem in my script?
The issues are that the script is not only triggered by the pushbutton but by an update of any device. This combined with the default behavior of a Push On button (it doesn't switch to Off if not set like below) will cause the effect you see.


Push Button.png
Push Button.png (54.4 KiB) Viewed 794 times

Re: Event triggered automatically

Posted: Monday 28 September 2020 8:18
by armaster
Don't understand why off delay should be 1, but it works. Thanks.

Re: Event triggered automatically

Posted: Saturday 10 October 2020 22:02
by wouterlet
A push on button won't go to the state off. It's always in the on state. So every time your script starts it Wil see the button is on.

The blocky script starts by every device change, so more often then you think.

If you make the button to go off the script won't do thee actions. Hopefully it helps you understanding.