blakeblackshear / frigate-hass-integration

Frigate integration for Home Assistant
MIT License
725 stars 114 forks source link

Integration whit homeassistant doesn't work #494

Closed DylanHP closed 1 year ago

DylanHP commented 1 year ago

Integration whit homeassistant doesn't work

When I try to get HomeAssistant to reconise my frigate installation, in my case is installed at 192.168.1.12:9200, I get this in response:

Error fetching information from http://192.168.1.12:9200/api/stats: Cannot connect to host 192.168.1.12:9200 ssl:default [Connect call failed ('192.168.1.12', 9200)]

but when I try to read the api stats I get this:

{"Cortile":{"camera_fps":24.1,"capture_pid":300,"detection_enabled":0,"detection_fps":0.0,"ffmpeg_pid":308,"pid":296,"process_fps":24.1,"skipped_fps":0.0},"Garage":{"camera_fps":0.0,"capture_pid":301,"detection_enabled":0,"detection_fps":0.0,"ffmpeg_pid":3017,"pid":298,"process_fps":0.0,"skipped_fps":0.0},"cpu_usages":{"%Cpu(s):":{"cpu":"id,","mem":"0.4"},"1":{"cpu":"0.0","mem":"0.0"},"102":{"cpu":"5.3","mem":"0.9"},"114":{"cpu":"0.0","mem":"0.1"},"134":{"cpu":"0.0","mem":"0.0"},"135":{"cpu":"0.0","mem":"0.0"},"136":{"cpu":"0.0","mem":"0.0"},"137":{"cpu":"0.0","mem":"0.0"},"15":{"cpu":"0.0","mem":"0.0"},"17":{"cpu":"0.0","mem":"0.0"},"24":{"cpu":"0.0","mem":"0.0"},"25":{"cpu":"0.0","mem":"0.0"},"26":{"cpu":"0.0","mem":"0.0"},"27":{"cpu":"0.0","mem":"0.0"},"28":{"cpu":"0.0","mem":"0.0"},"284":{"cpu":"0.0","mem":"0.5"},"29":{"cpu":"0.0","mem":"0.0"},"290":{"cpu":"1.0","mem":"0.1"},"291":{"cpu":"0.0","mem":"1.8"},"293":{"cpu":"2.0","mem":"0.5"},"296":{"cpu":"6.0","mem":"0.5"},"297":{"cpu":"0.0","mem":"0.3"},"298":{"cpu":"0.0","mem":"0.5"},"299":{"cpu":"0.0","mem":"0.1"},"30":{"cpu":"0.0","mem":"0.0"},"300":{"cpu":"6.6","mem":"0.5"},"301":{"cpu":"0.0","mem":"0.5"},"3011":{"cpu":"0.0","mem":"0.0"},"3028":{"cpu":"0.0","mem":"0.1"},"3031":{"cpu":"0.0","mem":"0.0"},"3032":{"cpu":"0.0","mem":"0.0"},"3035":{"cpu":"0.0","mem":"0.0"},"305":{"cpu":"0.0","mem":"0.2"},"308":{"cpu":"5.0","mem":"0.2"},"31":{"cpu":"0.0","mem":"0.0"},"319":{"cpu":"1.0","mem":"0.1"},"32":{"cpu":"0.0","mem":"0.0"},"41":{"cpu":"0.0","mem":"0.0"},"42":{"cpu":"0.0","mem":"0.0"},"78":{"cpu":"0.0","mem":"0.0"},"81":{"cpu":"0.0","mem":"0.0"},"82":{"cpu":"0.0","mem":"0.0"},"88":{"cpu":"0.0","mem":"0.1"},"97":{"cpu":"0.0","mem":"0.0"},"MiB":{"cpu":"1679.8","mem":"avail"},"PID":{"cpu":"%CPU","mem":"%MEM"},"Tasks:":{"cpu":"stopped,","mem":"1"},"top":{"cpu":"average:","mem":"0.45,"}},"detection_fps":0.0,"detectors":{"ov":{"detection_start":0.0,"inference_speed":25.04,"pid":291}},"service":{"last_updated":1685919250,"latest_version":"0.12.0","storage":{"/dev/shm":{"free":65.0,"mount_type":"tmpfs","total":67.1,"used":2.1},"/media/frigate/clips":{"free":620870.9,"mount_type":"zfs","total":621258.5,"used":387.6},"/media/frigate/recordings":{"free":620870.9,"mount_type":"zfs","total":621258.5,"used":387.6},"/tmp/cache":{"free":620870.9,"mount_type":"zfs","total":620871.9,"used":1.0}},"temperatures":{},"uptime":4056,"version":"0.12.0-da3e197"}}

