Event triggered automatically

Moderator: leecollings

Post Reply
armaster
Posts: 2
Joined: Friday 25 September 2020 20:40
Target OS: Raspberry Pi / ODroid
Domoticz version:
Contact:

Event triggered automatically

Post 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 795 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.
User avatar
waaren
Posts: 6028
Joined: Tuesday 03 January 2017 14:18
Target OS: Linux
Domoticz version: Beta
Location: Netherlands
Contact:

Re: Event triggered automatically

Post 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 792 times
Debian buster, bullseye on RPI-4, Intel NUC.
dz Beta, Z-Wave, RFLink, RFXtrx433e, P1, Youless, Hue, Yeelight, Xiaomi, MQTT
==>> dzVents wiki
armaster
Posts: 2
Joined: Friday 25 September 2020 20:40
Target OS: Raspberry Pi / ODroid
Domoticz version:
Contact:

Re: Event triggered automatically

Post by armaster »

Don't understand why off delay should be 1, but it works. Thanks.
wouterlet
Posts: 109
Joined: Tuesday 02 October 2018 20:52
Target OS: Raspberry Pi / ODroid
Domoticz version:
Contact:

Re: Event triggered automatically

Post 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.
Post Reply

Who is online

Users browsing this forum: No registered users and 1 guest