ESPhome DFplayer call service template

Hi all!
I have created a doorbell (D1 mini + dfplayer + speaker). I installed it with esphome, and it works properly. I would like to parameterize the dfplayer_play service with a template.
It works excellently under the development tools when I specify the file to be played via a template:

service: esphome.csengo_test_dfplayer_play
data: 
  file: "{{int(states.input_number.csengohang_fajl.state)}}"

But if I place this into the action of a button (or anything else):

type: button
tap_action:
  action: call-service
  service: esphome.csengo_test_dfplayer_play
  target: {}
  data:
    file: '{{int(states.input_number.csengohang_fajl.state)}}'

it doesn’t work.
I receive this message: “expected int for dictionary value @ data[‘file’]”

What am I doing wrong? Any idea?

THX

Why not put the automation in esphome and have it all together where it can work in the event HA is down or not working. Having entities, .mp3 files, dfplayer, speaker, doorbell all together and then essentially making it useless because all the logic/automations are in HA and wont work without HA. That IMO doesnt make sense.

The esp could be used to make your template button for whatever the reason is for it. The input_number could be made on the esp and then add the logic/automation and then HA isnt necessary for it to work, it all works from in the d1 mini yet, HA can still set your mp3/input_number but, isnt required anymore because it can now also be set from the d1 mini’s access point or web_server that doesnt require internet or HA.

Now if HA goes down it doesnt take your ability to control the dfplayer down with it or have any negative effect on it.