Automation - create timelapse via frigate for 3d printer

alias: 'Bambu A1 Mini: Create Print Timelapse'
description: Triggers a Frigate timelapse export when a print job finishes
triggers:
  - entity_id:
      - sensor.studio_a1_mini_print_status
    trigger: state
    from:
      - running
conditions: []
actions:
  - variables:
      start_time: >-
        {{ as_timestamp(states.sensor.studio_a1_mini_print_status.last_changed)
        -  (states.sensor.studio_a1_mini_print_progress.state | int(0) * 60) }}
      end_time: '{{ as_timestamp(now()) }}'
  - action: frigate.export_recording
    data:
      playback_factor: 10
      start_time: '{{ start_time | int(0) }}'
      end_time: '{{ end_time | int(0) }}'
      title: Print_{{ now().strftime('%Y%m%d_%H%M%S') }}
    target:
      entity_id: camera.printcam1

and the errors I get:

Bambu A1 Mini: Create Print Timelapse: Error executing script. Error rendering template for variables at pos 1: ValueError: Template error: int got invalid input '<template TemplateState(<state sensor.studio_a1_mini_print_progress=100; state_class=measurement, unit_of_measurement=%, friendly_name=A1 Mini Print progress @ 2026-08-18T22:02:42.644751-04:00>)>' when rendering template '{{ as_timestamp(states.sensor.studio_a1_mini_print_status.last_changed) - ((states.sensor.studio_a1_mini_print_progress) | int * 60) }}' but no default was specified
Bambu A1 Mini: Create Print Timelapse: Error executing script. Error rendering template for variables at pos 1: ValueError: Template error: int got invalid input '<template TemplateState(<state sensor.studio_a1_mini_print_progress=2; state_class=measurement, unit_of_measurement=%, friendly_name=A1 Mini Print progress @ 2026-08-18T22:07:51.916720-04:00>)>' when rendering template '{{ as_timestamp(states.sensor.studio_a1_mini_print_status.last_changed) - ((states.sensor.studio_a1_mini_print_progress) | int * 60) }}' but no default was specified
Bambu A1 Mini: Create Print Timelapse: Error executing script. Error rendering template for variables at pos 1: ValueError: Template error: int got invalid input '<template TemplateState(<state sensor.studio_a1_mini_print_progress=48; state_class=measurement, unit_of_measurement=%, friendly_name=A1 Mini Print progress @ 2026-08-18T22:31:27.567918-04:00>)>' when rendering template '{{ as_timestamp(states.sensor.studio_a1_mini_print_status.last_changed) - ((states.sensor.studio_a1_mini_print_progress) | int * 60) }}' but no default was specified
Bambu A1 Mini: Create Print Timelapse: Error executing script. Error rendering template for variables at pos 1: ValueError: Template error: int got invalid input '<template TemplateState(<state sensor.studio_a1_mini_print_progress=100; state_class=measurement, unit_of_measurement=%, friendly_name=A1 Mini Print progress @ 2026-08-19T06:36:38.619015-04:00>)>' when rendering template '{{ as_timestamp(states.sensor.studio_a1_mini_print_status.last_changed) - ((states.sensor.studio_a1_mini_print_progress) | int * 60) }}' but no default was specified
Bambu A1 Mini: Create Print Timelapse: Error executing script. Invalid data for call_service at pos 2: expected str for dictionary value @ data['playback_factor']

Thank you for your help.

The error doesn’t match the config you have provided…

The error includes the following:

states.sensor.studio_a1_mini_print_progress

… which will return the entire state object of the entity, which can’t be turned into an integer. Use the states() function:

states('sensor.studio_a1_mini_print_progress')

Sorry, I have been trying to fix it on my own. this is the latest version with the latest error:

alias: 'Bambu A1 Mini: Create Print Timelapse'
description: Triggers a Frigate timelapse export when a print job finishes
triggers:
  - entity_id:
      - sensor.studio_a1_mini_print_status
    trigger: state
    from:
      - running
conditions: []
actions:
  - variables:
      start_time: >-
        {{ as_timestamp(states.sensor.studio_a1_mini_print_status.last_changed)
        -  (states.sensor.studio_a1_mini_print_progress.state | int(0) * 60) }}
      end_time: '{{ as_timestamp(now()) }}'
  - action: frigate.export_recording
    data:
      playback_factor: 10
      start_time: '{{ start_time | int(0) }}'
      end_time: '{{ end_time | int(0) }}'
      title: Print_{{ now().strftime('%Y%m%d_%H%M%S') }}
    target:
      entity_id: camera.printcam1
 Error while executing automation automation.3d_printer_create_frigate_timelapse: expected str for dictionary value @ data['playback_factor'] 

and my “record” in frigate":

    record:
      enabled: true
      motion:
        days: 2
      export:
        timelapse_args: "-vf setpts=PTS/100 -r 30"
alias: 'Bambu A1 Mini: Create Print Timelapse'
description: Triggers a Frigate timelapse export when a print job finishes
triggers:
  - entity_id:
      - sensor.studio_a1_mini_print_status
    trigger: state
    from:
      - running
conditions: []
actions:
  - variables:
      start_time: >-
        {{ as_timestamp(states('sensor.studio_a1_mini_start_time')) - 
        (states('sensor.studio_a1_mini_print_progress') | int(0) * 60) }}
      end_time: '{{ as_timestamp(now()) }}'
  - action: frigate.export_recording
    data:
      playback_factor: 10
      start_time: '{{ start_time | int(0) }}'
      end_time: '{{ end_time | int(0) }}'
      title: Print_{{ now().strftime('%Y%m%d_%H%M%S') }}
    target:
      entity_id: camera.printcam1

something like this? I’m still getting the same dictionary error from the post above.