Help with button card tap action- data needs to be an int

Apparently, this line:
valve: '{{ states(''input_number.sprinkler_valve_number'') | int }}'
does not return an int?

When I press the button, I get this error:
Failed to call service … expected int for dictionary value @ data[‘valve’]

Any hints would be appreciated.
Here is the button card configuration:

show_name: true
show_icon: true
type: button
tap_action:
  action: call-service
  service: esphome.sprinkler_controller_1_start_single_valve
  service_data:
    valve: '{{ states(''input_number.sprinkler_valve_number'') | int }}'
  target: {}
name: Start valve

It’s not possible to use templates for actions. You could call a script instead that has the templated value.

Thanks for the link to the docs.

If you don’t mind custom components, “Lovelace Card Templater” is on HACS and allows you to template service values and anything else.