Camera Snapshot too old

I’m trying to send camera snapshot to telegram.
Automation works fine: creates timestamp variable, makes and saves snapshot to www folder, sends screenshot.
But image is not fresh.

For example: filename (= timestamp) is camera_20230526_150430.jpg, but timestamp on image is 2023/05/26 14:50:48.

Rtsp stream works fine, camera is configured properly, without any delays.
Difference between filename timestamp and timestamp on spanshot can be very different

I suppose HA saves and sends CACHED image. Any ideas how to fix it?
UPD: I suppose Caching happens on HA side, not camera side, because I see HA needs few (5-10) sec to load rtsp stream for lovelace card.

camera:
  - platform: generic
    name: "Camera-Vivotek"
    stream_source: "rtsp://192.168.1.5:554/live.sdp"
  action:
  - service: input_text.set_value
    entity_id: input_text.timestamp
    data:
      value: '{{ now().strftime("%Y%m%d_%H%M%S") }}'
  - delay:
      hours: 0
      minutes: 0
      seconds: 2
      milliseconds: 0
  - service: camera.snapshot
    data:
      filename: /config/www/camera/snapshots/camera_{{ states("input_text.timestamp") }}.jpg
    target:
      entity_id: camera.camera_vivotek
  - delay:
      hours: 0
      minutes: 0
      seconds: 2
      milliseconds: 0
  - service: telegram_bot.send_photo
    data:
      file: /config/www/camera/snapshots/camera_{{ states("input_text.timestamp") }}.jpg

Not a solution, but maybe a way to narrow things down: what happens when you take the camera offline for letssay 60 minutes, get it back online again and take a snapshot? Does it go back to the time when it was still online before the break? Or does it store a “fresh” image with a matching timestamp?

I don’t think the problem is caused by camera.
If I send 2 or more snapshots (one-by-one with some delay), all snapshots except first one is OK (filename ~ timestamp on image).
So, it seems that I need to wake up somehow rtsp stream in HA before saving and sending snapshot.

Hi i have same problem, that the first image is old because stream is not started , did you find a soultion

Hello,

I have the same problem, any solution?

1 Like

The only solution I found is to make 2 snapshots with little delay between them - one will be old and second will be OK.