I just tested Pyscript, for giggles, and, shockingly, it’s actually faster than a native automation. Again, not by enough to really matter (less than 2ms on average). For the curious, here’s how I’m testing.
Home Assistant:
- alias: time test
trigger:
- platform: state
entity_id: input_boolean.test_1
to: "on"
action:
- service: input_text.set_value
data:
entity_id: input_text.test_2
value: "{{ now() }}"
Thanks for that, it had to take more than a few minutes to write all of that out! While the concept that the OP is trying to accomplish doesn’t apply to anything I’m doing, this example really highlights how to do some pretty complex stuff right inside the HA YAML files rather than venturing into Python code.
For me, I can get around Python easily so it’s familiar territory, but I realize that it adds a layer of complexity to the system, so the more I see good complex examples like this one the more comfortable I become transitioning from relying on Python to do my complex stuff and moving to a pure YAML solution that still uses Python code in creative ways.
It still really highlights how you can do some super cool stuff in YAML! And, bonus points, it uses Python to do it (albeit within the double bracket structure which can be visually unappealing).
Ah, yes, thank you for the clarification! I first saw that in some examples on the forums and thought “well, that’s just Python in double brackets” and read the term jinja a few times in regards to it but haven’t dove into it too much. That helps, I can really do some more research on that and it will help immensely!
I found this thread while searching for exactly what the OP is asking for - thanks for the tips, I’ll take a look at the Python alternatives.
My $0.02: I started out as a professional programmer in 2000, and have worked on a variety of OSs and languages - Windows, Linux, BSD, Solaris, using C, C#, Ruby, Lisp, and many others.
The experience of working in YAML is so unpleasant compared to the professional tooling that was available 23 years ago, let alone today, that I was planning to abandon Home Assistant prior to discovering this thread.
with the current feature set of native YAML automations, as long as the data you need to access is already in Home Assistant (or you can get it in Home Assistant) there’s very little (nothing?) that can’t be done.
This is a true statement; but also, is unrelated to the OP’s original query (and complaint). One could write any possible program in COBOL, or MUMPS, or BASIC. But life’s too short to code in bad languages.