That’s quite an advanced automation no one should say this
We’re getting to the point.
It’s just save=state.light[N]; for i in (1, N): state.light[i]=save.state[i-i]; state.light[0]=not(save)
Pseudocode is easy, but in YAML+Jinjia it’s very complicated (I’ve done it in python_script, I’ll post it ASAP).
Another easy automation for me is: turn_off(light.any, climate.any except light.porch_lamp).
[I know it’s close to doable with YAML alone if it wasn’t for the “except”, so I added it - not an uncommon need]
A complicated automation for me is:
- take (external_temp, internal_temp, climate.furnace.state), feed it to some filtering (kalman?) and estimate (heat_power, heat_dissipation_ratio)
- given (heat_power, heat_dissipation_ratio), estimate for current (external_temp, internal_temp) how much in advance turn_on(climate.furnace) so that internal_temp reaches given setpoint at a given time.
I’ve endeavored making my whole home smart, so I’d like to play smart things with it!
Templating YAML with Jinja2 started as a big trend a few years back.
Actually, I have nothing against Jinja di per se; but the user base of Ansible and an home automation system are very different: the former work with it everyday, the latter do it from time to time, maybe months apart. That’s why a structured language, with an overload of possibilities, especially with a scattered documentation, becomes a stopgap.
Moreover, an home automation has to be reliable and robust to exceptions and errors (how many people writing templates ask themself when they will be evaluated and if they’ll always yield meaningful results?).
If I had to bet, in such a situation I’d first consider a visual language, like Node-Red or Blocky. However it has to be well integrated; if you have to write hard-to-remember function calls inside graphic items, its usefulness is lost.
I repeat: I’m not pushing for it, I know it would be a though work; I’m just suggesting not to take YAML+Jinja for granted as the best decision.