HA making too many requests to /api/<camera>/latest.jpg

I have a working setup with Home Assistant 2024.3.0 and Frigate 0.13.2-6476f8a running on different computers.

Sometimes, I’ve noticed the Frigate machine gets bogged down. CPU is 100% pegged, and the log shows very frequent requests to /api/<camera>/latest.jpg coming from Home Assistant for one of my two cameras. It’s requesting dozens per second at least.

Normally, the CPU for the Frigate box is maybe 15% on this 8-core machine. But when this condition happens, all cores are pegged at 100%. Restarting either Home Assistant or Frigate will reset things back to normal with no other config changes. It might be fine for a long time. Then at some point it might climb back to 100% over 1.5 hours or so.

I’ve tried removing the camera from all dashboards. I’ve switched to using go2rtc for streaming the camera feed, and I’ve used both the picture entity and the Frigate custom card for the camera view. Nothing seems to fix it permanently.

Can anyone tell me what config in HA might affect how frequently these requests are made? I don’t know where else to look to understand why the requests are made at all, and why with such high frequency sometimes.

Thanks!

would be a good start to include your frigate config

Sure, including my cleaned up frigate config below. The problem hasn’t returned yet, but it often takes some days before it happens again.

mqtt:
  host: 000.000.000.000
logger:
  default: info
detectors:
  coral1:
    type: edgetpu
    device: pci

go2rtc:
  streams:
    driveway:
      - rtsp://user:[email protected]:554/cam/realmonitor?channel=1&subtype=0 
  webrtc:
    candidates:
      - 000.000.000.000:8555
      - stun:8555

cameras:
  frontdoor:
    ffmpeg:
      inputs:
        - path: rtsp://user:[email protected]:554/h264_hd.sdp
          roles:
            - detect
            - rtmp
    detect:
      width: 1280 
      height: 720 
    record:
      enabled: True
    snapshots:
      enabled: True
    objects:
      filters:
        person:
          threshold: 0.7

  driveway:
    ffmpeg:
      inputs:
        - path: rtsp://127.0.0.1:8554/driveway 
          roles:
            - detect
    detect:
      width: 2592 
      height: 1944
    objects:
      track:
        - person
        - dog
        - car
        - bicycle
      filters:
        car:
          mask: 383,212,367,43,71,84,119,257
        person:
          threshold: 0.77

    record:
      enabled: True
    snapshots:
      enabled: True
    zones:
      street:
        coordinates: 1196,0,610,0,392,99,397,209,131,263,0,331,0,547
      drive:
        coordinates: 2592,575,2592,1300,2339,1614,1906,1944,1649,1944,859,900,628,526,449,444,1196,151,1993,217
      sidewalk:
        coordinates: 1645,1944,877,890,0,1539,0,1944

I experience the same thing after updating from frigate 0.12 to 0.13 including the frigate integration etc. (no config change)
Here is what it looks like in frigate logs, interestingly it only happens for one camera (I have 3 cameras configured overall):

frigate    | 2024-03-31 20:56:05.428550912  192.168.188.4 - - [31/Mar/2024:20:56:05 +0200] "GET /api/hik-carport/latest.jpg HTTP/1.1" 200 122068 "-" "HomeAssistant/2024.3.3 aiohttp/3.9.3 Python/3.12" "-"
frigate    | 2024-03-31 20:56:05.866121558  192.168.188.4 - - [31/Mar/2024:20:56:05 +0200] "GET /api/hik-carport/latest.jpg HTTP/1.1" 200 122086 "-" "HomeAssistant/2024.3.3 aiohttp/3.9.3 Python/3.12" "-"
frigate    | 2024-03-31 20:56:05.878590343  192.168.188.4 - - [31/Mar/2024:20:56:05 +0200] "GET /api/hik-carport/latest.jpg HTTP/1.1" 200 122086 "-" "HomeAssistant/2024.3.3 aiohttp/3.9.3 Python/3.12" "-"
frigate    | 2024-03-31 20:56:05.880839155  192.168.188.4 - - [31/Mar/2024:20:56:05 +0200] "GET /api/hik-carport/latest.jpg HTTP/1.1" 200 122086 "-" "HomeAssistant/2024.3.3 aiohttp/3.9.3 Python/3.12" "-"
frigate    | 2024-03-31 20:56:05.884057888  192.168.188.4 - - [31/Mar/2024:20:56:05 +0200] "GET /api/hik-carport/latest.jpg HTTP/1.1" 200 122086 "-" "HomeAssistant/2024.3.3 aiohttp/3.9.3 Python/3.12" "-"
frigate    | 2024-03-31 20:56:05.927683325  192.168.188.4 - - [31/Mar/2024:20:56:05 +0200] "GET /api/hik-carport/latest.jpg HTTP/1.1" 200 122086 "-" "HomeAssistant/2024.3.3 aiohttp/3.9.3 Python/3.12" "-"
frigate    | 2024-03-31 20:56:05.927821637  192.168.188.4 - - [31/Mar/2024:20:56:05 +0200] "GET /api/hik-carport/latest.jpg HTTP/1.1" 200 122086 "-" "HomeAssistant/2024.3.3 aiohttp/3.9.3 Python/3.12" "-"

As you can see, that’s dozens of requests per second…
I tried disabling the frigate integration in HA, no change in behavior.

A restart of HA stops the requests. I can reproduce them as follows:

  • open detail view of camera in UI
  • observe these requests for updating the camera view

Closing the camera UI or navigating to another view does not stop the requests. Reloading the UI forcefully does stop them though.

Last update for today :wink:
I also observed it when using the frigate card for HA, for cameras with live feed configuration:


After changing this to
Bildschirmfoto 2024-03-31 um 21.12.40
for all cameras and reloading the page the requests stopped.
So it looks like it has something to do with the mechanism how HA creates the (standard) camera stream…

Glad to learn it’s not just me.
I made some dashboard changes and ended up re-added the frigate card. This time I used go2rtc when I setup the live stream since I had more recently set up go2rtc in Frigate. It’s possible I was using HA video stream before.

I haven’t seen the issue again lately, and maybe the live provider change is why. Thanks for sharing that detail.