blakeblackshear / frigate-hass-integration

Frigate integration for Home Assistant
MIT License
657 stars 110 forks source link

Frigate constantly disconnecting from Home Assistant #686

Closed clowncracker closed 2 weeks ago

clowncracker commented 4 weeks ago

System Info

custom_component: 5.2.0 Frigate: Unraid Docker Frigate Version: 0.13.2-6476f8a OS: HAOS HAOS: Unraid VM HA Version: 2024.06.1

Configuration

  host: xxx
  user: xxx
  password: xxx

go2rtc:
  streams:
    front_door:
      - "ffmpeg:http://xxx.xxx.x.xxx/flv?port=1935&app=bcs&stream=channel0_main.bcs&user=xxx&password=xxx#video=copy#audio=copy#audio=opus"
      - rtsp://http://xxx.xxx.x.xxx/Preview_01_sub
    garage:
      - "ffmpeg:http://xxx.xxx.x.xxx/flv?port=1935&app=bcs&stream=channel0_main.bcs&user=xxx&password=xxx#video=copy#audio=copy#audio=opus"
    office:
      - "ffmpeg:http://xxx.xxx.x.xxx/flv?port=1935&app=bcs&stream=channel0_main.bcs&user=xxx&password=xxx#video=copy#audio=copy#audio=opus"
  webrtc:
    candidates:
      - xxx.xxx.x.xx:8555
      - stun:8555

detectors:
  coral:
    type: edgetpu
    device: usb

cameras:
  front_door: 
    mqtt:
      timestamp: false
      bounding_box: false
      crop: true
      quality: 100
      height: 500
      required_zones:
        - entryway
    ffmpeg:
      output_args:
        record: preset-record-generic-audio-aac
      hwaccel_args: preset-vaapi
      inputs:
        - path: rtsp://127.0.0.1:8554/front_door?video=copy&audio=aac
          input_args: preset-rtsp-restream
          roles:
            - detect
            - record
    detect:
      width: 2560
      height: 1920
      fps: 5
    record:
      enabled: true
      retain:
        days: 14
        mode: all
    objects:
      track:
        - person
        - car
      filters:
        person:
          mask:
            - 438,916,469,598,556,260,656,0,922,0,1051,286,1028,669,1021,976,1023,1077,997,1111,924,1108,823,1103,611,1091,439,1082
            - 1151,1070,1171,1115,1271,1115,1480,1110,1768,1106,2115,1081,2301,1054,2299,872,2277,689,2236,522,2134,528,1897,471,1516,423,1156,426
        car:
          mask:
            - 438,916,469,598,556,260,656,0,922,0,1051,286,1028,669,1021,976,1023,1077,997,1111,924,1108,823,1103,611,1091,439,1082
            - 1151,1070,1171,1115,1271,1115,1480,1110,1768,1106,2115,1081,2301,1054,2299,872,2277,689,2236,522,2134,528,1897,471,1516,423,1156,426
    snapshots:
      enabled: true
    zones:
      entryway:
        coordinates: 2560,1920,2560,1681,2173,1506,1928,1579,1593,1321,930,1404,475,1307,321,1319,0,1319,0,1920
  garage: 
    ffmpeg:
      output_args:
        record: preset-record-generic-audio-aac
      hwaccel_args: preset-vaapi
      inputs:
        - path: rtsp://127.0.0.1:8554/garage?video=copy&audio=aac
          input_args: preset-rtsp-restream
          roles:
            - detect
            - record
    detect:
      enabled: true
      width: 2560
      height: 1920
      fps: 5
    record:
      enabled: true
      retain:
        days: 7
        mode: all
    objects:
      track:
        - person
      filters:
        person:
          mask:
            - 0,0,2560,0,2560,353,963,383,486,431,0,529
            - 216,1920,906,1920,627,978,268,1022,165,1617,160,1767
    snapshots:
      enabled: true
  office: 
    ffmpeg:
      output_args:
        record: preset-record-generic-audio-aac
      hwaccel_args: preset-vaapi
      inputs:
        - path: rtsp://127.0.0.1:8554/office?video=copy&audio=aac
          input_args: preset-rtsp-restream
          roles:
            - audio
            - detect
            - record
    audio:
      enabled: true
    detect:
      enabled: true
      width: 2560
      height: 1920
      fps: 5
    record:
      enabled: true
      retain:
        days: 7
        mode: all
      events:
        objects: []
    objects:
      track:
        - person
      filters:
        person:
          mask:
            - 465,237,173,300,292,945,549,908
    snapshots:
      enabled: false