so the frigate integration seem to work but the integration whit homeassistant not.

Version of the custom_component

Newest stable version, 0.12.0 Integration version v4.0.0

Configuration

mqtt:
  host: 192.168.1.18
  user: mqtt_user
  password: mypassword

objects:
  track:
    - person
    - car
    - dog
    - umbrella
  filters:
    person:
      min_area: 5000
      max_area: 100000

detectors:
  ov:
    type: openvino
    device: AUTO
    model:
      path: /openvino-model/ssdlite_mobilenet_v2.xml

model:
  width: 300
  height: 300
  input_tensor: nhwc
  input_pixel_format: bgr
  labelmap_path: /openvino-model/coco_91cl_bkgr.txt

cameras:
  Cortile:
    ffmpeg:
      inputs:
        # High resolution Stream
        - path: rtsp://cortile:camera@192.168.1.28:554/stream1
          roles:
            - record
        # Low resolution Stream
        - path: rtsp://cortile:camera@192.168.1.28:554/stream2
          roles:
            - detect
            - rtmp
    detect:
      width: 640
      height: 360
      fps: 24

    record:
      enabled: True
      retain:
        days: 5
      events:
        retain:
          default: 10
        required_zones:
          - zone_cortile

    snapshots: 
      enabled: True
      required_zones:
        - zone_cortile

    mqtt:
      required_zones:
        - zone_cortile

    zones:
      zone_cortile:
        coordinates: 503,290,424,360,116,360,189,247,178,165,229,152,292,129,413,117,527,136,521,194,581,201,576,295
        objects: 
          - person
          - umbrella
          - car
          - dog
        filters:
          person:
            min_area: 5000
            max_area: 100000
            threshold: 0.8
          car:
            threshold: 0.7
          dog:
            threshold: 0.7

    motion:
      mask:
        - 566,0,640,0,640,360,602,308,584,200,585,159,605,124
        - 327,0,184,88,130,121,0,160,0,0

  Garage:
    ffmpeg:
      inputs:
        # High resolution Stream
        - path: rtsp://192.168.1.20/ch0_0.h264
          roles:
            - record
        # Low resolution Stream
        - path: rtsp://192.168.1.20/ch0_1.h264
          roles:
            - detect
            - rtmp
    detect:
      width: 640
      height: 360
      fps: 24

    zones:
      zone_cancello:
        coordinates: 234,68,295,66,348,61,345,0,230,0
        objects: 
          - person
          - umbrella
          - car
          - dog
        filters:
          person:
            min_area: 5000
            max_area: 100000
            threshold: 0.8
          car:
            threshold: 0.7
          dog:
            threshold: 0.7

    record:
      enabled: True
      retain:
        days: 5
      events:
        retain:
          default: 10
        required_zones:
          - zone_cancello

    mqtt:
      required_zones:
        - zone_cancello

    snapshots: 
      enabled: True
      required_zones:
          - zone_cancello

the logs are mentioned above

NickM-27 commented 1 year ago

you are going to need to show your frigate docker installation config

DylanHP commented 1 year ago

I didn't install it via docker but via trueNas scale webui

NickM-27 commented 1 year ago

Okay, that is just running docker. In any case, please show the config for the ports in the UI

DylanHP commented 1 year ago

image

lukaszs1942 commented 1 year ago

i have similar issue.

nabheet commented 1 year ago

This used to work amazingly but I upgraded everything a few weeks ago and now the camera entities are not available in HA.

I don't think this is a frigate docker issue because I seem to get valid responses via Frigate API. I can add the integration to HA. But it always says unavailable. And it could still be a Frigate Hass UI card issue but it works with other camera entities. Just not the camera defined in Frigate integration. Any suggestions to debug this issue would be greatly appreciated

