SOLVED: Universal Media Player: volume_set issue

I am having issues with the Universal Media Player. I am trying to specify the entity for the “volume_set” service, but when I add the code I get the following error:

Failed to call service media_player/volume_set, expected float for dictionary value @ data[‘volume_level’]

Does anyone know what I can do to fix this? I am following the “volume_set” code from the example on the Home Assistant website.

Here is my config.yaml code:

#Living Room Denon HEOS Control
  - platform: universal
    name: Living Room Combined
    state_template: >
      {% if is_state('media_player.living_room', 'off') %}
      off
      {% else %}
      {{ states('media_player.living_rm_deck') }}
      {% endif %}
    children:
      - media_player.living_rm_deck
      - media_player.living_room
    commands:
      turn_on:
        service: media_player.turn_on
        data:
          entity_id: media_player.living_room
      turn_off:
        service: media_player.turn_off
        data:
          entity_id: media_player.living_room
      select_source:
        service: media_player.select_source
        data_template:
          entity_id: media_player.living_rm_deck
          source: '{{ source }}'
      volume_set:
        service: media_player.volume_set
        data:
          volume_level: '{{ volume_level }}'
          entity_id: media_player.living_rm_deck
      volume_up:
        service: media_player.volume_up
        data:
          entity_id: media_player.living_room
      volume_down:
        service: media_player.volume_down
        data:
          entity_id: media_player.living_room
#      volume_mute:
#        service: media_player.volume_mute
#        data:
#          entity_id: media_player.living_room
    attributes:
      is_volume_muted: media_player.living_room|is_volume_muted
      volume_level: media_player.living_room|volume_level 
      source: media_player.living_rm_deck|source
      source_list: media_player.living_rm_deck|source_list

Check the number passed in ‘volume_level’, perhaps it is sent as an integer instead of a float?

My code was incorrect for volume_set. For json data that has two items (like entity_id and volume_level) “data_template” must be used. I had “data”, which was causing an error.

Incorrect code I had:

  volume_set:
    service: media_player.volume_set
    data:
      volume_level: '{{ volume_level }}'
      entity_id: media_player.living_rm_deck

Correct Code:

    volume_set:
        service: media_player.volume_set
        data_template:
          volume_level: '{{ volume_level }}'
          entity_id: media_player.living_rm_deck

It’s not really about two lines. You use data_template if you are using a template like {{ volume_level }}