Logs

Frigate logs

2024-06-09 18:12:50.771879801  [INFO] Starting Frigate...
2024-06-09 18:12:52.212367308  [2024-06-09 18:12:52] frigate.app                    INFO    : Starting Frigate (0.13.2-6476f8a)
2024-06-09 18:12:52.261603003  [2024-06-09 18:12:52] peewee_migrate.logs            INFO    : Starting migrations
2024-06-09 18:12:52.275977738  [2024-06-09 18:12:52] peewee_migrate.logs            INFO    : There is nothing to migrate
2024-06-09 18:12:52.281325525  [2024-06-09 18:12:52] frigate.app                    INFO    : Recording process started: 728
2024-06-09 18:12:52.282774571  [2024-06-09 18:12:52] frigate.app                    INFO    : go2rtc process pid: 88
2024-06-09 18:12:52.300080443  [2024-06-09 18:12:52] detector.coral                 INFO    : Starting detection process: 738
2024-06-09 18:12:52.301592366  [2024-06-09 18:12:52] frigate.app                    INFO    : Output process started: 740
2024-06-09 18:12:52.640974603  [2024-06-09 18:12:52] frigate.app                    INFO    : Camera processor started for front_door: 760
2024-06-09 18:12:52.641046403  [2024-06-09 18:12:52] frigate.app                    INFO    : Camera processor started for garage: 761
2024-06-09 18:12:52.641048257  [2024-06-09 18:12:52] frigate.app                    INFO    : Camera processor started for office: 762
2024-06-09 18:12:52.641110123  [2024-06-09 18:12:52] frigate.app                    INFO    : Capture process started for front_door: 764
2024-06-09 18:12:52.654611748  [2024-06-09 18:12:52] frigate.app                    INFO    : Capture process started for garage: 768
2024-06-09 18:12:52.654671376  [2024-06-09 18:12:52] frigate.app                    INFO    : Capture process started for office: 773
2024-06-09 18:12:52.654709200  [2024-06-09 18:12:52] frigate.app                    INFO    : Audio process started: 778
2024-06-09 18:12:54.914988938  [2024-06-09 18:12:52] frigate.detectors.plugins.edgetpu_tfl INFO    : Attempting to load TPU as usb
2024-06-09 18:12:54.917099133  [2024-06-09 18:12:54] frigate.detectors.plugins.edgetpu_tfl INFO    : TPU found

HA Logs


Logger: custom_components.frigate.api
Source: custom_components/frigate/api.py:244
integration: Frigate (documentation, issues)
First occurred: 6:42:05 PM (2 occurrences)
Last logged: 6:53:01 PM

Timeout error fetching information from http://xxx.xxx.x.xx:5000/api/stats:

Logger: custom_components.frigate
Source: helpers/update_coordinator.py:344
integration: Frigate (documentation, issues)
First occurred: 6:42:05 PM (2 occurrences)
Last logged: 6:53:01 PM

Error fetching frigate data:

Describe the bug

I'm getting these errors in my HA logs fairly constantly after updating to HA 2024.06.x. I don't know if something in HA changed, but I didn't have this issue before this update. Note that I restarted Home Assistant and Frigate to get fresh logs, but this happens every 10 minutes or so.

Debug log

