Help with "Invalid config for [automation] " Error

Hi, This is my first post and I’m brand new to HA but not to home automation.
I’m getting this error when I check my configuration:
“Invalid config for [automation]: [service] is an invalid option for [automation]. Check: automation->action->0->service. (See ?, line ?).”

What am I doing wrong? I’d appreciate any suggestions.

My dir structure is this:
.
└── homeassistant
├── automations
│ ├── master_bath
│ │ ├── shower_music_sg_on.yaml

└── configuration.yaml

I have this include in my configuration.yaml:

automation: !include_dir_list automations

The “shower_music_sg_on.yaml” automation contains this. I’m playing a Sonos source when a switch is triple pressed after two Sonos speakers are grouped and volume set.

alias: "Turn on SG shower music"
trigger:
  platform: state
  entity_id: sensor.family_room_alcove_scene_state_1
  to: "Pressed 3 Times"
action:
  service: script.turn_on
  entity_id: script.group_mast_bed_bath_sonos
  delay: '00:00:01'
  service: script.turn_on
  entity_id: script.volume_50_mast_bed_bath_sonos
  delay: '00:00:02'  
  service: media_player.select_source
  data:
    - entity_id: media_player.master_bedroom
    - source: "Best of Coldplay"

Here are the two scripts that are called in the automation:

group_mast_bed_bath_sonos:
  alias: Group Master Bedroom and Bath Sonos
  sequence:
  - data:
      master: media_player.master_bedroom
    entity_id: media_player.master_bath
    service: sonos.join
volume_50_mast_bed_bath_sonos:
  alias: Set Volume of Master Bedroom & Bath Sonos to 50%
  sequence:
  - data:
      volume_level: 0.5
    entity_id:
    - media_player.master_bath
    - media_player.master_bedroom
    service: media_player.volume_set

Your automation actions need to be a list, like this

action:
  - service: script.turn_on
    entity_id: script.group_mast_bed_bath_sonos
  - delay: '00:00:01'
  - service: script.turn_on
    entity_id: script.volume_50_mast_bed_bath_sonos
  - delay: '00:00:02'  
  - service: media_player.select_source
    data:
      - entity_id: media_player.master_bedroom
      - source:  "Best of Coldplay"

Also you made an error with that last service call. It is an oxymoron.

Thanks ! Can you elaborate on what you mean by “…its is an oxymoron”

I’m pretty sure that’s a poke at your choice of music :wink:

LOL!! Maybe, I should change it to “Best of Bee Gees” and see what I get :smiley:

Yeah just my black sense of humour. Couldn’t resist.

1 Like

I’m getting this error now:
Error loading /config/configuration.yaml: mapping values are not allowed here
in “/config/automations/master_bath/shower_music_sg_on.yaml”, line 14, column 11

after changing the automation to:

alias: "Turn on SG shower music"
trigger:
  platform: state
  entity_id: sensor.family_room_alcove_scene_state_1
  to: "Pressed 3 Times"
action:
  - service: script.turn_on
    entity_id: script.group_mast_bed_bath_sonos
  - delay: '00:00:01'
  - service: script.turn_on
    entity_id: script.volume_50_mast_bed_bath_sonos
  - delay: '00:00:02'  
  - service: media_player.select_source
      data:
        - entity_id: media_player.master_bedroom
        - source: "Best of Coldplay"

Data and the two lines below it are indented two spaces too far. Look what I wrote, compare it to yours. Data lines up with service in my example.

I believe you should not have dashes before entity_id & source (and what @tom_l said about indentation.)

  - service: media_player.select_source
    data:
      entity_id: media_player.master_bedroom
      source: "Best of Coldplay"

Corrected it to match with your example - but now get this error:
Invalid config for [automation]: required key not provided @ data[‘action’]. Got None
required key not provided @ data[‘trigger’]. Got None. (See ?, line ?).
Invalid config for [automation]: expected dict for dictionary value @ data[‘action’][4][‘data’]. Got None. (See ?, line ?).

alias: "Turn on SG shower music"
trigger:
  platform: state
  entity_id: sensor.family_room_alcove_scene_state_1
  to: "Pressed 3 Times"
action:
  - service: script.turn_on
    entity_id: script.group_mast_bed_bath_sonos
  - delay: '00:00:01'
  - service: script.turn_on
    entity_id: script.volume_50_mast_bed_bath_sonos
  - delay: '00:00:02'  
  - service: media_player.select_source
    data:
      - entity_id: media_player.master_bedroom
      - source: "Best of Coldplay"

And, just noticed, you probably need a dash for the entire automation:

- alias: "Turn on SG shower music"
  trigger:
    platform: state
    entity_id: sensor.family_room_alcove_scene_state_1
    to: "Pressed 3 Times"
  action:
    - service: script.turn_on
      entity_id: script.group_mast_bed_bath_sonos
    - delay: '00:00:01'
    - service: script.turn_on
      entity_id: script.volume_50_mast_bed_bath_sonos
    - delay: '00:00:02'  
    - service: media_player.select_source
      data:
        entity_id: media_player.master_bedroom
        source: "Best of Coldplay"

Corrected again based on @pnbruckner suggestion and getting this error:

Invalid config for [automation]: required key not provided @ data[‘action’]. Got None
required key not provided @ data[‘trigger’]. Got None. (See ?, line ?).

alias: "Turn on SG shower music"
trigger:
  platform: state
  entity_id: sensor.family_room_alcove_scene_state_1
  to: "Pressed 3 Times"
action:
  - service: script.turn_on
    entity_id: script.group_mast_bed_bath_sonos
  - delay: '00:00:01'
  - service: script.turn_on
    entity_id: script.volume_50_mast_bed_bath_sonos
  - delay: '00:00:02'  
  - service: media_player.select_source
    data:
      entity_id: media_player.master_bedroom
      source: "Best of Coldplay"

Given that you have:

automation: !include_dir_list automations

Then forget what I said about adding a dash for the entire automation.

However, I’d strongly suggest changing it to:

automation: !include_dir_merge_list automations

Then it should have a dash (and each file can contain more than one automation.)

See: EXAMPLE: !INCLUDE_DIR_MERGE_LIST

That did it. Configuration is valid now when I changed to

automation: !include_dir_merge_list automations

in “configuration.yaml”

and included the dash with the “alias” line like so:

- alias: "Turn on SG shower music"
  trigger:
    platform: state
    entity_id: sensor.family_room_alcove_scene_state_1
    to: "Pressed 3 Times"
  action:
    - service: script.turn_on
      entity_id: script.group_mast_bed_bath_sonos
    - delay: '00:00:01'
    - service: script.turn_on
      entity_id: script.volume_50_mast_bed_bath_sonos
    - delay: '00:00:02'  
    - service: media_player.select_source
      data:
        entity_id: media_player.master_bedroom
        source: "Best of Coldplay"

Thanks everyone !!

1 Like