Float expected?

There are strange things going on… Just to make it easier, I reduced a script to makes this test.

Here is the simple script

alias: 'Switch : Airco float'
fields:
  temperature:
    description: The temperature to set the airco at
    default: 19
    example: 21
sequence:
  - service: climate.set_temperature
    data:
      temperature: '{{ temperature }}'
    target:
      entity_id: climate.airco_gang
description: Set airco temperature
mode: single

Calling this script from a button like this works fine

type: button
tap_action:
  action: call-service
  service: script.switch_airco_float
  service_data:
    temperature: 20
  target: {}
name: Test gang

Replacing the 20 degrees by a helper gives me an error about “float expecting” ?

type: button
tap_action:
  action: call-service
  service: script.switch_airco_float
  service_data:
    temperature: '{{ states(''input_number.temperatuur_airco_gang'')|float}}'
  target: {}
name: Test gang

Schermafbeelding 2021-12-28 082523

You cannot use templates in basic Lovelace (except markdown card).

Ah OK…sorry, but I’m beginner…what do you mean with “expect markdown card”, could you give an example ?

In fact, I was trying the script. I don’t understand why I get an error when I run it

Schermafbeelding 2021-12-28 112327

Typo, I meant “except”

Well, {{temperature }} is not defined when you just use “Run Script”
I suppose it should use the default, but apparently it doesn’t

Why don’t you put the helper in the script ?

sequence:
  - service: climate.set_temperature
    data:
      temperature: '{{ states(''input_number.temperatuur_airco_gang'')|float}}'
    target:
      entity_id: climate.airco_gang
description: Set airco temperature
mode: single

And the button would look :

type: button
tap_action:
  action: call-service
  service: script.switch_airco_float
name: Test gang

You don’t even need the fields :slight_smile:

BTW, for float filter you need now to set a default => any_value|float(default=0)

No, because this script is in fact larger. It accepts not only the temperature but also the entity-id.

All of a sudden the script doesn’t work anymore and I donn’t know why.

This is the script :

alias: 'Switch : Airco x op y graden'
description: Set airco mode to heat and set temperature
fields:
  temperature:
    description: The temperature to set the airco at
    default: '{{ states(''input_number.temperatuur_airco_gang'')}}'
    example: 21
  entity_id:
    description: The climate entity you want to control
    default: climate.airco_gang
    example: climate.airco_gang
sequence:
  - service: climate.turn_on
    target:
      entity_id: '{{ entity_id }}'
  - service: climate.set_hvac_mode
    target:
      entity_id: '{{ entity_id }}'
    data:
      hvac_mode: heat
  - service: climate.set_temperature
    data:
      temperature: '{{ temperature }}'
    target:
      entity_id: '{{ entity_id }}'
  - service: climate.set_fan_mode
    data:
      fan_mode: auto
    target:
      entity_id: '{{ entity_id }}'
mode: single

When I click on “Run Script” I get these errors in de log :