Help! Failed to call service climate/set_hvac_mode. required key not provided @ data['hvac_mode']

I know it’s late but, what am I doing wrong?

type: entities
show_header_toggle: false
entities:
  - entity: input_select.living_room_hvac_mode
  - type: call-service
    icon: 'mdi:thermostat'
    action_name: Change HVAC Mode...
    name: ' '
    service: climate.set_hvac_mode
    data_template:
      entity_id: climate.living_room
      hvac_mode: '{{ states.input_select.living_room_hvac_mode.state }}'

This looks like a lovelace config, you can’t just use templates in lovelace, you need a custom card to enable templating in lovelace.

Thanks. I installed that component but still having trouble…

type: 'custom:config-template-card'
variables: 
  hvac_mode: states.input_select.living_room_hvac_mode.state
entities:
    - input_select.living_room_hvac_mode
card:
  type: entities
  show_header_toggle: false
  entities:
    - entity: input_select.living_room_hvac_mode
    - type: call-service
      icon: 'mdi:thermostat'
      action_name: Change HVAC Mode...
      name: ' '
      service: climate.set_hvac_mode
      data:
        entity_id: climate.living_room
        hvac_mode: "${hvac_mode}"

But the UI is not accepting it. If I change it to:

type: 'custom:config-template-card'
variables: 
  hvac_mode: states.input_select.living_room_hvac_mode.state
entities:
    - input_select.living_room_hvac_mode
card:
  type: entities
  show_header_toggle: false
  entities:
    - entity: input_select.living_room_hvac_mode
    - type: call-service
      icon: 'mdi:thermostat'
      action_name: Change HVAC Mode...
      name: ' '
      service: climate.set_hvac_mode
      data:
        entity_id: climate.living_room
        hvac_mode: heat

…the editor is happy. Am I doing something wrong or is it not supported??

What I am trying to do is use a button to pop up another screen or dialogue where you select the mode from input_select and then click action to call the service to set the climate mode.

You’re making up syntax. There is no call-service type for entities. I’m assuming you just want an button, so you want to use the syntax for an button for special row elements.

  type: entities
  show_header_toggle: false
  entities:
    - entity: input_select.living_room_hvac_mode
    - type: button
      icon: 'mdi:thermostat'
      action_name: Change HVAC Mode...
      name: ' '
      tap_action:
        action: call-service
        service: climate.set_hvac_mode
        service_data:
          entity_id: climate.living_room
          hvac_mode: heat

Making up syntax? Just trying to do the UN-doable!!

