go2rtc icon indicating copy to clipboard operation
go2rtc copied to clipboard

Source: Nest - "400 Bad Request"

Open Lockie85 opened this issue 1 year ago • 7 comments

Hey,

I'm trying to get my nest camera working on Version: 1.9.1 via the following method:

streams:
  nest-doorbell: nest:?client_id=***&client_secret=***&refresh_token=***&project_id=***&device_id=***

However, I'm getting "400 Bad Request". image

I've checked my: client_id client_secret refresh_token project_id device_id

All are correct and I've confirmed this via commands like:

curl -X GET \
  'https://smartdevicemanagement.googleapis.com/v1/enterprises/YOUR_PROJECT_ID/devices/YOUR_DEVICE_ID' \
  -H 'Authorization: Bearer YOUR_ACCESS_TOKEN' \
  -H 'Content-Type: application/json'

Which provided a successful response. I'll keep checking as maybe I've made and missed a tiny mistake somewhere, but assuming I've not, any ideas what might be going on? Many Thanks.

Lockie85 avatar May 08 '24 18:05 Lockie85

Also worth noting that when I try entering details the camera via the "Add" > "Goggle Nest" UI, I get "no sources".

Lockie85 avatar May 08 '24 18:05 Lockie85

go2rtc v1.9.0 had a bug where consumer connections where not closed. It drained my nest doorbell battery. Have you checked it works on the Google Home app? v1.9.1 solved it for me.

miguelangel-nubla avatar May 09 '24 19:05 miguelangel-nubla

go2rtc v1.9.0 had a bug where consumer connections where not closed. It drained my nest doorbell battery. Have you checked it works on the Google Home app? v1.9.1 solved it for me.

On version 1.9.1, I still get "400 Bad Request". Is there a good method of debugging this problem?

I've set the log level to debug and here is what I'm seeing:

5/11/2024, 10:08:58 AM | debug | [webrtc] new consumer src=nest-doorbell 5/11/2024, 10:09:00 AM | debug | [mp4] add consumer error=streams: nest: wrong status: 400 Bad Request 5/11/2024, 10:09:01 AM | debug | [webrtc] add consumer error=streams: nest: wrong status: 400 Bad Request 5/11/2024, 10:09:01 AM | warn | [streams] json locked 5/11/2024, 10:09:02 AM | debug | [mjpeg] add consumer error=streams: nest: wrong status: 400 Bad Request

Lockie85 avatar May 11 '24 09:05 Lockie85

Sorry for repeating myself but are you sure it works on the home app?

Is there a good method of debugging this problem?

I would try to make it work using Home Assistant first with the nest integration, then copy the exact credentials from ha (/config/.storage/core.config_entries if I remember correctly. Just search for the nest client id in the .storage folder and the relevant json will show up) including the exact same refresh token.

miguelangel-nubla avatar May 12 '24 02:05 miguelangel-nubla

I don't have Nest cameras, so can't help with that

AlexxIT avatar May 12 '24 15:05 AlexxIT

Ive got the same issue (nest doorbell wired), and I've triple checked my params:

  • client_id
  • client_secret
  • refresh_token
  • project_id
  • device_id

Ive also made the API request to fetch the device with the access token and deviceId as per the original post here, and I get a good response back. Im using go2rtc 1.9.2 and Frigate (0.13.2-6476f8a)

        "sdm.devices.traits.CameraLiveStream": {
          "maxVideoResolution": {
            "width": 640,
            "height": 480
          },
          "videoCodecs": [
            "H264"
          ],
          "audioCodecs": [
            "AAC"
          ],
          "supportedProtocols": [
            "RTSP"
          ]
        },

But get this in Frigate go2rtc log

2024-05-31 13:41:35.827383741  13:41:35.827 WRN [rtsp] error="streams: nest: wrong status: 400 Bad Request" stream=Doorbell-camera
2024-05-31 13:41:45.873670924  13:41:45.873 WRN [rtsp] error="streams: nest: wrong status: 400 Bad Request" stream=Doorbell-camera
2024-05-31 13:41:55.833223943  13:41:55.832 WRN [rtsp] error="streams: nest: wrong status: 400 Bad Request" stream=Doorbell-camera
2024-05-31 13:42:05.912001824  13:42:05.911 WRN [rtsp] error="streams: nest: wrong status: 400 Bad Request" stream=Doorbell-camera
2024-05-31 13:42:16.042513558  13:42:16.042 WRN [rtsp] error="streams: nest: wrong status: 400 Bad Request" stream=Doorbell-camera
2024-05-31 13:42:26.163931089  13:42:26.163 WRN [rtsp] error="streams: nest: wrong status: 429 Too Many Requests" stream=Doorbell-camera

Eventually it gets throttled, HTTP 429.

I manage to get this working with HA Google Nest addon though.

I think maybe this is because Nest doorbell wired (legacy) only supports RTSP stream, and go2rtc only support Nest with webRTC stream?

jasjeetsuri avatar May 31 '24 13:05 jasjeetsuri

Just to note, I just hit a "400 Bad Request" myself again with a Nest Doorbell (battery), this time was because I clicked the small "turn off video" button on the official Home app. Working fine as soon as I enabled it again.


I think maybe this is because Nest doorbell wired (legacy) only supports RTSP stream, and go2rtc only support Nest with webRTC stream?

Only Nest cameras with WebRTC are currently supported https://github.com/AlexxIT/go2rtc/blob/03956968667bba2febb6a513d159dc9a00b3e4c8/pkg/nest/client.go#L50 and was only initially tested with the doorbell battery version.

miguelangel-nubla avatar Jun 14 '24 10:06 miguelangel-nubla

Just to note, I just hit a "400 Bad Request" myself again with a Nest Doorbell (battery), this time was because I clicked the small "turn off video" button on the official Home app. Working fine as soon as I enabled it again.

I think maybe this is because Nest doorbell wired (legacy) only supports RTSP stream, and go2rtc only support Nest with webRTC stream?

Only Nest cameras with WebRTC are currently supported

https://github.com/AlexxIT/go2rtc/blob/03956968667bba2febb6a513d159dc9a00b3e4c8/pkg/nest/client.go#L50 and was only initially tested with the doorbell battery version.

+1 exactly what happens in my environment also. I noticed that if the camera is down in the Google Home web app, Frigate won't be able to get the stream. Makes sense. I just wish it wasn't a 400 error :)

cthach avatar Aug 06 '24 19:08 cthach