Ah right, I forgot your first request was already unreasonable. They didn’t make an argument that other languages can do it shorter without special characters.
This reading is super funny. You are contradicting yourself 3 times over here.
this:
Exactly. The use of special characters is certainly not part of what I dislike about YAML.
Also, I think the sarcasm part completely missed the point I was trying to make. I don’t mind learning a new language and I do take time to do that (see numerous examples in my post). My point was that I, personally, find the combination of YAML and Jinja more annoying and difficult to learn than many other languages I’ve learned. That’s also the point of this WTH as far as I can tell.
Yes, it’s a configuration for an automation.
FYI shorthand would be
if: "{{ x.state > 1 }}"
then:
action: <service>
data: <data>
My example was about YAML, so I left out templates. Also I was a bit hasty and the proper representation of the state of entity x should probably have been states.x.state, and the more robust way of calling it states(‘x’).
It’s not really a fair comparison when templates were added to address complex checks like an if statement.
ah, and I forgot, we can shorten it more
if: "{{ x.state > 1 }}"
then: {action: send, data:{message: ""}}
So far we are comparing the appearance of single commands. Or single actions like if something then do something else
. But a life shows the need to create much more complex automation
Just curious if HA is capable to do something which is fairly complex (even if not sounds like this). Not asking for a solution, while indeed I would like to see the code (to see how complex or easy on eyes it can be). But trying to be fair I’m not requesting for such a source code. Just a fair comment.
Is it possible to write an automation using the current state of HA/yaml/jinja, which does as follows:
- when the washer finishes, HA starts to send actionable notifications to all members in the house
- It sends a notification every 15 minutes for two hours until the washer is opened or notifications are suppressed by the actionable notification option.
- If any new family member comes back home, and the washer is still not emptied (or notification is not suppressed), HA starts to nagg the new member the same way
I have to admit I won’t be able to write it using built-in automation. I wouldn’t even know where to start from. Can it be handled by single automation or there must be more automation involved to achieve such a thing?
Yes, that’s entirely possible.
The only thing HA automations cannot do, is create a script on the fly. And the only use to create a script on the fly, would be to abuse parallel, or durations w/ a script.
OK, so how to achieve parallelism in the case of use case above? I mean one group is being notified after some event - it’s easy. But then each new member arriving home creates a parallel automation process (note the counter 15mins for 2 hours applies for him while must not apply for other members anymore).
Does it require more automations running in parallel?
There’s a number of ways, you can use parallel
action or set the automation to parallel and abuse the triggers and events.
Here’s an example of something close to what you’re asking. It’s a work in progress (I have a more complex version that I’m moving from) but it’s a blueprint that creates door notifications and turns on lights.
- It turns on lights when the door is opened and schedules the light turning off in 2 minutes after the door closes.
- It sends a notification to the user when the door opens.
- If the door opens again within a time window, that second message is suppressed and the time window is extended by the time window. A count is incremented.
- At the end of the time window, a message will appear with the number of door counts.
- This also announces who likely opened the door.
- If it doesn’t know who opened the door, it says that, but then waits for a device tracker to appear at the house. If it does it says the person that opened the door was “xyz” and to ignore the previously unknown person opening the door.
EDIT: While this may seem complex, the first 400 lines are selectors for blueprints. So this would be maybe 500 lines of yaml without them.
You can use the state of the person and last_changed to get if they are home and for how long.
Is that really the only thing they can’t do? Then I have a lot to learn. I was underthe impression that automations can also not create or store variables except ones with very limited scope. And I never found a way to create a helper from within a blueprint or automation.
BTW Maybe the automation could call ChatGPT to write the script? If there is an integration that can handle the file io that might work (the script creation, not the execution )
You can use mqtt to store global variables. I’m doing that in the linked automation.
That’s an interesting workaround. I don’t really use MQTT for anything anymore (I had a DSMR reader that communicated through MQTT but I recently flashed ESPhome onto it), but this would be a good use for it. For a blueprint it’s not so convenient to have such an extra requirement but hey.
It may not be convenient, however it allows you to have variables and create devices for your automation. Also, you can make entities that adjust the automation during run instead of just inputs from blueprints.
Pretty good! It’s functionality that I really think should be part of the core but it’s good to know there is at least a workaround.
I think (based on what I have seen), it is not about “knowing” YAML. YAML itself for me wasn’t hard to pick up as it is just whitespace and structure. As in, the basic concept of the structure and layout of YAML. Plus there are YAML linters what can help if someone is unsure.
What I have trouble with (and what I see others struggling with) is the completely non-deterministic and no obvious verbosity of the keys and values that YAML is being used to define. For a some people it seems completely backwards to how it should be done.
This may be worse for me because I’ve been programming for so long (BASIC, freaking Logo Writer, Pascal, Turing, Visual Basic and variants, ASP, JavsScript, C variants) and the concepts of trying to “program” in a YAML structure is so completely foreign.
It is just a bizarre way to define a programming language.
But it is something I accept if I want to use Home Assistant.
Woah, thanks for the trip down memory lane!
Documentation covers every available key and the structure. This is one of the few good things about the documentation.
It’s a configuration for an automation, it’s not a “programming language”. Maybe that’s the hang up. It’s simply a structure that tells HA what to do in order to execute the automation.