And condition with a single child not working

Here’s the action sections condition documentation.

Notice the syntax.

Now notice the same condition inside the condition page that you linked that covers all conditions

See how they both share the same condition, one just has an alias attached to it.

That’s your condition. Not the field it goes into.

In that case, it goes against all conventions in programming language documentation.

I’d prefer to just see a formal operational semantics such that there is no confusion possible.

Thanks for the help, all. I got it to work without the extra condition:.

The yaml is created by tools outside of Home Assistant.

unfortunately, that leads to more confusion as then people don’t add the condition field in automation. It’s a double edged sword and it’s gotten to this point based on past experiences beginners had.

Whatever “tools” they might be, they needlessly sorted the YAML statements and failed to provide you with guidance for composing valid YAML (i.e. allowing for the malformed condition). I suggest you use the Automation Editor or, if you prefer a text editor, VS Code with the Config Helper plug-in.

I intentionally wrote it like this based on the documentation. I have programmed in 30+ languages. If I can’t write a condition the first time correctly, it’s a problem with Home Assistant.

The “script” syntax also uses this "script:" syntax. I have absolutely no idea whether it’s wrong to use it there too. I think it would help if there would be complete examples including the automation: toplevel element. A formal semantics would be better, however, but I believe the people involved in this project are not exactly PL experts, so I guess I can’t expect that.

YAML has unordered data format elements. If the designers of Home Assistant considered it important, they should not have used YAML.

I think you should familiarize yourself with integrations as that seems to be the disconnect here. An integration has a specific configuration, and that configuration changes based on the integration. Script is the script integration. The action section of an automation shares the same functionality as the sequence in a script.

It’s ordered because users wanted it that way. Remember, more than just you is using this.

EDIT: I should clarify, yaml doesn’t care. People on the forums like seeing it…

trigger:
  ...
condition:
  ...
action:
  ...

Can you show me examples in the documentation where the YAML statements are sorted alphabetically in automations?

The overwhelming majority of examples that I have found in the documentation and in this community forum are in a ‘cause and effect’ order (trigger/condition/action).

Your syntax errors are always Home Assistant’s fault?

At most I’d say the syntax errors you created (malformed condition) were allowed by whatever unnamed tools you used. Ultimately, it’s your responsibility to supply Home Assistant with a syntactically correct automation.

They considered trigger/condition/action ordering important enough to store it that way for automations created via the Automation Editor (even though it’s not required for the YAML interpreter, just for improved legibility).

1 Like

I rarely make mistakes while programming. I wrote it based on how I interpreted the documentation.

Also, let’s be fair. The condition syntax is completely awful and redundant compared to how it would be done in e.g. Lisp.

I have not claimed anything about the order of the properties in the documentation. It’s unfortunate that you talk about things I haven’t said.

The order is created by tooling and that tooling could potentially use a Home Assistant specific backend, but you are literally the only one that is concerned about the order.

The Automation Editor is something nobody is going to use for anything remotely complicated.

I guess this is an example of one of those rare instances when you did, based on a misunderstanding of the documentation.

You’re right; that was my mistake. I thought your reply was to me, on the subject of ordering, but you had replied to petro, on the subject of condition notation.

Your unnamed tooling is fine for the YAML interpreter but below par for user-legibility, namely for the volunteers who must examine the non-standard ordering and spot your mistakes. It’s in the same vein as the unformatted YAML occasionally posted by newcomers.

If you know 30+ programming languages then you are aware that many have style conventions that aren’t mandatory but do improve legibility. Consider it the Home Assistant style to order by ‘trigger/condition/action’.

1 Like

I’d consider the documentation to be written in an almost malicious fashion. As such, I don’t count this as a mistake. You are free to have your own count.

Anyway, the world is a bit more automated again and I am certain that people will benefit from this topic.

If the people behind Home Assistant were smart, they would implement a pretty printer in the forum software itself. That way the whole topic would be moot.

It’s created by community members so you have the opportunity to improve it. This guide explains how:

really?

how so?

that’s going pretty far just to try to place the blame for your mistake on someone else.

it’s ok to say “oops, I misunderstood the documentation (which could use improvement) and didn’t realize it worked that way” instead of saying that they intentionally wrote the documentation to trip YOU up for some unknowable nefarious reason.

1 Like

Like I said: I don’t make mistakes. You, however, have made the mistake of whining over a topic that was already dead.

Home Assistant’s error message, in your first post, clearly shows that you did.

1 Like

I never make mistakes…it had to be your fault.

I think this whole thread was started and “written in an almost malicious fashion” by you.

:wink:

see how silly that sounds?

But in this case I’m not sure it isn’t the truth.

Good luck finding anymore help in this community with the way you’ve behaved here. So I guess you are on your own and we will see how many other “non-mistakes” you make.

4 Likes

Out of curiosity, pardon me but I simply couldn’t resist. I played around with this one using the OP’s “Given:”:

:rofl:

2 Likes

I think you have pointed out one of my struggles with HA as well. Following the documentation and checking the code produces errors in HA. I see many times the HA changes and errors happen even though the docs were followed. A recent example was in the templates and default values.

I disagree with the op about anything from the developers being malicious. I believe that since this is open source that the docs are the least fun thing to work on and they are the last to update and many times are incomplete.

As to the link to change documents, I have found this very difficult on ones I have tried and it being almost a debate on why I want to change them. Many of the documents are not written to the correct level of user and most require you to go to many additional documents rather than being self contained or at the very least correct links to the additional information needed.