image image
mqtt:
  host: mosquitto
  user: USER
  password: PASSWORD

#detectors:
#  coral:
#    type: edgetpu
#    device: usb

detectors:
  cpu1:
    type: cpu
    num_threads: 3
  cpu2:
    type: cpu
    num_threads: 3

go2rtc:
  streams:
    front_door_main:
      - rtsp://USER:PASS@192.168.86.22:88/videoMain
    front_door_sub:
      - rtsp://USER:PASS@192.168.86.22:88/videoSub
    garage_main:
      - rtsp://USER:PASS@192.168.86.55:88/videoMain
    garage_sub:
      - rtsp://USER:PASS@192.168.86.55:88/videoSub

cameras:
  front_door:
    ffmpeg:
      inputs:
        - path: rtsp://127.0.0.1:8554/front_door_sub
          input_args: preset-rtsp-restream
          roles:
            - detect
        - path: rtsp://127.0.0.1:8554/front_door_main
          input_args: preset-rtsp-restream
          roles:
            - record
    mqtt:
      enabled: false
    ui:
      dashboard: true
    motion:
      mask:
        - 454,369,452,640,936,631,965,339
  garage:
    ffmpeg:
      inputs:
        - path: rtsp://127.0.0.1:8554/garage_sub
          input_args: preset-rtsp-restream
          roles:
            - detect
        - path: rtsp://127.0.0.1:8554/garage_main
          input_args: preset-rtsp-restream
          roles:
            - record
    mqtt:
      enabled: false
    ui:
      dashboard: true
    motion:
      mask:
        - 902,448,1280,475,1240,195,1075,193
        - 684,172,928,176,932,77,684,86
        - 0,314,96,306,88,218,0,222
rtmp:
  enabled: false

snapshots:
  enabled: True
  clean_copy: True
  timestamp: False
  bounding_box: True
  crop: True
  height: 175
  retain:
    default: 10
    objects:
      person: 15

record:
  enabled: True
  expire_interval: 60
  retain:
    days: 5
    mode: active_objects
  events:
    pre_capture: 5
    post_capture: 5
    retain:
      default: 10
      mode: active_objects
      objects:
        person: 15
        car: 3

birdseye:
  enabled: True
  quality: 31
  mode: objects

detect:
  fps: 5
  enabled: True

objects:
  track:
    - person
    - bicycle
    - motorcycle
    - car
    - bus
    - bird
    - cat
    - dog

motion:
  improve_contrast: true
NickM-27 commented 1 year ago

Does the integration have any errors?

nabheet commented 1 year ago

I am not sure where to look for errors but doesn't seem so.

image
NickM-27 commented 1 year ago

Nevermind I see your problem, the names of the go2rtc streams don't match the camera

nabheet commented 1 year ago

oh! What should it be?

Maybe I misunderstood the documentation. IIRC, it says that I can set up a low quality stream for detection and a high quality stream for recording. Which is what I thought I set up and it had been working wonderfully for a many many months. Or its possible that I was not using the correct combinations in all 3 things - Frigate, HA Integration and the UI card. It is pretty hard to keep track of the settings across the board. πŸ˜„

NickM-27 commented 1 year ago

The name of the go2rtc stream used for the integration needs to match the name of the camera. So whichever one you want to use, needs to have the _ and everything after removed.

nabheet commented 1 year ago

And here is the weirdest part - it connected and got a snapshot before it disconnected.

image

I am pretty sure the preview of the Front door camera used to work.

NickM-27 commented 1 year ago

That points to MQTT issues as well then

nabheet commented 1 year ago

oh! definitely have MQTT errors but I didn't realize that was important because I never set it up correctly. Should I fix them first?

2023-07-08 06:51:00.985012394  [2023-07-08 06:51:00] frigate.comms.mqtt             ERROR   : Unable to publish to events: client is not connected
NickM-27 commented 1 year ago

Yes definitely

nabheet commented 1 year ago

Thanks man! working like a charm now. πŸ™‡β€β™‚οΈ

NeillHerbst commented 1 year ago

How did you fix the mqtt issues?

github-actions[bot] commented 1 year ago

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.