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

I think it’s really great too!

A few remarks:

  • @pierre-gilles how do you add a new action block? I don’t see a +
  • the label Only continue if bothers me because it logically implies there is no Then or Else. You had just put Conditions in your video which I thought was very good
  • I find the text If all conditions are met ... odd because you can see a +OR just below; it throws me off because if I have an OR not all conditions are valid but only one of them (ok, there is + Add condition below but it’s not obvious/descriptive)
  • I like knowing where we are in the scene with the 1.2.Then.xx but looking at your latest example, I find it visually heavy… very personal opinion, no bad faith in my comment.
  • do we make a centered + Add action for the IF/THEN/ELSE and readjust for all the other « normal » blocks or do we leave the others like that? :
    Personally I prefer this one — it’s clearer because all the functions related to the block are grouped (move/add/delete).

In any case this bodes a ton of good things to come for scenes in this dev, I’m eager to have it in prod :hugs:

If Gladys is set to French on your side then it will be in French.

1 Like

thanks @_Will_71

Like what’s currently in production :slight_smile: It’s automatic, I haven’t changed that.

I think you’re confusing several things!

Don’t pay attention to the translations for now, they haven’t been done.
I’m just working on the UI right now.

I like the little « + add action » button at the bottom everywhere :slight_smile:

I just tested and I hadn’t even noticed that when you added an action a new block appeared, excellent automation!!

Point 2 : ok
Point 3 : ok, we’ll see with use

I agree with that!

And so this proposal is logical and relevant.

On that, I agree as well, but that’s exactly what I had done in the mockup to remove the ambiguity. There is this text at the start of the « If… » section: If all the conditions below are met, the scene will continue with the blocks defined in the “Then…” section. Otherwise, those defined in the “Else…” section will be executed

1 Like

Hello everyone!

I’ve made good progress on development today and I have a first testable result :tada:

It’s not completely finished yet, but you can already start testing and give me your feedback.

The PR is available here for those who want to try it in their development environment:

I started a Docker build on :

gladysassistant/gladys:scene-if-then-else

This build should be ready in about 50 minutes (around 17:50 today).

Questions

One question I have concerns drag & drop, which has become more complex to manage. Because the action “Condition : Si… Alors… Sinon…” is a large block that itself contains actions, it is not possible to move it freely into other actions via drag & drop.

:right_arrow: For now, I’ve made it so that this action can only be moved to another action of the same type. That alleviates the problem a bit; we’ll see if it’s ideal. I’m open to your feedback!

@StephaneB, since you designed this development, I’m particularly interested in your opinion. Tell me what you think! :blush:

Cool @pierre-gilles that you managed to progress to the point where it’s already testable. But do we need a dev environment, or will there be a Gladys Plus link to test?

You have to run the

Ah yes, makes sense. How do you start the container? If you’ve already written that somewhere, of course don’t hesitate to point me to the right page :wink: (I looked around a bit and couldn’t find it…)

It’s here :slight_smile:

1 Like

So spoiler for those who haven’t tested: it’s just awesome to be able to imagine scenes with this new « if… then… else… » mechanism!!

Bravo @pierre-gilles

A few remarks first:

  • we’ll have to get used to the new position of the « + New action » button, but that’s fine with me
  • Nice catch, the list of conditions: I had completely forgotten that there were also « If alarm » and « If house… ». But wouldn’t it be wise to rename them to « Condition on alarm » and « Condition on empty house » and « Condition on non-empty house »?
  • In the same way that Then and Else can be collapsed/expanded, I think the Condition should be able to be too.
  • I find the indentation of the Then and Else sections works well, even when nesting several levels of Conditions. In practice, we might still get a bit lost if scenes become long, but everyone can limit themselves to reasonable things so it remains readable…
  • When the « Then… » and « Else… » sections are collapsed, I find there’s missing info to visualize whether there are some blocks defined or not. Maybe some info like « > Then (3 action blocks) » and « > Else (0 action blocks) »? And the same for the Condition, if you make it collapsible.
  • I think the name of the action « condition if then else » is not the most fitting. I understand it’s a simple name, but with this action it’s not really a condition we add, like with the five other « condition… » actions. This new action really aims to add two action paths… Anyway, « Conditional blocks » seems more fitting. But it’s a bit ugly, though :wink: Some alternatives: « If… Then… Else structure », « Action blocks according to condition (If… Then… Else…) »

