Help needed to set a Input Number helper to half an entity value in a script

I have this in a script that works

alias: Test
sequence:
  - service: input_number.set_value
    data:
      value: 200
    target:
      entity_id: input_number.half_current_power
mode: single

And I have this in my template editor that works

{%
 set half_power_level =
(states('sensor.grid_power_power') | float /2) | round (2)
%}
{{half_power_level}}

I want to take the sensor.grid_power_power divide by 2 and store it in the input_number.set_value helper

So close but so far

Regards Dave

try this:

alias: Test
sequence:
  - service: input_number.set_value
    data:
      value: >
        {% set half_power_level = (states('sensor.grid_power_power') | float /2) | round (2) %}
        {{half_power_level}}
    target:
      entity_id: input_number.half_current_power
mode: single

Brilliant works great, get the hang of templates one day, thank you so much.

Regards Dave

1 Like