Best way to turn on multiple lights one-by-one

If you mean can I create an equivalent solution as a YAML automation, with an appropriate template, the answer is no. Maybe it’s possible but, over the 11 months I’ve been hanging around this forum, I’ve never seen it done.

The issue is you can’t iterate (loop) in a YAML automation. It lets you define a sequence of steps, where each step can be tweaked with a template, but you can’t loop through those steps.

1 Like

So just like speaking and thinking (if you are fortunate enough to be multi-lingual) - pick the programming language for the task at hand.

Latin is much preferred by lawyers due to it’s formal structure, I heard.

I thought i would just pop in here… I have 200 lines of code for turning on my 19 lights of IKEA… Turn on … delay… turn on… delay and it works brilliant. :slight_smile:

Even though the automation is long, it is still very easy to see exactly what it does :smile:

1 Like

But loops are possible. e.g.

Iterate through a Group

NM. I see what you are saying. Iteration is not equivalent to a “while true do” loop.

YAML is not Turing Complete. Python is.

I have similar automations that I could combine at the expense of mere mortal (me) understanding, but this is not the way to go for maintainability.

Anecdotally, there’s bugger all gain to be made other than the satisfaction of solving the puzzle. The hardware we run HA on is more than capable of a few inefficiencies, even if configuration length equated to efficiency (I’m guessing it does not, much).

It’s your home automation system. Write it so you can understand it and maintain it.

I’ll be the first to admit that out of necessity I have been guilty of using provided configuration I do not fully understand. But it’s rare.

The worst thing about 5500+ lines of automations is… bugger all. Ctrl+F in most editors will get you there.

I think ‘most’ of us here suffer from it (to a greater or lesser degree or we wouldn’t be obsessing about when it’s appropriate to “turn a light off”). A good coder is hard to find. They need the right level of OCD, but not tooooo much as some of them have to turn the light off 23 times before they leave a room.
"BUT testing is a valuable use of time !!! " ; - ))))))))))))))))
Cheers

Only 10 minutes ! … You’re not trying hard enough ! ; - ))))))))))

1 Like

No. Thats just so they can charge you $600 per hour !

There is bugger all latin left in the law, I can’t think of the last time I used a latin phrase.

True, if your clients dont need Alibi’s, you’ll get a bonus if that’s the case.
i.e. you can’t let your ego get in the way and cause extra complications even if they are semi-intoxicated e.g. “on exiting one pub we engaged in a physical difference of opinion versus another pub”

Sorry I couldn’t resist a quick stab

Those words are all in common english use, and are english. The type of latin that lawyers are notorious for is a fortiori or ejusdom generis.

English is a bastardisation of other languages, that’s why it’s so flexible.
I had a friend who was thinking of buying a fortiori (though he decided it was a foible excuse) he bought a lamborghini instead. (french fencing derivation from the same root).
and as for ejusdom generis, I think you can get pills for that ! or is that too generic ?
Seriously - I had to look up those words