How to get value from input_number to a script for MQTT?

I made a ‘helper’ for an input number with a slider that I put on my lovelace ui.

I then made a script that calls my MQTT service with the following action, but the payload doesn’t get the number the I select in the ui.

payload: "{{ states('input_number.nap_length') }}"
qos: 1
topic: homeControl/parentNapLength

I’ve tried reading around the forums and I see people using the states controller, but for me the payload sent to mqtt is just the text of the payload field.

{{ states(“input_number.nap_length”) }}

It’s not actually grabbing the number from what I select in the input field.

Can someone point me in the right direction here?

payload_template: "{{ states('input_number.nap_length') }}"
qos: 1
topic: homeControl/parentNapLength

Perfect. I hate when I miss things so simple. But I think that made a couple things click in my mind about how templates work. Thanks so much!

1 Like