Stuck on small script which should be simple

I am trying to get this script to work:

p2:
  #Turn on P2
  alias: P2
  - service: media_player.select_source
    data_template:
      entity_id:
        - media_player.stue
      source: P2

And I get errors, of course:

Error loading /home/homeassistant/.homeassistant/configuration.yaml: while parsing a block mapping in “/home/homeassistant/.homeassistant/scripts.yaml”, line 3, column 3 expected , but found ‘-’ in “/home/homeassistant/.homeassistant/scripts.yaml”, line 4, column 3

My bet is that there’s a wrong indentaion or something there. I’m totally useless in YAML, can somebody please help me with this one?

You were forgetting some additional variables. Should work with the following code

script:
p2:
  #Turn on P2
  alias: P2
  sequence:
  - service: media_player.select_source
    data:
      entity_id: media_player.stue
      source: "P2"
1 Like

Thanks! :slight_smile: No error mesages now.

1 Like