Service call in dashboard card behaves differently to in Developer tools -> Services

If I run:

show_name: true
show_icon: true
type: button
tap_action:
  action: call-service
  service: hive.boost_heating_on
  data:
    time_period: '01:00:00'
    temperature: '{{(states(''sensor.living_room_front_temperature'')|float+1.5)|float}}'
  target:
    entity_id: climate.living_room_front
name: button

in a card I get this error:
Failed to call service hive/boost_heating_on. expected float for dictionary value @ data[‘temperature’]

If I run:

service: hive.boost_heating_on
data:
  time_period: '01:00:00'
  temperature: '{{(states(''sensor.living_room_front_temperature'')|float+1.5)|float}}'
target:
  entity_id: climate.living_room_front

in Developer tools → Services I get no error and it behaves as intended.

The card is built using code editor rather than visual UI, and the service call is copied and pasted directly from the service call screen to ensure no silly typo’s etc.

Any ideas?

Most core cards do not accept templates. You will need to chain scripts or use an automation.

Thanks, being new to Home Assistant, your response didn’t immediately gel. However after some digging around and further playing (based upon your statement of automations), I have created a toggle helper (which I bind to the card), and then two automations, one to turn on and one to turn off - which execute when the toggle helper state changes.

Feels quite inefficient - three separate blocks of “code” to perform what is really just two very simple operations (api call for on and api call for off) which I’d typically bind into a single if statement. Is there a better way to do it (eg more complex branching in automations), or is this just “the way it is”?

Thanks.

If the Hive integration provides a means of knowing whether it is in “Boost” or not, then there is no need for a separate input boolean helper.

The two most common ways to create branched logic in scripts and automations are using the branching Actions (If/Then or Choose) or using templates.

There was nothing wrong with using a template, the limitation comes from the card you chose…

Button Cards can call scripts:

show_name: true
show_icon: true
type: button
tap_action:
  action: call-service
  service: script.toggle_heat_boost_living_room
name: button

The script can handle the templates and/or branching Actions:

alias: Toggle Heat Boost Living Room
sequence:
  - choose:
    - conditions:
        - alias: "Is it already in Boost Mode?"
          condition: state
          entity_id: HOWEVER_YOU_DETERMINE_THIS 
          state: 'on'
      sequence:
        - service: hive.boost_heating_off
          data: []
          target:
            entity_id: climate.living_room_front
    default:
      - service: hive.boost_heating_on
        data:
          time_period: '01:00:00'
          temperature: '{{ states(''sensor.living_room_front_temperature'') | float(0) + 1.5 }}'
        target:
          entity_id: climate.living_room_front