Need help with configuration.yaml for media player

Hello everyone,

I have a problem with a switch that i’d like to get some help with. I have set up a switch template for controlling the input and volume of a audio receiver that has network control. The configuration.yaml looks as follows:

switch 1:
        - platform: template
          switches:
                  marantz_audioaux:
                          value_template: >
                                  {{ is_state_attr('media_player.tv_stue', 'source', 'AUX:Analog In') }}
                          turn_on:
                                  service: media_player.select_source
                                  data_template:
                                          entity_id: media_player.tv_stue
                                          source: 'AUX:Analog In'
                                  service: media_player.volume_set
                                  data:
                                          entity_id: media_player.tv_stue
                                          volume_level: 0.25
                          turn_off:
                                  service: media_player.select_source
                                  data_template:
                                          entity_id: media_player.tv_stue
                                          source: 'AUX:Analog In'
                                  service: media_player.volume_set
                                  data:
                                          entity_id: media_player.tv_stue
                                          volume_level: 0.25

The problem is that using this switch I get the following error:
marantz_audioaux: Error executing script. Invalid data for call_service at pos 1: extra keys not allowed @ data[‘source’]

Can anyone help me out?

Best regards,
Anders

See documentation how to perform multiple steps in a single action. Looks like you need to use

turn_on:
  sequence: 
    - service: media_player.select_source
      data_template: ...
    - service: ...

Thanks for the help here, sequence was not supported by swith template, but I managed to get this working.

The code should be:

switch 1:
        - platform: template
          switches:
                  marantz_audioaux:
                          value_template: >
                                  {{ is_state_attr('media_player.tv_stue', 'source', 'AUX:Analog In') }}
                          turn_on:
                                  - service: media_player.select_source
                                    data_template:
                                          entity_id: media_player.tv_stue
                                          source: 'AUX:Analog In'
                                  - service: media_player.volume_set
                                    data:
                                          entity_id: media_player.tv_stue
                                          volume_level: 0.25
1 Like