Configuration suddenly broke due to an existing script?

Hello all!

I am new to the Home Assistant game so I am learning as I go. I created a script a couple days ago and it was working as expected and I was getting no configuration errors. Then suddenly my configuration keeps giving me the following error:

"Invalid config for [script]: [action] is an invalid option for [script]. Check: script->script->1583173228512->action. (See /config/configuration.yaml, line 21). "

I am trying to have a script that toggles the mute on and off of a media player.

I did upgrade Home Assistant version and HassOS version when they appeared on the console. I have tried rolling back to 0.105.5 but the issue persists.

Here is my scripts.yaml config

'1583173228512':
  alias: 'Family Room Mute Toggle'
  sequence:
  action: call-service
  data_template:
    is_volume_muted: '{{ not state_attr(''media_player.family_room'', ''is_volume_muted'') }}'
    entity_id: media_player.family_room
    service: media_player.volume_mute 

Here is my main configuration.yaml

# Configure a default setup of Home Assistant (frontend, api, etc)
default_config:

#Uncomment this if you are using SSL/TLS, running in Docker container, etc.
#http:
#   base_url: example.duckdns.org:8123

# Text to speech
tts:
  - platform: google_translate

##Discovery##
discovery:

##Speedtest##
speedtestdotnet:

group: !include groups.yaml
automation: !include automations.yaml
scene: !include scenes.yaml
sensor: !include sensors.yaml
script: !include scripts.yaml

I have been reading through the forums and have worked through multiple issues that way but this one is stumping me. Mostly cause it worked fine for a day or 2 before it suddenly stopped.

Thanks so much for everyone’s help!

Remove this line

1 Like

That’s a configuration line for a Lovelace card, not a script. It’s never been valid in a script.

'1583173228512':
  alias: 'Family Room Mute Toggle'
  sequence:
    service: media_player.volume_mute 
      data_template:
        entity_id: media_player.family_room
        is_volume_muted: '{{ not state_attr("media_player.family_room", "is_volume_muted'") }}'

More information about scripts

Ok, thanks! Not sure how I had it working then, so weird.

My scripts.yaml config now looks like:

'1583173228512':
  alias: 'Family Room Mute Toggle'
  sequence:
    service: media_player.volume_mute
      data_template:
        entity_id: media_player.family_room
        is_volume_muted: '{{ not state_attr("media_player.family_room", "is_volume_muted'") }}'

but I am getting the following in the configurator:

“bad indentation of a mapping entry at line 5, column 20:
data_template:”
^
and this in my logs:
“mapping values are not allowed here
in “/config/scripts.yaml”, line 5, column 20”

“Invalid config for [script]: [data_template] is an invalid option for [script]. Check: script->script->1583173228512->data_template. (See /config/configuration.yaml, line 21).”

I really appreciate all your help. I have read through the scripts documentation, everything I read seems to imply this error is due to indentation formatting error but the indentations look right to a noob like me. :slight_smile:

I’d check the script docs, I just quickly hacked what you wrote. Probably I over indented the last three lines and it should have been:

'1583173228512':
  alias: 'Family Room Mute Toggle'
  sequence:
    service: media_player.volume_mute
    data_template:
      entity_id: media_player.family_room
      is_volume_muted: '{{ not state_attr("media_player.family_room", "is_volume_muted'") }}'/

I will play around with this and post my results.
Thanks so much!

I am all good to go

The issue ended up being there was an extra ’ in the code that did not show up in the configurator in HA but when I opened the YAML in Visual Studio Code I saw it.

I guess I learned the hard way not to use the configurator.

Thanks so much everyone for your help!