Pass a formula into number.set_value service value

Hi,

I have a Tuya Thermostat that added a entity called number.gulamistabas_radiators.comfort_temperature and I am trying to build a simple user interface where I can adjust it with a + and - buttons.

The problem: To increase the temperature I call number.set_value service and try to pass {{ (states.number.gulamistabas_radiators_comfort_temperature.state) | int + 1 }} as its value, but I get this error: Failed to call service number/set_value. expected float for dictionary value @ data[‘value’]

As I understand the service expects a number but the value is a string. What can be done here to fix it?

My code:


tap_action:
  action: call-service
  service: number.set_value
  data:
    value: '{{ (states.number.gulamistabas_radiators_comfort_temperature.state) | int + 1 }}'
  target:
    entity_id: number.gulamistabas_radiators_comfort_temperature

1 Like

Try


    "{{ states('number.gulamistabas_radiators_comfort_temperature') |int + 1 }}"

Sadly still doesn’t work. After saving HA changes it to:

data:
    value: '{{ states(number.gulamistabas_radiators_comfort_temperature) | int + 1 }}'

My bad, I overlooked that you want to use it in a button action. This won’t work with the default Home Assistant cards.

I’m trying something very similar but within a YAML Automation and can’t seem to get a config that passes the syntax check. Any idea what I’m doing wrong here?

- service: number.set_value
  data:
    entity_id: number.retic_front_garden_time
    value: {{ states('input_number.retic_program2_station1_run_time') | int(0) }}

The outer quotes are missing.

Thank you!