Trouble with automation where editor removes ""

Hi,
I have a problem i’m not sure how to work around.
image
The To-value has a + in it so the automation won’t fire.
When i read the documentation there should be “” around the To-value.
But if i go into YAML-mode and add “Disney+” and save the editor removes “”.

I’m guessing the + is the problem since i have separate triggers on for example Netflix in the same automation, that works.

trigger:
  - platform: state
    entity_id: media_player.living_room_tv
    attribute: source
    to: Netflix
  - platform: state
    entity_id: media_player.living_room_tv
    attribute: source
    to: Twitch
  - platform: state
    entity_id: media_player.living_room_tv
    attribute: source
    to: SVT Play
  - platform: state
    entity_id: media_player.living_room_tv
    attribute: source
    to: Disney+

All but Disney+ works.

Anyone have an idea how to workaround this problem?

If the Automations YAML editor is removing double quotes from an attribute that contains special characters (+) and should be a string, then it sounds like a straight-up bug.

Does the same happen with single quotes (which don’t parse escape codes like \n)?

I’ve seen annoying rework of whitespace around more complex YAML like multi-line {{ templates }} formatted specially for readability.

Sadly single quotes is removed aswell.

What happens if you set your TV to Disney+ and check the state of media_player.living_room_tv attribute in the Developer Tools?

Does it show it as Disney+, Disney Plus or something else?

I checked that, it is with +
Used that way to know what to write in the automation.

Question is if the right place to fix this is in the lg tv integration so it instead would be Disney plus. Or is it better to have it changed in the automation editor so quotations is used like the docs say?
Easiest i would assume is change the lg tv integration?

I think we have different definitions of “Easiest”.

Getting a change pushed through to an integration involves multiple people and takes time.

Before proceeding with your plan, have you searched the other topics which mention LG? There are a few, and I don’t remember anyone mentioning issues with Disney+

the only work around I know would be to completely write the automation in yaml and bypass the UI editor completely for that automation. There are some things you need to do before you can do that tho.

first you need to create a new file in your config directory (where configuration.yaml is) and call it something readable like automations_yaml.yaml

then go to your configuration.yaml file and add an entry:

automation yaml: !include automations_yaml.yaml

then go to the automation you created in the UI and copy the yaml for it. Paste the code you just copied into the automations_yaml.yaml file you just created above. Ensure indentations are correct.

Add the quotes around your “Disney+” then save the file.

reload automations from the developers tools-yaml tab (do a config check first).

Your automation should show up your automations list with proper formatting maintained.

If it doesn’t show up but if not then do a full restart of HA.

Then you should probably submit an issue to the UI editor github.

2 Likes

Or only write this bit in YAML as a script then call the script from the Automation editor.

You should still report this issue here so it gets fixed:

4 Likes

Wouldn’t a template trigger work?

trigger:
  - platform: template
    value_template: "{{ state_attr('media_player.living_room_tv', 'source') == 'Disney+' }}"
2 Likes

Thank you, i did not think about that one, should work.
Will test this :slight_smile:
Thanks again.

Thank you all for suggestions.
I will report this issue.

1 Like