Can someone copy and paste this automation YAML and tell me if the Visual Editor is broken?

Home Assistant 2021.3.4

Whenever I use the following automation YAML in the “Edit in YAML” mode, when I save or refresh, it purges my transition template and just replaces it with “0”. I don’t see why this should be happening unless it is a bug?

alias: Turn off living room lights (movie)
description: ''
  - platform: state
    entity_id: media_player.plex_plex_for_apple_tv_entertainment_room
    to: playing
  - condition: state
    entity_id: media_player.plex_plex_for_apple_tv_entertainment_room
    state: Movies
    attribute: media_library_title
  - service: light.turn_off
      transition: {% if state_attr("media_player.plex_plex_for_apple_tv_entertainment_room",
        "media_position") < 60 %}6{% else %}2{% endif %}
        - light.tv_stand
        - light.side_table
        - light.hanging_lamp
mode: single

Steps to Reproduce

  1. Create an automation through the UI
  2. “Edit in YAML” in the top right menu
  3. Paste in this YAML
  4. Press “Save”
  5. Refresh
  6. “Edit in YAML” and confirm if the transition template is 0

Using the dated data_template key in place of data does not fix the problem.

The issue appears to be that the …

Visual editor is not supported for this configuration:

  • Templates not supported in visual editor

You can still edit your config in YAML.

… error message that normally locks it into YAML and does not allow the Visual Editor to take back control is not occurring.

The Visual Editor has a long-standing reputation for being unable to support all the things that can be done (with a YAML automation). It has recently improved significantly but still lacks the ability to support templates everywhere they are normally allowed.

Not a bug just a limitation.

1 Like

Your template is also incorrectly formatted. You need to use the multiline template indicator or wrap your template in quotes. If you wrap your template in quotes, you’ll need to use single quotes seeing that your interior quotes are double.