Cover.set_cover_position with input_number not working below Button

I am trying to control a shutter but I cannot control the position of it from a Button.
I created a Helper (input_number.target_pos) and I am using it in an Action commanded by a Button.
If I test in the Developer Tools everything seems fine:

  • In Template, if I write {{ states('input_number.target_pos') }} I obtain a result of type “number”
  • In Actions if I write:
    action: cover.set_cover_position target: device_id: 2d0828f02b139df4fd54c5b11c2d48f5 data: position: "{{ states('input_number.target_pos') | int }}"
    The shutter goes to the position.

When I try to use a Button, I get an error. I ran a lot of tests but I cannot understand what is wrong…
Last test:

show_name: true
show_icon: true
type: button
tap_action:
  action: perform-action
  target:
    device_id: 2d0828f02b139df4fd54c5b11c2d48f5
  data:
    position: "{{ states('input_number.target_pos') | int }}"
  perform_action: cover.set_cover_position
entity: cover.dining_room_shutter_output

Could someone help me?

Templates are not supported in almost any card actions. Move your templated action to a script, then call the script with the card action.

1 Like