Input Number and MQTT

Hello Forum,
i started to connect my Arduino to Home Assistant using MQTT protocol.
I have to pass some parameters defined with input-number integration to Arduino then I create a button on the front end with the following code:

type: button
tap_action:
  action: call-service
  service: mqtt.publish
  service_data:
    topic: Hassio
    payload: '{{ states.input_number.box1.state | int }}'

The issue i am founding is that the payload is not the number of the input_number but it’s a string containing “{{ states.input_number.box1.state | int }}”.

What i did wrong?

Thanks in advance
Alessandro

well, it does not say explicitly in the docs that service_data accepts templates and it looks like HA does not do anything to the template and passes it as-is to the service in question.
you can easily work around it by calling a script that calls service: mqtt.publish with all necessary templates.

Solved! Thx
Alessandro

that’s great.
it would be even better if you could mark a post with a solution so others could find it quickly.
also, post your working code here to help the community.
cheers!