WTH - why is there a "And If" in Automations after the Action?

Can’t understand why “And If” is there when you can implement the same logic and better with the toolset available on “Then Do”.

Writing automations in HA can be a pain for newcomers as I.

It’s difficult to understand with an AND / OR is implicit, it’s difficult to understand parallelism, it’s difficult to follow the yaml since with the change from UI to YAML and vice versa, the code seams to move place. It’s difficult to debug.

I believe a lot of improvement could be done here.

Can’t say I’m not a fan of the simple NodeRED UI. Simple blocks linking to each other passing the action down to a reaction.

Just my thoughts on What The Heck.

Thank you all for the great work on HA!
Happy Holidays! :christmas_tree: :gift:

And if is used when you want something to only happen if certain conditions are met, such as only turning up the heat if there is someone in the house.

You can do that with the tools available on the “Then Do” section.

True you can do it in the “then do” section, but it is an extremely common part of an automation, so why not place in its own section.

You do the same in Node Red anyway.


First column is the triggers and the second column is the “and if” (or conditions).

One reason to use the general conditions block… When all the conditions in the Conditions block (And If) pass, the last_triggered attribute gets set; if any of them fail, the attribute retains its previous value. This distinction allows us to create conditions that can throttle the rate of an automation based on that attribute instead of requiring delays or timers.

FWIW, I despise the renaming of the blocks to “When”, “And If”, “Then Do”… it doesn’t seem to have helped and it seems to have moved some new users further away from understanding the concepts behind automations in HA.

3 Likes

Which is ironic, because the very reason it was done was to help new users. (I agree with you.)

I think of the three sections of an automation as:

“If one of these things happens” - triggers, currently called “When”

“And all of these things are true” - conditions, currently called “And If”

“Then perform these actions” - actions, currently called “Then do”