I abandoned that exact approach and looked into browser-mod…
I now have custom more info popup cards to call my services:

  - title: Environment
    path: environment
    icon: 'hass:thermostat'
    theme: ''
    badges: []
    popup_cards:
      sensor.living_room_hvac_mode:
        title: ' '
        card:
          style: |
            .card-header {
              line-height: 20px;
            }
            .card-header .name {
              font-size: 14px;
              color: gray;
            }
          type: entities
          show_header_toggle: false
          title: 'Set thermostat to:'
          entities:
            - type: button
              icon: 'mdi:fire'
              action_name: Heat
              name: ' '
              tap_action:
                action: call-service
                service: climate.set_hvac_mode
                service_data:
                  entity_id: climate.living_room
                  hvac_mode: heat
            - type: button
              icon: 'mdi:power'
              action_name: 'Off'
              name: ' '
              tap_action:
                action: call-service
                service: climate.set_hvac_mode
                service_data:
                  entity_id: climate.living_room
                  hvac_mode: 'off'

      sensor.living_room_preset_mode:
        title: ' '
        card:
          style: |
            .card-header {
              line-height: 20px;
              font-size: 14px;
              white-space: normal;
              text-align: center;
            }
            .card-header .name {
              font-size: 14px;
              color: gray;
              white-space: normal !important;
              text-align: center;
            }
          type: entities
          show_header_toggle: false
          title: >-
            Save energy by using Eco Temperatures when no one's home. Or turn
            them on manually any time.
          entities:
            - type: button
              icon: 'mdi:leaf'
              action_name: START ECO
              name: ' '
              tap_action:
                action: call-service
                service: climate.set_preset_mode
                service_data:
                  entity_id: climate.living_room
                  hvac_mode: eco
            - type: button
              icon: 'mdi:leaf-off'
              action_name: STOP ECO
              name: ' '
              tap_action:
                action: call-service
                service: climate.set_preset_mode
                service_data:
                  entity_id: climate.living_room
                  hvac_mode: none

          - type: horizontal-stack
            cards:
              - type: 'custom:button-card'
                entity: sensor.living_room_hvac_mode
                name: MODE
                show_name: true
                tap_action:
                  action: more-info
                color_type: icon
                state:
                  - operator: template
                    value: >
                      [[[ return states['climate.living_room'].state === 'off'
                      ]]]
                    icon: 'mdi:none'
                    color: white
                  - operator: template
                    value: >
                      [[[ return states['climate.living_room'].state === 'heat'
                      ]]]
                    icon: 'mdi:none'
                    color: 'rgb(239, 140, 0)'
                  - operator: template
                    value: >
                      [[[ return states['climate.living_room'].state === 'cool'
                      ]]]
                    color: blue
                    icon: 'mdi:none'
                show_state: false
                style: |
                  ha-card {
                    font-size: 85% !important;
                    color: white;
                    background:
                    {% if is_state_attr('climate.living_room', 'hvac_action', 'heating') %}
                      #EB6D00 ;
                    {% else %}
                      {% if is_state_attr('climate.living_room', 'hvac_action', 'cooling') %}
                        #0055FF ; 
                      {% else %}
                        #373F48;
                      {% endif %}
                    {% endif %}
                    box-shadow: none;
                  }
                  ha-icon {
                    background-image: url("data:image/svg+xml;charset=utf-8,%3Csvg xmlns='http://www.w3.org/2000/svg' width='24.1' height='24.1' viewBox='-282.6 655.7 611.9 511.8' fill='%23FFF'%3E%3Cpath d='M235.4 1039.5c-38.3 30.7-76.8 46.1-117.7 46.1-51.2 0-99.7-23-153.5-74.2-61.4-58.8-127.9-110-194.5-110-12.8 0-25.6 2.6-38.4 5.1-2.3.7-5.7 1-7.6-2.6-1.7-3.2 0-5.1 2.6-7.6 38.3-30.7 76.8-46.1 117.7-46.1 51.2 0 99.7 23 153.5 74.2 61.3 58.8 127.8 110 194.4 110 12.8 0 25.6-2.6 38.3-5.1 2.8-.5 5.9-1.2 7.6 2.6 1.6 3.3.1 5.1-2.4 7.6zM-194.5 991c38.3 0 76.8 18 115.2 56.3 46.1 43.5 97.2 84.4 145.9 84.4 10.2 0 20.5-2.6 28.2-5.1 2.6-.7 4.6.1 5.7 2.1 1.7 3.1-.6 5.6-.6 5.6-28.2 23-58.8 33.2-87 33.2-38.3 0-76.8-18-115.2-56.3-46.1-43.5-97.2-84.4-145.9-84.4-10.2 0-20.4 2.9-28.2 5.1-2.3.7-4.2.7-5.7-2.3-1.5-2.8.6-5.3.6-5.3 28.1-20.6 56.3-33.3 87-33.3zM327.4 799c-28.2 23-58.8 33.2-87 33.2-38.3 0-76.8-18-115.2-56.3-46-43.4-97.1-84.4-145.8-84.4-10.2 0-20.5 2.6-28.2 5.1-2.2.7-4.3.2-5.6-1.8-2.2-3.5.5-5.9.5-5.9 28.2-23 58.8-33.2 87-33.2 38.3 0 76.8 18 115.2 56.3 46.1 43.5 97.2 84.4 145.9 84.4 10.2 0 20.5-2.6 28.2-5.1 2.1-.8 4.3-1.1 5.7.7 1.5 2.1 1.9 4.5-.7 7zM81.9 811.9c61.4 58.8 127.9 110 194.5 110 12.8 0 25.6-2.6 38.3-5.1 2.6-.7 5.7-1.2 7.6 2.6 1.6 3.1 0 5.1-2.6 7.6-38.4 30.7-76.8 46-117.7 46-51.2 0-99.7-23-153.5-74.2-61.4-58.8-127.9-110-194.5-110-12.8 0-25.6 2.6-38.3 5.1-2.6.7-5.7.7-7.6-2.6-1.8-3.1 0-5.1 2.6-7.6 38.3-30.7 76.8-46.1 117.7-46.1 51.1 0 99.7 23.1 153.5 74.3z'/%3E%3C/svg%3E");
                    background-position: 25%;
                    background-position-x: 50%;
                    background-position-y: center;
                    background-repeat: no-repeat;
                    height: 44px;
                    margin: 0 
                    auto 3px;
                    width: 26px;            
                    }
              - type: 'custom:button-card'
                entity: sensor.living_room_preset_mode
                name: ECO
                label: ECO
                tap_action:
                  action: more-info
                color_type: icon
                color: green
                icon: 'mdi:none'
                state:
                  - operator: template
                    value: >
                      [[[ return
                      states['climate.living_room'].attributes.preset_mode ==
                      'none' ]]]
                    icon: 'mdi:none'
                    color: white
                show_state: false
                show_name: true
                style: |
                  ha-card {
                    font-size: 85% !important;
                    color: white;
                    background:
                    {% if is_state_attr('climate.living_room', 'hvac_action', 'heating') %}
                      #EB6D00 !important;
                    {% else %}
                      {% if is_state_attr('climate.living_room', 'hvac_action', 'cooling') %}
                        #0055FF !important; 
                      {% else %}
                        #373F48 !important;
                      {% endif %}
                    {% endif %}
                    box-shadow: none;
                  }  
                  ha-icon { 
                    background-image: url("data:image/svg+xml;charset=utf-8,%3Csvg xmlns='http://www.w3.org/2000/svg' width='24.1' height='24.1' viewBox='0 0 26 24' fill='%23FFF'%3E%3Cpath class='st0' d='M.8 20.7c6.3 4.5 13.1 4.7 19-1.7 6.1-6.5 6.4-14.5 6.2-19-3.3 4-9.5 2.2-18.2 5C1 7.2.1 15.3 0 18.7c1.6-1.7 4.6-4.5 8.5-5.9 6.2-2.3 8.9-2.3 12.6-5.1-2.3 2.6-5.3 4.1-11.1 6.2-4.2 1.5-7.9 5.3-9.2 6.8z'/%3E%3C/svg%3E"); 
                    background-position: 25%;
                    background-position-x: 50%;
                    background-position-y: center;
                    background-repeat: no-repeat;
                    height: 44px;
                    margin: 0 
                    auto 3px;
                    width: 26px;            
                  }

I have a similar problem here…
I can change the state from “off” to “heat” but not vice versa.

tap_action:
  action: call-service
  service: climate.set_hvac_mode
  service_data:
    entity_id: '[[[ return variables.entity ]]]'
    hvac_mode: |
      [[[
        if (states[variables.entity].state == "off"){
          return 'heat';
        } else if (states[variables.entity].state == "heat"){
          return 'off';
        }
      ]]]

There’s no need for an else if there. Just change it to else.