Automation help with setting an input_number

Dear Hive Mind,
what am I doing wrong here please ? I simply want the non-negative difference between two of my variables in one of my automations but input_number.diff never gets set when it the automation triggers. Thanks is advance.

action:

  • data:
    entity_id: input_number.diff
    value: ‘{{ ((states.input_number.bb.state|int)-(states.input_number.fb.state|int))|abs }}’
    service: input_number.set_value

Use data_template: instead of data:

Also please format your pasted code in future.

Thank you. That worked. Will try to remember to format the pasted code (this is my first time) in future.

1 Like