blakeblackshear / frigate-hass-integration

Frigate integration for Home Assistant
MIT License
740 stars 117 forks source link

Request error http 400 on <hass>/api/frigate call #756

Open nottledim opened 22 hours ago

nottledim commented 22 hours ago

When a notification is sent to android hass app using SgtBatten's notification blueprint it provides the clip url that looks like https://<domain>/api/frigate/notifications/1730296666.946824-qaky68/drive/clip.mp4

Android reports attempting to open this as "this page isn't working" Error 400

Similarly locally or from the browser http://hass:123/api/frigate/notifications/1730296666.946824-qaky68/drive/clip.mp4 returns an http 400 Request Error.

This is using the integration v5.4.0 with frigate 0.14.1-f4f3cfa

Configuration

Frigate is on a separate server from hass

Notification automation:

- id: '1708528816493'
  alias: Frigate Drive
  description: ''
  use_blueprint:
    path: SgtBatten/Stable.yaml
    input:
      camera: camera.drive
      notify_device: d688f0f669c11bc8e880601d897711bd
      zones: []
      message: HA {{camera_name}} detected a {{label}}
      critical: 'false'
      alert_once: true
      update_thumbnail: true
      cooldown: 60
      base_url: https://hass.xxxx.net/
      channel: CamFront
      attachment: snapshot
      icon: mdi:cctv

Frigate config

# 18-Nov-23 RJM
version: 0.14

auth:
  enabled: false
tls:
  enabled: false

mqtt:
  host: 192.168.xx.xx
  port: 1883
 # user: user
 # password: password
  topic_prefix: frigate
  #client_id: frigate_lb

birdseye:
  enabled: true
  mode: objects
  restream: false
  layout:
    max_cameras: 4

detectors:
  coral:
    type: edgetpu
    device: pci

cameras:
  Garage:
    enabled: true
    ui:
      order: 40
    ffmpeg:
      inputs:
        - path: rtsp://xxx:7447/HzhYjKTvFmjaHi0n
          roles:
            - detect
            - record
      # hwaccel_args: preset-vaapi
    detect:
      enabled: true
      width: 1280
      height: 720
      stationary:
        interval: 10
      max_disappeared: 75
    record:
      enabled: true
      events:
        objects:
          - person
    snapshots:
      enabled: true
    objects:
      filters:
        person:
          threshold: 0.8
          mask:
            - 286,442,223,648,108,570,260,311
    motion:
      mask:
        - 286,442,223,648,108,570,260,311
    birdseye:
      order: 5

and more cameras

frigate-proxy:

Add-on: Frigate Proxy
 Proxy addon for Frigate
-----------------------------------------------------------
 Add-on version: 1.5
 You are running the latest version of this add-on.
 System: Home Assistant OS 13.2  (amd64 / qemux86-64)
 Home Assistant Core: 2024.10.4
 Home Assistant Supervisor: 2024.10.3
Add your logs here:

I wish I could find something. Frigate integration emits many lines like:
[custom_components.frigate] Finished fetching frigate data in 0.006 seconds (success: True)
and nothing else.  I don't know where else to look.

Incidentally SgtBatten beta version for frigate 0.14 has the same problem. The config is very similar but it has this extra attribute:

video: '{{base_url}}/api/frigate{{client_id}}/notifications/{{id}}/{{camera}}/clip.mp4'

If I set a client_id in that url hass returns 404 error otherwise it returns 400 error.

To me it's like a proxy or remote access problem. My question is what is wrong that provokes the 400 error?

NickM-27 commented 22 hours ago

Would be good to see the request details using browser debug tools so we can see what the response is

nottledim commented 20 hours ago

Request

GET /api/frigate/notifications/1730396453.984189-ifwube/Porch/clip.mp4 HTTP/1.1
Accept: text/html,application/xhtml+xml,application/xml;q=0.9,image/avif,image/webp,image/apng,*/*;q=0.8,application/signed-exchange;v=b3;q=0.7
Accept-Encoding: gzip, deflate
Accept-Language: en-GB,en-US;q=0.9,en;q=0.8
Cache-Control: max-age=0
Connection: keep-alive
DNT: 1
Host: hass.lingbrae:8123
Upgrade-Insecure-Requests: 1
User-Agent: Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/129.0.0.0 Safari/537.36

Response

HTTP/1.1 400 Bad Request
Referrer-Policy: no-referrer
X-Content-Type-Options: nosniff
Server: 
X-Frame-Options: SAMEORIGIN
Content-Length: 0
Date: Fri, 01 Nov 2024 13:36:58 GMT