When and why is data written to the database every second?

Hi,

I have an automation that calls a script every second, that script itself has a count of 3 and a delay of "00:00:00.333", so it saves an image from a camera 3 times per second.

Does this mean that 86,400 (or actually 259,200) pieces of text are added to my database every day, since the input is written 3 times per second?

Automation:

alias: Continu buffer fill (3fps, 20 frames)
description: Continu buffer fill (3fps, 20 frames)
triggers:
  - seconds: /1
    trigger: time_pattern
actions:
  - action: script.buffer_capture_burst_3_frames
    data: {}
mode: single

Script:

alias: buffer_capture_burst_3_frames
sequence:
  - variables:
      idx: "{{ states('input_number.buffer_index_gif') | int }}"
  - repeat:
      count: 3
      sequence:
        - target:
            entity_id: camera.test
          data:
            filename: ........frame_{{ '%02d' | format(idx) }}.jpg
          action: camera.snapshot
        - data:
            entity_id: input_number.buffer_index_gif
            value: "{{ (idx % 20) + 1 }}"
          action: input_number.set_value
        - delay: "00:00:00.333"
        - variables:
            idx: "{{ states('input_number.buffer_index_gif') | int }}"

Input:
input_number.buffer_index_gif

When is something written to the database every second, and is it possible to disable that?

Maybe first explain what you are trying to accomplish with this? Because this should likely be solved by a card, not by scripts. For instance using advanced camera card.

It’s not directly about the camera action, but the principle.
I read that the history is set to 10 days by default. So, if an input_number gives a different value every second, will it add a maximum of 3600 x 24 x 10 = 864K entries to the database? Am I understanding that correctly?

Regarding the camera action: I built something similar about 9 years ago using Python and Bash on a Pi2. When the doorbell was pressed, a 4-second GIF was created, starting from the moment before the doorbell was pressed. I did this by continuously looping and saving 3 frames per second. When the doorbell was pressed, ffmpeg would make a GIF from the last 12 images (frames), which was then shared via Telegram. (There were some other tricks involved, but this is the general idea).

I was trying to make something similar with HA, but I was concerned that I might overload the database with counters.

Maybe overkill for what you need, but have you looked at frigate? It can record clips on movement or specific objects detected such as persons. If is highly customizable recorder software and the software is part of the Home Assistant family so integration is great.