Scenes: Conditional blocks (IF... THEN... ELSE...)

Feature description
C’est encore moi avec une autre idée géniale ( :innocent:) : améliorer le « continuer seulement si ».

Exemple concret : je veux que mon interrupteur sans fil puisse allumer et éteindre ma prise avec un simple clic.

Actuellement, je dois faire 2 scènes :

  1. Si clic et si la prise est éteinte → Allumer la prise
  2. Si clic et si la prise est allumée → Éteindre la prise

Avec le sinon / sinon si je pourrais utiliser une seule scène :

  1. Si clic et si la prise est éteinte → Allumer la prise, → sinon éteindre la prise.

Le sinon si permettrait d’être encore plus performant en vérifiant l’état d’un ou plusieurs périphériques dans une seule scène et agir en conséquence.

@pierre-gilles, I reread this thread following this exchange :

Well, it seems to me that your proposal of November 6, 2023 was received rather favorably, except by those who were worried that it would reduce the number of scenes. But that was before the appearance of tags, so I think that would no longer be an issue.

In any case, for a topic that is the top 1 by number of votes, it’s worth thinking about :wink:

You were asking how Apple does it in Shortcuts. I illustrate it with the screen below. And I find that it’s satisfactory if there are few actions in the ‹ then › path and the ‹ else › path. But if it becomes long, in my opinion it’s not very readable and what you propose (by sending the else to another scene) is preferable.

And in Zapier, it’s the screen below. Pretty nice, but not easily adaptable to the current presentation of scenes in Gladys, so that would mean too many things to rework to get there. Your proposal is more pragmatic :wink:

I think it’s possible to make a compromise on this function si/alors/sinon with a single action to perform (and then move on to the next) or if there are several actions to chain we launch a scene (whether in the alors or the sinon).

However, if we launch a scene, should we stop or wait for the scene execution to return?

Personally I’d lean toward a return (currently I know that’s not the case because I got caught out).
And I’d go a bit further in the UI, namely that we could « switch » into the scene to edit it (saving the current one with a small alert message asking whether to save or not), and if we edit this scene on its own, we should know that it has a parent scene (or several, actually, kind of like a subroutine).
I may be getting a bit carried away here…

I forgot to say that we keep the continuer si, for me it’s additional functions.

1 Like

I admit my proposal was a bit of a workaround, and in hindsight I agree with the feedback: it doesn’t really change much about the problem :grinning_face_with_smiling_eyes:

The real issue here isn’t so much having a “Continue only if” with an “otherwise”, but rather introducing scenes with multiple possible execution flows, rather than a single linear scenario as is currently the case.

I tested Apple’s proposal with Shortcuts, and it works pretty well! In any case, it works well on mobile, which seems to me to be the number one criterion.

Zapier is interesting too, but I can see myself using it less on mobile. I’m curious to see how it looks on mobile!

Zapier on mobile doesn’t have a dedicated app (at least on iOS), so it’s a web app and the display isn’t modified. It’s like with node-red, you only see a small part of your complete algorithm… And Zapier displays a warning "Zapier works better on a

1 Like

4s of video to illustrate :

Yeah OK Zapier is really not great.

@StephaneB Would you like to lead this topic and put together a proposal on Whimsical inspired by what Apple does? :slight_smile:

The idea would be to have a block « IF » that would contain two blocks « THEN » and « ELSE » which would themselves be groups of Gladys’ standard actions.

To keep scenes clean, we could put limits on depth (max 1 or 2 I think), but at least it would already be much better than it is now!

1 Like

It’s true that that’s what Zapier does and it completely opens up the possibilities: it’s not an « if then else », it’s a crossroads where each possible path has its own condition to access it. Which means, I imagine, that the scene can start to follow multiple paths in parallel if several conditions are met. But I’m not sure we need to go that far.

I agree that it works, but I think we should find a very clear way to identify that we’re in the steps of a « then » or an « else ». The simple, slight indentation of blocks in Shortcuts isn’t great…

Yes, I just think that on the iOS side it’s poorly presented; if we encapsulate it well in Gladys as we already do with action groups, it will be clear

I

Honestly, Whimsical is super simple :slight_smile:

No, I don’t have anything that does an automatic conversion, but I like Whimsical because it encourages you to simplify things as much as possible.

I couldn’t resist making a small mockup to show what I’m thinking :smiley:

I’m thinking of something like this:

The « Then » and « Else » areas would be exactly the

6 Likes

