String does not match the pattern of "LEGACY_SYNTAX^"

While editing automations.yaml with Studio Code Server it shows the message:

String does not match the pattern of “LEGACY_SYNTAX^”

next to lines like:

  • platform: state
  • platform: device

Why is it complaining? How to fix?

Update:

I found that the legacy syntax issues will be fixed automatically, when the automation is (slightly) changed via the automation editor and then saved. The change then can be undone and the automation saved again.

3 Likes

Hi Bacchus,

I have a blog post and a video if you want to know more thru my process in fixing these, and yes, it you open in the ui editor and save, it will fix it all. I didn’t use that.

6 Likes

Thank you Sir! :slight_smile:

Most of it I already fixed yesterday, but I learned from you, that also condition has changed to conditions.
Strangely the editor didn’t complain about that, but it is now fixed, too.

2 Likes

Thanks for the question and answer! Just getting into proper HA programming. This was a top Google result, and solved an issue immediately. That balances out that other issues are taking way longer than expected. :stuck_out_tongue:

1 Like

Hmmm this page is not available to me. Can you please just put here a summary or maybe a link how to fix these errors?

Mine is like this

input:
    motion_sensor:
      name: Motion Sensor
      description: The motion sensor that triggers the snapshots
      selector:
        entity:
          domain: binary_sensor  << and here is the exact same error

Thanks
L:

Hi L>,

Nothing in that code quote has YAML affected by this change.
What exactly is not available to you?

The legacy syntax warning is telling you your code works, but you are using a legacy way of doing it not the modern way.
The code in that box is legacy and was changed years ago.

Do it the current way and the legacy warning will go away.
Selectors - Home Assistant.

Thank you. I’ll checkit. I just started this Blueprint journey so I’m a bit lame :slight_smile: Do you know any useful tool for exmple for vs-code which helps avoiding such issues and can speed up blueprint development?

Thx
L:

It’s a confusing error because it says the pattern does not match legacy syntax, when the error actually is that we are using legacy syntax. Got me caught up and confused as well.

2 Likes

I tried to tell that to he author, but English is not their primary language. Perhaps you could write an issue on that.

Hi SG,

I have a lot of template senors in packages.
F.e.:

template:
# track day-peaks:
  - trigger:
      - platform: time
        at: '00:00:00'
      - platform: state
        entity_id: sensor.fusionsolar_realtime_power_w
        not_to:
          - 'unavailable' 
          - 'unknown'
    sensor:
      - name: 'fusionsolar_daypeak'
        unique_id: 'fusionsolar_daypeak'
        unit_of_measurement: 'W'
        device_class: power
        state: >
          {{ [trigger.to_state.state | float(0), this.state | float(0)] | max
            if trigger.platform != 'time' else
            states('sensor.fusionsolar_realtime_power_w') | float(0) }}

This results in the LEGACY message:

I thought I have to change it like this (note - trigger (plural) and - trigger (single):

But it appears it should be like this:

Does this make sense?
Can I trust this change, and apply it to all my instances?

Thanks for advice!

brgds, L

1 Like

Right now it is working as intended-ish. I believe this will change in the Beta on Wednesday and if that works, the next release.
I see the same thing and heard there is a round 3 of clean-up happening.

I sure hope reformatting gets automated a bit. I tried the find/replace method mentioned above, but since some of my automations are already the new format, it isn’t working right.

If you have your stuff in the automation UI, it is automated. Otherwise not.

Advanced methods are generally on your own…

1., The hint helped, now most of the errors are gone. Many thanks. (BTW: what is the reason for the changes, do you know?)
2., I still have errors with other syntax things. Is there any “dictionary” to compare old and recent methods?(e.g: “hvac_mode”, friendly name, sequence, etc. is marked as “not allowed” what was working before.) Thanks

Hi Leon,

try with
triggers:

  • trigger:

In your sample there is

  • trigger:
    • trigger:

I can’t seem to get your webpage to come up?

This one?
How to Migrate Home Assistant 2024.8 & 2024.10 YAML Changes | What Are We Fixing Today?.

Is your pihole or adguard blocking it? I’m a YT creator and those programs tend to mess with our lives quite a bit…
Otherwise here’s the YT link. The description text is that same as my blog.

I found that with 2024.12.* I was getting errors with triggers and actions as documented on your site. I never did watch the video. I did get a “Configuration will not prevent Home Assistant from starting!” in Developer tools.

My old format:

  • trigger:

    • platform: event

    action:

    • service:

My new format:

  • trigger:

    • trigger: event

    action:

    • action:
3 Likes

In my scripts.yaml, I have the following code to create a switch that immediately (after 1 second) turns off again. Essentially, it’s like a push button that automatically returns to its 0 state.

toggle_button_with_reset:
  alias: Toggle Button with Reset
  sequence:
    - service: input_boolean.turn_on
      target:
        entity_id: input_boolean.my_button
    - delay: "00:00:01"  # Wait 1 second
    - service: input_boolean.turn_off
      target:
        entity_id: input_boolean.my_button

In my opinion, this code is correct, but I get the error “string does not match the pattern of LEGACY_SYNTAX” on both service lines. Does anyone have any idea how I should fix this issue? I’m a bit stuck. :frowning:

thanks!

Did you figure it out?