Using input_number value in automations to set entity

Hello everyone,

I’m trying to get my air purifier automate using home assistant. I have already some automations running to set the fan speed value to a number if the PPM2.5 value goes above some value.

There is of course another scripty that lowers the fan the PPM2.5 value goes below some value It was utill today a fixed number.

But now I’m trying to I want to have a input_number field and set the fan speed to that number instead of the fixed one.

I have tried many methods but all seem to fail and I get the following message when I try to save the script:

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

Here is my script:

alias: Purify Air Stop (PPM₂.₅ ≤ 2 → 🌬️400RPM)
description: Stops air purifier when certain threshold is reached
trigger:
...
...

condition:
...
...

action:
  - device_id: d9f29....
    domain: number
    entity_id: number.mi_air_purifier_3c_favorite_motor_speed
    type: set_value
    value: "{{ states('input_number.air_purifier_power_minutes') | int }}"
mode: single

What am I doing wrong ?

A Device Action doesn’t support templates.

Use a service call.

action:
  - service: number.set_value
    target:
      entity_id: number.mi_air_purifier_3c_favorite_motor_speed
    data:
      value: "{{ states('input_number.air_purifier_power_minutes') | int(0) }}"

Perfect ! Thank you very much for spotting my mistake

1 Like