Set Value with Input Number

Hi there!

I’m a bit stuck on an automation. Until now I use:

service: input_number.set_value
target:
  entity_id: input_number.slider_stove_target_temp
data:
  value: 22

… but I want wo replace the static value “22” by a input_number from a slider: “input_numer.slider_ofen_boosttemperatur”. But if I replace it…

value: input_numer.slider_ofen_boosttemperatur

I get the error “expected float for dictionary value @ data[‘value’]. Got None”. So I thought maybe I shoult convert it to float, but…

value: {{ input_numer.slider_ofen_boosttemperatur | float }}

…did not help. I was tinkering around with some variants, but did not get it correct. Anyone can help?

Best

Pascal

value: "{{ states('input_number.slider_ofen_boosttemperatur')|float(0) }}"

There are examples in the docs https://www.home-assistant.io/docs/configuration/templating/#states

Also spelling “number” correctly helps :wink:

1 Like

Damn… I of cause saw those docs. But mis-spelling “number” is a new kind of idiotic fault of mine. Thank you for helping me out. It works of cause now…

Wonder if you can help - I’m trying to do similar in a picture-element card

    title: '+10'
    style:
      '--mdc-typography-button-font-size': 20px
      color: white
      '--mdc-theme-primary': '#dddddd'
      top: 77.5%
      left: 92%
    service: input_number.set_value
    service_data:
      entity_id: input_number.my_points
      **value: "{{ states(''input_number.my_points'') + 10|float(0) }}"**

I’ve tried a few variants of this (both with and without the float but I seem to get a float error every time), also tried setting the step to simply increment in the card, but that didn’t work (I need step to remain as 1 generally)

Even ignoring the +10 and just trying to grab the value this fails…

I also tried this example over in the link and that failed too

{% set state = states('sensor.temperature') %}{{ state | float + 1 if is_number(state) else "invalid temperature" }}

I’m sure I’m missing something obvious, but I’m stuck

Core dashboard cards don’t support templates (other than the markdown card).

Urgh. Well that’s unnecessarily annoying…
Any way to do anything but increment by the predefined step then without creating a helper?

EDIT: Seems best way is a script (from over here [SOLVED] Increment Input Number by value of another Input Number - Configuration - Home Assistant Community (home-assistant.io))

1 Like

I get the same error. Trying to choose an input number instead of a value but it doesn’t help. I have some tv02 thermostats here where I can set a specific boost time. I want to enter a number in the dashboard i.e. 100 and than the thermostat should boost for 100 seconds. This is my automation:


alias: tv02 automation
description: ""
trigger:
  - platform: state
    entity_id:
      - input_number.tv02
condition: []
action:
  - device_id: b1e9e4be42ddac02bb6d0e22a8a174f9
    domain: number
    entity_id: number.thermostat_wz_boost_timeset_countdown
    type: set_value
    value: "{{ states('input_number.tv02') | float(0) }}"
mode: single

When trying to save the following error appears: “Message malformed: expected float for dictionary value @ data[‘value’]”

Device actions do not support templates. They have other problems too. Stop using them (and device triggers and conditions). In this case use the set value service instead.

1 Like

Thank you very much. I changed the code. Btw I used a lot of device triggers and actions. I will use more services in the future than. Thanks.

Solution:

alias: tv02 automation
description: ""
trigger:
  - platform: state
    entity_id:
      - input_number.tv02
condition: []
action:
  - service: number.set_value
    data:
      value: "{{ states('input_number.tv02') | float(0) }}"
    target:
      entity_id: number.thermostat_wz_boost_timeset_countdown
mode: single

Good idea. Here’s why, What happens if I have to replace a device - #2 by tom_l

You know you can just put the number in the dashboard and edit it without having to use an input number though?

1 Like

oh lol, didn’t think about that, thanks. I changed to the number.thermostat_wz_boost_timeset_countdown entity in the dashboard. :grinning:

1 Like

I have been fighting with HA for hours trying to set an entity to a value of an input helper where the UNHELPFUL error message kept asking for a float. I’d almost given up when I found this.

This type of of inconsistency in HA is what makes me want to throw it all in the bin. HA needs to fully commit one way or the other. All in with templating or not. I don’t care about “The year of the Voice Assistant”. I care about not wasting several hours due to inconsistent interface and unhelpful error messages.

Thank you. ‘Set value service’ worked for me.

I have an problem with automation and service input_number

alias: Keba Test
description: ""
trigger:
  - platform: state
    entity_id:
      - input_number.mokka_soc_zahler_start
condition: []
action:
  - service: input_number.set_value
    target:
      entity_id: input_number.mokka_soc_zahler
    data:
      value: "{{ states('input_number.mokka_soc_zahler_start') |float(0) }}"

When I start the automation by changing the trigger, the trace shows false

Ausgeführt: 9. Februar 2024 um 15:58:55
Ergebnis:
params:
  domain: input_number
  service: set_value
  service_data:
    value: 64
    entity_id:
      - input_number.mokka_soc_zahler
  target:
    entity_id:
      - input_number.mokka_soc_zahler
running_script: false

Nothing happens.

When I start only this action direct in the automation editor, it works!, the value is in the second number.

What is wrong?
And why works the same code so different?

I try to use button to change helper value input_number.ledsw with automation:

id: '1712101321528'
alias: New automation
description: ''
trigger:
  - device_id: 855e5e6c9cec2e77fb7b50d0dd264991
    domain: zha
    platform: device
    type: remote_button_short_press
    subtype: button_1
condition: []
action:
  - event: change value
    event_data:
      service: input_number.set_value
      target:
        entity_id: input_number.ledsw
      data:
        value: 55
mode: single

but nothing happens… I see that automation run, but value doesn’t change. What to do with that?