2024-06-09 18:42:05.863 ERROR (MainThread) [custom_components.frigate] Error fetching frigate data: 
2024-06-09 18:48:19.043 DEBUG (MainThread) [custom_components.frigate] Finished fetching frigate data in 0.001 seconds (success: True)
2024-06-09 18:48:24.588 DEBUG (MainThread) [custom_components.frigate] Finished fetching frigate data in 0.547 seconds (success: True)
2024-06-09 18:48:29.043 DEBUG (MainThread) [custom_components.frigate] Finished fetching frigate data in 0.002 seconds (success: True)
2024-06-09 18:48:34.588 DEBUG (MainThread) [custom_components.frigate] Finished fetching frigate data in 0.546 seconds (success: True)
2024-06-09 18:48:39.043 DEBUG (MainThread) [custom_components.frigate] Finished fetching frigate data in 0.001 seconds (success: True)
2024-06-09 18:48:44.583 DEBUG (MainThread) [custom_components.frigate] Finished fetching frigate data in 0.542 seconds (success: True)
2024-06-09 18:48:49.042 DEBUG (MainThread) [custom_components.frigate] Finished fetching frigate data in 0.001 seconds (success: True)
2024-06-09 18:48:54.580 DEBUG (MainThread) [custom_components.frigate] Finished fetching frigate data in 0.538 seconds (success: True)
2024-06-09 18:48:59.042 DEBUG (MainThread) [custom_components.frigate] Finished fetching frigate data in 0.001 seconds (success: True)
2024-06-09 18:49:04.582 DEBUG (MainThread) [custom_components.frigate] Finished fetching frigate data in 0.541 seconds (success: True)
2024-06-09 18:49:09.044 DEBUG (MainThread) [custom_components.frigate] Finished fetching frigate data in 0.001 seconds (success: True)
2024-06-09 18:49:14.581 DEBUG (MainThread) [custom_components.frigate] Finished fetching frigate data in 0.540 seconds (success: True)
2024-06-09 18:49:19.043 DEBUG (MainThread) [custom_components.frigate] Finished fetching frigate data in 0.001 seconds (success: True)
2024-06-09 18:49:24.589 DEBUG (MainThread) [custom_components.frigate] Finished fetching frigate data in 0.548 seconds (success: True)
2024-06-09 18:49:29.044 DEBUG (MainThread) [custom_components.frigate] Finished fetching frigate data in 0.001 seconds (success: True)
2024-06-09 18:49:34.581 DEBUG (MainThread) [custom_components.frigate] Finished fetching frigate data in 0.540 seconds (success: True)
2024-06-09 18:49:39.042 DEBUG (MainThread) [custom_components.frigate] Finished fetching frigate data in 0.001 seconds (success: True)
2024-06-09 18:49:44.581 DEBUG (MainThread) [custom_components.frigate] Finished fetching frigate data in 0.540 seconds (success: True)
2024-06-09 18:49:49.043 DEBUG (MainThread) [custom_components.frigate] Finished fetching frigate data in 0.001 seconds (success: True)
2024-06-09 18:49:54.586 DEBUG (MainThread) [custom_components.frigate] Finished fetching frigate data in 0.545 seconds (success: True)
2024-06-09 18:49:59.042 DEBUG (MainThread) [custom_components.frigate] Finished fetching frigate data in 0.001 seconds (success: True)
2024-06-09 18:50:04.582 DEBUG (MainThread) [custom_components.frigate] Finished fetching frigate data in 0.541 seconds (success: True)
2024-06-09 18:50:09.043 DEBUG (MainThread) [custom_components.frigate] Finished fetching frigate data in 0.002 seconds (success: True)
2024-06-09 18:50:14.583 DEBUG (MainThread) [custom_components.frigate] Finished fetching frigate data in 0.542 seconds (success: True)
2024-06-09 18:50:19.042 DEBUG (MainThread) [custom_components.frigate] Finished fetching frigate data in 0.001 seconds (success: True)
2024-06-09 18:50:24.579 DEBUG (MainThread) [custom_components.frigate] Finished fetching frigate data in 0.538 seconds (success: True)
2024-06-09 18:50:29.042 DEBUG (MainThread) [custom_components.frigate] Finished fetching frigate data in 0.001 seconds (success: True)
2024-06-09 18:50:34.583 DEBUG (MainThread) [custom_components.frigate] Finished fetching frigate data in 0.541 seconds (success: True)
2024-06-09 18:50:39.043 DEBUG (MainThread) [custom_components.frigate] Finished fetching frigate data in 0.001 seconds (success: True)
2024-06-09 18:50:44.584 DEBUG (MainThread) [custom_components.frigate] Finished fetching frigate data in 0.543 seconds (success: True)
2024-06-09 18:50:49.043 DEBUG (MainThread) [custom_components.frigate] Finished fetching frigate data in 0.002 seconds (success: True)
2024-06-09 18:50:54.585 DEBUG (MainThread) [custom_components.frigate] Finished fetching frigate data in 0.543 seconds (success: True)
2024-06-09 18:50:59.043 DEBUG (MainThread) [custom_components.frigate] Finished fetching frigate data in 0.001 seconds (success: True)
2024-06-09 18:51:04.581 DEBUG (MainThread) [custom_components.frigate] Finished fetching frigate data in 0.540 seconds (success: True)
2024-06-09 18:51:09.044 DEBUG (MainThread) [custom_components.frigate] Finished fetching frigate data in 0.001 seconds (success: True)
2024-06-09 18:51:14.583 DEBUG (MainThread) [custom_components.frigate] Finished fetching frigate data in 0.542 seconds (success: True)
2024-06-09 18:51:19.042 DEBUG (MainThread) [custom_components.frigate] Finished fetching frigate data in 0.001 seconds (success: True)
2024-06-09 18:51:24.586 DEBUG (MainThread) [custom_components.frigate] Finished fetching frigate data in 0.544 seconds (success: True)
2024-06-09 18:51:29.042 DEBUG (MainThread) [custom_components.frigate] Finished fetching frigate data in 0.001 seconds (success: True)
2024-06-09 18:51:34.587 DEBUG (MainThread) [custom_components.frigate] Finished fetching frigate data in 0.546 seconds (success: True)
2024-06-09 18:51:39.043 DEBUG (MainThread) [custom_components.frigate] Finished fetching frigate data in 0.001 seconds (success: True)
2024-06-09 18:51:44.585 DEBUG (MainThread) [custom_components.frigate] Finished fetching frigate data in 0.543 seconds (success: True)
2024-06-09 18:51:49.043 DEBUG (MainThread) [custom_components.frigate] Finished fetching frigate data in 0.001 seconds (success: True)
2024-06-09 18:51:54.585 DEBUG (MainThread) [custom_components.frigate] Finished fetching frigate data in 0.543 seconds (success: True)
2024-06-09 18:51:59.043 DEBUG (MainThread) [custom_components.frigate] Finished fetching frigate data in 0.001 seconds (success: True)
2024-06-09 18:52:04.581 DEBUG (MainThread) [custom_components.frigate] Finished fetching frigate data in 0.539 seconds (success: True)
2024-06-09 18:52:09.042 DEBUG (MainThread) [custom_components.frigate] Finished fetching frigate data in 0.001 seconds (success: True)
2024-06-09 18:52:14.580 DEBUG (MainThread) [custom_components.frigate] Finished fetching frigate data in 0.538 seconds (success: True)
2024-06-09 18:52:19.042 DEBUG (MainThread) [custom_components.frigate] Finished fetching frigate data in 0.001 seconds (success: True)
2024-06-09 18:52:24.584 DEBUG (MainThread) [custom_components.frigate] Finished fetching frigate data in 0.543 seconds (success: True)
2024-06-09 18:52:29.043 DEBUG (MainThread) [custom_components.frigate] Finished fetching frigate data in 0.001 seconds (success: True)
2024-06-09 18:52:34.586 DEBUG (MainThread) [custom_components.frigate] Finished fetching frigate data in 0.545 seconds (success: True)
2024-06-09 18:52:39.042 DEBUG (MainThread) [custom_components.frigate] Finished fetching frigate data in 0.001 seconds (success: True)
2024-06-09 18:53:01.165 ERROR (MainThread) [custom_components.frigate.api] Timeout error fetching information from http://xxx.xxx.x.xx:5000/api/stats: 
2024-06-09 18:53:01.165 ERROR (MainThread) [custom_components.frigate] Error fetching frigate data: 
2024-06-09 18:53:01.165 DEBUG (MainThread) [custom_components.frigate] Finished fetching frigate data in 16.481 seconds (success: False)
2024-06-09 18:53:06.581 INFO (MainThread) [custom_components.frigate] Fetching frigate data recovered
2024-06-09 18:53:06.581 DEBUG (MainThread) [custom_components.frigate] Finished fetching frigate data in 0.540 seconds (success: True)
2024-06-09 18:53:11.044 DEBUG (MainThread) [custom_components.frigate] Finished fetching frigate data in 0.002 seconds (success: True)
Tan-tan-san commented 3 weeks ago

