Skip to content

Home Assistant Automations Improved YAML Syntax: Easier or More Complicated?

Improved YAML in Home Assistant Automations

If you’re a Home Assistant user, you’ve may heard about the recent improved YAML syntax in Home Assistant automations. These changes were designed to make the code easier to understand and more natural to use, but do they really simplify things, or are they more complicated now? In this article, we’ll break down exactly what’s changed and what it means for you as a Home Assistant user.

Now, here’s the good news: these changes are not “breaking changes.” Your current automations will continue to work, and you don’t have to worry about updating them unless you want to take advantage of the new syntax. So, if you’re happy with your current setup, you can simply do nothing. Home Assistant has no plans to remove the old syntax, and everything will keep running smoothly.

That said, the new & improved YAML syntax is recommended for new automations. If you use the automation graphical editor to create or modify automations, it will automatically generate code in the new style. But what exactly has changed, and why should you consider switching to the updated syntax? Let’s dive in!

Tired of reading?

If you are a more of a visual person, then check my video on this topic:

What Has Changed in the YAML Syntax?

In Home Assistant 2024.8 release the “service” key was renamed to “action” in both the UI and YAML. Following that same idea, they’ve now made some updates to improve YAML syntax in automations.  Let’s look at the key changes:

  1. The trigger key is now triggers (plural).
  2. The condition key is now conditions (plural).
  3. The action key is now actions (plural).

The reason behind this change is simple: most automations have multiple steps. Whether you’re setting up multiple triggers, conditions, or actions, using the plural form makes the code more consistent and easier to follow.

Another key update is the platform key, which is now simply called trigger in the new syntax. This further streamlines the way automations are defined in YAML.

The New & Improved YAML syntax in Home Assistant Automations
The New & Improved YAML syntax in Home Assistant Automations

For everyday users, these changes won’t affect how your current automations work. The old syntax will continue to be supported indefinitely, so there’s no need to panic. But if you’re creating new automations or tweaking old ones, you’ll start seeing the updated syntax, especially if you use the graphical editor.

Example: Old vs. New Syntax

Let’s look at an example of a simple automation that turns on a bedroom light at sunset. This example will highlight the differences between the old and new syntax:

Old Syntax:

alias: "Old YAML Syntax"
description: "HA 2024.9 release or lower"

trigger:
- platform: sun
event: sunset
condition:
- condition: state
entity_id: light.bedroom
state: 'off'
action:
- action: light.turn_on

target:
entity_id: light.bedroom

New Syntax:

alias: "Improved YAML Syntax"
description: "From HA 2024.10 release or higher"
triggers:
- trigger: sun
event: sunset
conditions:
- condition: state
entity_id: light.bedroom
state: 'off'
actions:
- action: light.turn_on
target:
entity_id: light.bedroom

As you can see, the new syntax uses plural forms for triggersconditions, and actions. The key platform has been replaced with trigger, and while this might seem like a small change, it helps make the code more consistent and natural to read.


Want to Learn More? Download My Free Smart Home Glossary!

Understanding all the terms in the smart home world can be overwhelming. That’s why I’ve created a free Smart Home Glossary that breaks down common jargon into simple, easy-to-understand definitions. This PDF is packed with helpful tips and explanations to guide you through your smart home journey.

Click the link to download the glossary – https://automatelike.pro/glossary

Plus, when you sign up, you’ll automatically join my mailing list, where I share weekly updates, exclusive articles, and special offers. It’s free, and you can unsubscribe at any time with just one click!


Deeper Dive into the New Syntax

Now, let’s break down what the new plural syntax means for real-world use. If you have multiple triggers, conditions, or actions in your automation, the new format makes it easier to see everything at a glance. You no longer have to manage mixed singular and plural forms, which can sometimes make reading the code confusing.

For example, let’s say you have two triggers for turning on a light: one for sunset and another for motion detection. In the old syntax, you’d have something like this:

Old Syntax (Multiple Triggers):

trigger:
- platform: sun
event: sunset
platform: state
entity_id: sensor.motion
to: 'on'

New Syntax (Multiple Triggers):

triggers:
- trigger:
event: sunset
trigger: state
entity_id: sensor.motion
to: 'on'

Notice how the plural form makes it clear that you’re dealing with multiple triggers. The same principle applies to conditions and actions.

By using the plural form for these sections, the Improved YAML syntax becomes more structured, especially in more complex automations. It’s like organizing your thoughts into distinct categories, which helps both beginners and advanced users manage automations more effectively.

Using the Graphical Editor

If you’re not comfortable writing YAML code directly, the graphical automations editor in Home Assistant will generate YAML for you, using the new syntax. This makes it super easy to create complex automations without having to worry about getting the syntax just right. I highly recommend using the graphical editor when possible—it saves time and ensures that your YAML is properly formatted.

Final Thoughts

The new & improved YAML syntax for Home Assistant automations is a welcome change for most users. It brings consistency, clarity, and ease of use, especially for those who are just getting started with Home Assistant. While the old syntax will continue to work, using the new plural format for triggersconditions, and actions is a smart move don’t you think?

Do you like the new syntax? Let me know in the comments below by typing a simple “Yes” or “No.” I’d love to hear your thoughts!


Join My Free Webinar

I’m excited to announce my upcoming Home Assistant webinar, where we’ll dive into pros & cons of the different Home Assistant installation methods plus I will reveal one super simple way to get started with Home Assistant on a PC in under 5 minutes.

Sign up now to reserve your spot – https://automatelike.pro/webinar

See you there or you can check my other Home Assistant articles.

1 thought on “Home Assistant Automations Improved YAML Syntax: Easier or More Complicated?”

  1. Hi could you make an example of automation using the graphic editor.
    Turn on the street lights at sunset and turn them off at sunrise.
    With two separate automations it works with a single automation no
    Sorry for my English but I used the translator.

Leave a Reply

Your email address will not be published. Required fields are marked *