Value template in Automation action not working

Hi,

I’ve created a template sensor to calculate the available charging current from PV for my wallbox. I’d like to use this value to automate the setting on my wallbox dynamically as generated power rises/falls.

The value (amps) are calculate in sensor.pv_current_wallbox. In the automation I check if the current value is >5 and <17 as this is the accepted range on the wallbox.

My automation (in automation.yaml) looks like this:

- id: "1686979181892"
  alias: Wallbox - Charging current
  description: ""
  trigger:
    - platform: state
      entity_id:
        - sensor.pv_current_wallbox
  condition:
    - condition: numeric_state
      entity_id: sensor.pv_current_wallbox
      above: 5
      below: 17
  action:
    - device_id: b58816f955af4e01aff72dccd9dd1485
      domain: number
      entity_id: number.wallbox_portal_max_charging_current
      type: set_value
      value: "{{ states('sensor.pv_current_wallbox') | int }}"
  mode: single

I can’t get it to work with the reference to the entity in the ‘value’ line. Checking the configuration in the developer tools does not show any errors and the template evaluates correctly. It also works if I change the value to a fixed int, e.g.

      value: 8

What am I doing wrong?

Regards
HoInDaHouse

Use a number.set_value service call rather than a device action.