I too am having this issue after recently updating. Difference is I'm using HA OS and frigate in a docker container.

Core 2024.6.2

Supervisor 2024.06.0

Operating System 12.3

Frontend 20240610.0

Frigate: SYSTEM 0.13.2-69D9A261

HA Logs Log details (ERROR) This error originated from a custom integration. Logger: custom_components.frigate Source: helpers/update_coordinator.py:344 integration: Frigate (documentation, issues) First occurred: 12:52:20 PM (3 occurrences) Last logged: 1:48:47 PM

Error fetching frigate data:

clowncracker commented 3 weeks ago

I too am having this issue after recently updating. Difference is I'm using HA OS and frigate in a docker container.

Core 2024.6.2

Supervisor 2024.06.0

Operating System 12.3

Frontend 20240610.0

Frigate: SYSTEM 0.13.2-69D9A261

HA Logs Log details (ERROR) This error originated from a custom integration. Logger: custom_components.frigate Source: helpers/update_coordinator.py:344 integration: Frigate (documentation, issues) First occurred: 12:52:20 PM (3 occurrences) Last logged: 1:48:47 PM

Error fetching frigate data:

I'm using Frigate in an unraid Docker and Home Assistant in an unraid VM, so it sounds like we have the same setup.

clowncracker commented 3 weeks ago