And then a few small issues during my tests:

  • within the same block, I created a « condition if then else » action then a « send a message » action. I couldn’t move the message action to the position of the condition action, whereas the reverse is possible.
  • I ran tests moving action blocks:
    • I made the interface bug when I tried to move an action block from the « Then… » section to the « Else… » section which was collapsed (the block I wanted to move stayed grayed out, without moving…)
    • I couldn’t move an action block from the « Then… » section to the « Else… » section when it was expanded (the block didn’t move)
    • When I tried to move an action block from the « Then… » section to a block outside the « Condition If Then Else » action, it had an undesirable drastic effect: the « Condition If Then Else » action completely disappeared.
  • I created a simple scene: block 1 displays the message « Before », block 2 with a time condition that displays « Then » or « Else » depending on the time, and block 3 that displays after. On execution, I often got « Before Then After » or « Before Else After », but I sometimes got « Before After Else » and even « After Before Else » (and the same with the "Then"s). That’s strange, right? Is it just the display flow in « Discussion » that can be inverted, but the blocks did execute in order? Or is there a problem?
2 Likes

Hello,
I just tested it quickly, it’s really great!

Bug (?) found so far: if you add an action to a Then or Else block, a second action block appears (normal). If you delete the action from the first block, the second does not disappear and cannot be deleted:


In a « classic » block, when you delete the action from the first block, you have the option to delete:
![image|690x453](upload://zShb5bAKF1yW

:+1: it works for me (Firefox/macOS) in both directions

:+1: You can move an action from a Then/Else block of one Condition to a Then/Else block of another Condition at the same level or at a lower/higher level (indentation), or even to a standalone Action block

I’ll test again tomorrow to be sure. I’m using Firefox and Ubuntu, but on a small computer that I haven’t updated in a long time…

Thank you all for your feedback! :slight_smile:

I think it’s better to favor understanding over consistency :slight_smile: « If the house is empty » is much clearer, I find.

Intuitively I disagree, since it’s « top-level » I prefer to keep it visible. I might be wrong, in practice it might be inconvenient

Not a bad idea! I’ll see what can be done :slight_smile:

I understand what you mean, but for me the goal is really comprehension by the end user. It needs to be concrete, not abstract. So typically, everything that is « Structure » is too abstract, the end user won’t understand.

I think « If… Then… Else » should be part of the title, as for the prefix, I’m open :slight_smile:

Ok I’ll investigate for the drag \u0026 drop.

If your scene runs very fast, the messages can all be created at the same millisecond and therefore be in a random order.

Could you re-test by adding « Wait » blocks (10ms is enough) to check that it’s not a bug?

Indeed, I’ll fix it :slight_smile:

1 Like

That’s really not bad!

4 Likes

Hello everyone :slightly_smiling_face:

I’ve made fixes based on your feedback, thanks again!

A new Docker image is available:

gladysassistant/gladys:scene-if-then-else

:backhand_index_pointing_right: Tutorial: Launch a test Docker image

:warning: If you already ran the old image, remember to run:

docker pull gladysassistant/gladys:scene-if-then-else

I tested by adding wait actions of 10ms then 100ms in parallel with each « send a message » action, and I still have inversions in the discussion (for example before=>after=>then, and then=>after=>before). Increasing the waits to 1s, I have no inversions. I can’t really say whether that means there is indeed a bug…

I understand that concern about being understandable. But if you type the word ‹ condition › in the dropdown list, you don’t find them all and I find that a shame. Well, not a big deal, just a pity :wink: And renaming to « Condition ‹ if the house is empty › », what would you think?

I propose « Conditional actions ‹ If… Then… Else… › » . It’s still fairly short, the If Then Else is well included, and it conveys that we’re adding blocks of actions rather than a condition.

[