A simple action to set a charge rate but no change made to entity

I have a pretty simple automation set up which, in theory, should set the relevant expected charge target based on the forecast for tomorrow using Solcast. I can set the charge target using a slider and that works fine, but I want to try to setup something a little more automatic.

This script appears to give a valid output when I push it through Developer tools, but doesn’t change the value of the entity (I’ve removed the trigger section, which is working):

action:
  - service: input_number.set_value
    target:
      entity_id: number.deye_sunsynk_sol_ark_capacity_point_1
    data:
      value_template: >
        {% set forecast = states('sensor.solcast_pv_forecast_forecast_tomorrow')
        | float(1) | int %}  {% if forecast >= 25 %}
          {{ 20 }}
        {% elif forecast <= 5 %}
          {{ 100 }}
        {% else %}
          {{ 100 - (forecast - 5) * 4 }}
        {% endif %}

Can anyone point out where I’m going wrong on what would appear to be a very simple task please? I’ve checked the trace and it shows an error:

Executed: April 28, 2024 at 9:22:07 AM
Error: extra keys not allowed @ data['value_template']
Result:
params:
  domain: input_number
  service: set_value
  service_data:
    value_template: 52
    entity_id:
      - number.deye_sunsynk_sol_ark_capacity_point_1
  target:
    entity_id:
      - number.deye_sunsynk_sol_ark_capacity_point_1

I think I should stick to my day-job!

Thanks

what happens when you change value_template to value?

Thanks. That appears to have stopped the error, but it still doesn’t amend the value of the entity

oh, I missed that you are using input_number.set_value to set a number. use input_number.set_value to set input_number (helper numbers).

use number.set_value instead to set a number entity