Problems when sending information from lovelace-template to shell_command

I have a script that logs chores to grocy trough a shell_command. The script is turned on by a tap_action in lovelace. Since I only want to list chores that are due today, I am using the addons auto-entities and template-entity-row. Everything works fine, except for the shell_command.

This is my config:

tap_action in lovelace:

tap_action:
  action: call-service
  service: script.grocy_track_chore
  service_data:
    id: '{{ state_attr("this.entity_id", ''chore'')[''id''] }}'

script.grocy_track_chore:

grocy_track_chore:
  sequence:
  - service: script.notify
    data_template:
      message: "{{ id }}"
  - service: shell_command.grocy_track_chore
    data_template:
      grocy_key: !secret grocy
      chore_id: "{{ id }}"
      tracked_time: "{{ now() }}"
  - delay: 1
  - service: homeassistant.update_entity
    entity_id: group.grocy

And shell_command.grocy_track_chore:

  grocy_track_chore: "curl -X POST http://192.168.0.129:9192/api/chores/{{chore_id}}/execute -H 'Accept: application/json' -H 'Content-Type: application/json' -H 'GROCY-API-KEY: {{grocy_key}}' -H 'cache-control: no-cache' -d '{ \"tracked_time\": {{tracked_time}},  \"done_by\": 0 }'"

If I try to run the script from services in developer tools, and add an ID, everything is working fine and the shell_command gets executed. But if I tap the sensor in lovelace I get this error:’

Error running command: `curl -X POST http://192.168.0.129:9192/api/chores/{{chore_id}}/execute -H 'Accept: application/json' -H 'Content-Type: application/json' -H 'GROCY-API-KEY: {{grocy_key}}' -H 'cache-control: no-cache' -d '{ "tracked_time": {{tracked_time}}, "done_by": 0 }'`, return code: 3

It looks like the template in shell_command is not getting sent through when I am running it from lovelace. I cannot understand why?

I also added a notify in my script to help debugging, and the message I receive looks the same, and contains a number, both when I type it in manually in service-calls and when I am running the script from lovelace.

The shell_command also works if I remove the template and replace it with a number, like this:

tap_action:
  action: call-service
  service: script.grocy_track_chore
  service_data:
    id: '9'

So I am pretty sure that I am doing something wrong with my template-code in tap_action, but I cannot figure out what, since everything looks good, and the same, on the notify-message I am receiving.

I think the problem is that the template in tap_action is passing the id as a string to the script and not as an integer. But there is something strange, because whenever I try to convert it to an int (or float), it just gives me 0, even if the ID is not 0:

chore_id: "{% set cid = id | int %} {{ cid }}"

Returns 0 everytime

chore_id: "{% set cid = id | float %} {{ cid }}"

Returns 0.0 everytime

I have also tried to convert before sending it, and it gives the correct number, but the error is the same (and I still gets 0 if I try to convert it again in the script):

tap_action:
  action: call-service
  service: script.grocy_track_chore
  service_data:
    id: '{{ state_attr("this.entity_id", ''chore'')[''id''] | int}}'