Harmony Hub Templating Command data attribute?

I am building a remote using ha-floorplan and would like to have a button which steps through a list of surround modes and sets the amplifier to that mode. Things are going OK until I try and template the command so I am looking for some help with this last step.

input_select:
  surround_mode:
    name: "Amplifier Surround Mode"
    options:
      - Sci-Fi
      - Movie
      - Music
      - DspMovie
      - DspMusic
    initial: Sci-Fi
script:
  change_surround_mode:
    alias: "Change Rumpus Amp Surround Mode"
    sequence:
      - service: input_select.select_next
        target:
          entity_id: input_select.surround_mode
      - service: remote.send_command
        data_template:
          entity_id: remote.rumpus_harmony_hub
          command: {{states.input_select.surround_mode.state}}
          device: Main Zone

In the template editor all is well but in am getting this error:
invalid key: "OrderedDict([('states.input_select.surround_mode.state', None)])" in "/config/packages/media.yaml", line 305, column 0

Anyone… Bueller…?

This might not actually be the cause of the error, but in general, jinja templates on a single line in yaml need to be in quotes.

Also, data_template: is deprecated, so you can just use data: now.

Then for consistency, if you’re going to use target for the entity_id in the first service call, I would probably use it in the second, although this is purely cosmetic, and it’s not actually required in either case.

And finally, although it probably doesn’t matter here, the general advice is to avoid states. when templating an entity value (see the warning about halfway down the page).

So you could try this, but I can’t guarantee it will work!

script:
  change_surround_mode:
    alias: "Change Rumpus Amp Surround Mode"
    sequence:
      - service: input_select.select_next
        target:
          entity_id: input_select.surround_mode
      - service: remote.send_command
        target:
          entity_id: remote.rumpus_harmony_hub
        data:
          command: "{{ states('input_select.surround_mode') }}"
          device: Main Zone
1 Like

Thanks Chris. It was the QUOTES!