Yes, this looks like a good start.

Just two things I already notice with this mockup:

  • you say « The ‹ Then › and ‹ Else › areas would be exactly the same as area 1 »: does that mean we can only put actions there that run in parallel (so it would be a single block)? Or do you envision that we could define blocks that run sequentially, one after the other?
  • with the condition displayed like that, I understand it’s a block equivalent to ‹ continue only if ›, so we can add 'OR’s if we want. But I see less clearly how to chain multiple ‹ condition blocks › so that they’re treated as 'AND’s.

I think in both cases it should be possible: to chain blocks inside a Then and inside an Else, and to define conditions with ‹ AND › logic. Are you okay with that?

If that’s the case, will you continue the mockup or do you want me to take over? And can you share in Whimsical what you’ve started?

Indeed, we’ll have to see how we handle the sequential part!

Indeed! That’s something to think about too!

I’d be happy for you to take over! Can you send me your Whimsical email privately?

So look, there’s also a video on Tasker’s site.

I would suggest:

  • if we want parallel then we stay in the THEN/ELSE block
  • if we want sequential then we launch a scene

@pierre-gilles Do you want numbering like 1.1 - 1.2 - etc. for the different blocks to find your way around?

That’s indeed a possibility. But I’ll try to make a mockup where sequential is possible, that will be better. And if it makes the interface unreadable, we may have to revert to what you propose

I had that in mind too.

So here are 3 mockups to propose a new action « Condition If… Then… Else… »:

  • Mockup 1: choose the action
  • Mockup 2: the action is displayed, with the different areas to configure: If / Then / Else
  • Mockup 3: an example scene to illustrate. If the heating is off and it’s cool in the living room or the dining room, I turn on the radiator and confirm it by message 5 minutes later. And otherwise (if the radiator is already on, or if it’s warm enough in one of the two rooms), the living room light turns on and then turns off after 15 minutes (don’t ask me why, this example is ridiculous, I know…). Finally, in both cases, a message is sent.

The conditions in the « If » section are very similar to the « Continue only if » action. I actually only changed the title. And in this « If » section, you could only add conditions like that, not other actions of course. Hence the fact that the button is « Add a condition » and not « New action ».

The two blocks « Then » and « Else » would allow chaining sequential blocks. Numbering the blocks with ‹ A › for ‹ Alors › and ‹ S › for ‹ Sinon › should make it easier to find your way…

What do you think?

1 Like

Very good mockup @StephaneB, I really like the process and layout you’re proposing.

Two remarks: one about the Add a condition, I see it more at the IF level:

And the other point concerns the A and the S in the numbering.
At first glance, I might confuse the S with the 5 (yes, my eyesight gets worse every year :wink: ).
For French (the language of Molière), A=Alors / S=Sinon, but for other languages, does the letter change automatically?
If it’s in English, we have T=Then / E=Else; in German we’d have D=Dann / S=Sonst but maybe O=Oder (I’m not bilingual in German).
Not sure that this is ideal, but that’s my very personal opinion.
And also the O (o) and the I (i) which could be confused with 0 and 1.
Lowercase might do the trick, or a specific icon… I don’t have a brilliant idea right now…

After a brief chat with Perplexity, a few ideas:

1. (block) If/Then/Else 
  IF condition
  Then
    1.A01.1 action 1
    1.A01.2 action 2
  Else
    1.B01.1 action 3
    1.B01.2 action 4
1. (block) If/Then/Else 
  IF condition
  Then
    1.#.1 action 1
    1.#.2 action 2
  Else
    1.*.1 action 3
    1.*.2 action 4
1. (block) If/Then/Else 
  IF condition
  Then
    1.\u003e.1 action 1
    1.\u003e.2 action 2
  Else
    1.\u003c.1 action 3
    1.\u003c.2 action 4
1. (block) If/Then/Else 
  IF condition
  Then
    1.→.1 action 1
    1.→.2 action 2
  Else
    1.←.1 action 3
    1.←.2 action 4
1.△.1 action 1 (for "Then")
1.▽.1 action 3 (for "Else")
1. (block) If/Then/Else 
  IF condition
  Then
    1.▶.1 action 1
    1.▶.2 action 2
  Else
    1.◀.1 action 3
    1.◀.2 action 4
1. (block) If/Then/Else 
  IF condition
  Then
    1.✓.1 action 1
    1.✓.2 action 2
  Else
    1.✗.1 action 3
    1.✗.2 action 4