Request error http 400 on <hass>/api/frigate call
Closed this issue · 8 comments
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?
Would be good to see the request details using browser debug tools so we can see what the response is
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
I've been seeing this error (or something very similar) for quite a while but not been able to resolve it. I always get the 404 error. I had presumed I may need to expose the actual frigate server to the outside world (which I'm reluctant to do), but if that was the case it would presumably work when I'm connected to the home network (and it doesn't).
Watching to see if I can learn something!
In total frustration I rebooted my hass server (not just restart home-assistant) and my notifications now work. However now my frigate card doesn't. I get this error:
Failed to receive response from Home Assistant for request. Check troubleshooting.
{
"request": {
"type": "frigate/events/get",
"instance_id": "frigate",
"cameras": [
"Drive"
],
"limit": 50,
"id": 355
},
"response": {
"code": "not_found",
"message": "Unable to find Frigate instance with ID: frigate"
}
}
I don't know what that means. What is a frigate instance_id and where is it set? Is this related to mqtt client_id setting in frigate config? Interestingly if I set mqtt client_id to 'frigate' then both notifications and frigate card work. For one frigate instance at least. BTW I have to say when it works it's rather good :-)
I have got no Telegram notification since several days ago. Debugging from HA log, I have found the video path returns HTTP 404. And eventually I have found it is due to adding the second Frigate entity onto HA several days ago. Leaving only one Frigate entity fixed the HTTP 404 problem.
"message": "Unable to find Frigate instance with ID: frigate"
Frigate card is telling you the default Frigate instance does not exist on this HA server. Do you have the integration installed?
PS: The Frigate instance id being referred to is actually the client_id
field from the Frigate MQTT config, which has a default of frigate
. If you use a different client_id
value, or have multiple Frigate servers, you need to tell the card that so it can know how to talk to HA correctly.
Thanks for confirming that and that link. It's all working very well now. I think we put this issue down to ignorance and finger trouble.