@blakeblackshear any chance you can take a look at this?

blakeblackshear commented 3 weeks ago

Are you certain frigate is running without restarting itself?

clowncracker commented 3 weeks ago

Are you certain frigate is running without restarting itself?

Frigate itself isn't restarting at all, it's 100% stable. It's like the connection from Home Assistant to Frigate is unstable.

clowncracker commented 3 weeks ago

This keeps popping up in my logs. Is there anything I can do?

clowncracker commented 2 weeks ago

@blakeblackshear just wanted to follow up on this, it isn't getting any better. I'm getting hundreds of disconnects a day.

h3x1e commented 2 weeks ago

Having this issue too, Frigate is running but loses connection in Home Assistant.

Also started getting the "Detected Blocking Call" issue around the same time but thats from a Discord integration problem (I think).

It seems, random, nothing seems to trigger the disconnect.

` This error originated from a custom integration.

Logger: custom_components.frigate
Source: helpers/update_coordinator.py:344
integration: Frigate (documentation, issues)
First occurred: 20 June 2024 at 20:52:46 (57 occurrences)
Last logged: 08:25:20

Error fetching frigate data: `

My setup is running on Ubuntu Server with Frigate and Home Assistant Core running in Docker.

blakeblackshear commented 2 weeks ago

The integration doesn't maintain a persistent connection. It simply polls an endpoint every few seconds. Do you see a corresponding error in frigate's nginx logs?

h3x1e commented 2 weeks ago

I don't personally. I just see the usual and expected GET requests.

Its just strange that after the HomeAssistant update I'm now seeing the "Frigate Server Unavailable" "Frigate Server turned off" log messages, and it's also causing the Frigate cards to not display an image until I refresh Home Assistant.

blakeblackshear commented 2 weeks ago

If that's the case, then it seems like the integration is attempting to make an outbound network request, but it's never being received by Frigate. I'm not sure what changed in Home Assistant that would cause these timeouts. I just updated to 2024.6.3 to see if I can reproduce this. If I can't, I am not really sure where to look for issues or whether it's a problem with the integration or Home Assistant.

clowncracker commented 2 weeks ago

@h3x1e are you running the Mail and Packages addon? Even though it doesn't show in any debug logs, I think that might actually be the root cause of the issue. I disabled the addon for 12 hours and I haven't run into this issue since. I'm going to try reenabling it and see if I run into the issue again.

h3x1e commented 2 weeks ago

@clowncracker yes I am running it. Disabling it now to check!

h3x1e commented 2 weeks ago

It's been 15 hours since I disabled the Mail & Packages Integration, and Frigate in Home Assistant hasn't disconnected once. Something to do with the "Camera" part of the M&P Integration I guess, but idk.

clowncracker commented 2 weeks ago

I'm going to close this ticket, the issue wasn't with Frigate at all but with an unrelated addon. Sorry for assuming the worst of Frigate, I should have known better!

For anyone curious, it's being tracked here: https://github.com/moralmunky/Home-Assistant-Mail-And-Packages/issues/906