In a scene that handles the click on 2 buttons (click 3 positions: single, double and long), in the « if… then. else » condition I have 2 conditions with an « OR » but in fact the behavior is that of the « AND »! To know the buttons keep the last position: if button 1 just sent a single click but button 2 remained on the last state (for example double click), the « then » does not execute, which does not correspond to the « OR » but to an « AND »
Hi @Chris75,
Thanks for the feedback and the screenshot, it helps a lot!
Actually, this isn’t a bug. In your screenshot, you have two separate « Condition on variables » blocks, and in an « If… Then… Else », the blocks are connected by an AND: this is what the text at the top of the « Conditions » section indicates. The OR is done within the same block, with the « + OR » button.
To make an OR, you need to:
- delete the second block;
- in the first block, click on « + OR » and add
Button_51 (Button click)equal toSingle click.
That said, I recognize that the interface doesn’t help you: an « OR » is displayed between the conditions of the same block, but nothing indicates the « AND » between two blocks. I’ve opened an issue to display it clearly: Scenes: show the AND between the condition boxes of an "If / Then / Else" (and "While") block · Issue #3358 · GladysAssistant/Gladys · GitHub
However, be careful: even with an OR, your scene won’t do what you want ![]()
« Retrieve the last state » on a button returns the last click received, even if it’s several days old: the value is never reset. With Button_42 = Single click OR Button_51 = Single click, if the last click of button 51 was a single click (even 3 days ago), a double-click on button 42 will still trigger the « Then ».
The correct method is to put the type of click in the trigger rather than in a condition. Triggers are connected by an OR:
- Trigger « Device state change »:
Button_42=Single click - Trigger « Device state change »:
Button_51=Single click - Then directly your actions, without condition.
On recent versions of Gladys, you can also select both buttons in a single trigger.
You then make a scene per type of click (single, double, long). The trigger of a button goes off with each click, even if you make two single clicks in a row.
However, managing the 3 types of clicks in a single scene with « If… Then… Else » is not properly possible today: Gladys would need to offer as a variable « which button / which click triggered the scene ». I’ve noted it in the issue as a possible improvement.
Let me know if it works on your side!
Hi everyone!
This topic is now in development.
A PR has been opened to display the AND between the condition boxes of an « If / Then / Else » block and a « While »:
Feel free to follow the PR, test (optional, especially for small requests) and give your feedback here if needed.
