Problem with media_player mute switch

Hello,
Please bear with me as this whole thing with a Home Assistant configuration is still very foreign to me.
I have managed to create some custom tiles which are representing buttons on my remote control.
I got the defined in a customize section like:

homeassistant:
  customize:
script.tv_control:
  custom_ui_state_card: state-card-tiles
  config:
    columns: 4
    rows: 2
    row_height: 85px
    column_width: 92px
    gap: 30px
    entities:
      - entity: switch.tv_power_toggle
        icon: mdi:power
        column: 1
        row: 1
      - entity: switch.tv_volume_toggle
        icon: mdi:volume-off
        column: 2
        row: 1

the power toggle finally started to work but I am struggling with mute/volume toggle and 2nd day getting errors.
Could someone be so kind and see where am I making a mistake please?
Below is a section corresponding to the code above:

switch:
  - platform: template
    switches:
      tv_power_toggle:
        friendly_name: "TV toggle power"
        value_template: "{{ is_state('media_player.tv', 'on') }}"
        turn_off:
          service: media_player.turn_off
          data:
            entity_id: media_player.tv
        turn_on:
          service: hdmi_cec.power_on
          data:
            entity_id: switch.hdmi_0
      tv_volume_toggle:
        data_template:
          entity_id: media_player.tv
          is_volume_muted: >-
            {%- if states.media_player.tv.attributes.is_volume_muted == false -%}
            true
            {%- else -%}
            false
            {%- endif -%}
        set_true:
          service: media_player.volume_mute
          data:
            entity_id: media_player.tv
            is_volume_muted: true
        set_false:
          service: media_player.volume_mute
          data:
            entity_id: media_player.tv
            is_volume_muted: false 

I would really appreciate your help.
Thanks