In this picture I have two working automations that include some templating.
A) This template is created by editing the YAML file. It looks good there, but are not visible in the automation editor. And I am unsure if it will be saved or lost if I do any changed in the Automation Editor?
B) This is created by input in the Automation Editor, and the template is visible both in editor and in the YAML file. However it is messy and not relay easy to read and understand in the YAML file. This will also be hard to share with other people that may want to dublicate something. How can this be done? And how can it bee cleaned?.
I also see that template in Automation A is inside â and '. but the Automation B is inside " and ", why is that?
This is quite confusing.
From the structure it seems these have been created with the automation editor, the id: randomlongnumber is a giveaway.
All such produced are as visible in yaml as one that is hand crafted.
The editor sometimes put quotes in arbitrarily, Iâve seen single, double and even triple quotes, sometimes where they are not strictly needed.
There are no hard and fast rules but âgenerallyâ coders within this forum prefer to have âdouble quotesâ on the outside of jinja and âsingle quotesâ on the inside. You are required (sometimes) to have this so the interpreter can see quoted text as distinguished from keywords and then interpret the whole for output, so â{{ 'hello â ~ âthereâ }}â
BUT
You appear to have 3 automations here, as distinguished by the 3 aliasâs
But the 2nd one looks to be from a list (the other 2 dictionary)
This shouldnât work, the config checker should throw a wobbler.
The preffered way of posting questions with yaml is to post the yaml in preformatted text rather than images (they are huge by comparison) but I can understand why you posted this.
There are a few people here trying to get a handle on the automation editor, so they can help newbies, but the vast majority prefer to use a simple text editor to craft their efforts. The automation editor (for example) will strip out any comments (marked by a leading #) from your code.
Both automations are created by the Automation Editor, I do this so it gets an ID. But the template in Automation A is added in the YAML file afterwords.
so Iâm not sure I understand your question.
Do you mean that you can find where automation B is stored but you canât find automation A ?
Given that you are playing with the AE then it will (AFAIK) only save automations in one of two places.
The actual configuration.yaml or more often in automation.yaml. Both these files live in your config directory.
Have I misunderstood ?
You can have an âaliasâ (even an empty one) in the action section too. I donât see the purpose (other than to confuse things even more) but it is legal and wonât throw a âwobblerâ.
so there truly are only two automations in there.
But I donât know why (aside from the aforementioned âabomination theoryâ) the editor would put an âaliasâ in the action of one automation and not in the other one.
If you donât want to use the automation editor then there is absolutely no benefit to having an âidâ in any of your automations. Itâs strictly there so that the automation editor can âseeâ the automation and be able to edit it. Itâs not used anywhere else at all.
OTOH, if you still want to use the âidâ then just put one in yourself when you write your automation by hand. There is no magic behind the âidâ. Itâs just a randomly assigned value. You can make it anything you want. And the good thing about that is that you can make it a ânot-so-random string of textâ so you can even make it human readable so it will make sense to you.
Okay, I will take your word for it, Iâve never seen it but after a couple of tragic attempts at using the AE, I decided that pulling my own teeth would be preferable.
Do you mean why would anyone use the alias option for action steps? To make debugging easier. If you look in home-assistant.log, there are message lines written each time an action step is executed. Without an alias it says something generic, like:
2019-11-04 10:50:20 INFO (MainThread) [homeassistant.components.automation] Executing Foyer Snapshot
2019-11-04 10:50:20 INFO (MainThread) [homeassistant.helpers.script] Script Foyer Snapshot: Executing step call service
2019-11-04 10:50:20 INFO (MainThread) [homeassistant.helpers.script] Script Foyer Snapshot: Executing step call service
But if you add an alias to each step, that will be displayed instead, making it easier to see which step has executed. Same thing goes for sequence steps in scripts.
Honestly, I donât use them, at least normally. But it can make debugging easier if things arenât working as expected.