Message malformed: expected float for dictionary value @ data['value']

I have seen this error all over the place here but somehow I can’t apply the answers to my situation.
Like all the others I’d like to set a value based on a variable.
Below screenshot shows where I am coming from (point2) and what I want to do (point1)

I have tried quite a few variations, with quotes, without quotes, adding “data:”, whatever I found as proposed solution, but somehow don’t get any further.
In fact, I don’t understand why HA is complaining about a float in the first place? This is supposed to be an integer value but anyway, can’t get it to work in the UI and also not via the automation.yaml.

- id: '1736929362414'
  alias: 'Discharge: Allow'
  description: ''
  triggers: []
  conditions: []
  actions:
  - device_id: ecaf0cd09262b32282ffdb7fda3754b7
    entity_id: 39b174fbc1f1572e371e9cb01a0d57e2
    domain: number
    type: set_value
    value: "{{ states('input_number.batterymindischargesoc') | float }}"
  - device_id: ecaf0cd09262b32282ffdb7fda3754b7
    domain: number
    entity_id: b8ae709d170ec3d19d6dd6447fd87f48
    type: set_value
    value: 20
    …

Anyone got an idea what I might be missing?
Thanks

try float(0) or float(default=0)

You cannot use templates, at all, with device actions. Don’t use device actions. They may be easy to setup in the UI but the code they make is barely human readable.

Device actions don’t support templates.

1 Like

Ah, ok no device actions. So that probably means I need to edit the automation.yaml directly. Up to now device actions are the only type of automation I got, so couldn’t find any other yaml structure to reuse in automations.yaml. What should I look for instead? Any term I can search for here?

Apologies if this is a basic question, as you can probably tell, I am pretty new to HA

My bad…I have setup variables using entities.

actions:
  - action: timer.start
    metadata: {}
    data:
      duration: "{{ states('input_number.test_number') | int*60 }}"

No, you can use the visual editor for most things except figuring out the templates. But after you open the “Add action” picker, don’t go with the first option “Device” but find the category for the entity type you want to operate on and then pick the appropriate action from there.

For your actions you’d pick the Number category and then the action Set. While this may sound near identical to what you’re already doing, and looking very similar in the visual editor, when you go to inspect the YAML they are very different.

And that worked right away. Thank you very much!
Haven’t come across this approach until now, and you are right, the yaml looks a lot cleaner now. Very easy to edit and duplicate in fact