dermotduffy / frigate-hass-card

A Lovelace card for Frigate in Home Assistant
MIT License
528 stars 57 forks source link

Allow a non-Frigate go2rtc URL endpoint #1206

Closed dm82m closed 11 months ago

dm82m commented 1 year ago

Checklist:

Release with the issue: Latest Frigate Card Last working release (if known):

Browser and Operating System: Google Chrome on MacOs

Description of problem:

Cant get 2 Way Audio working with the frigate-hass-card. It works directly through go2rtc. But with the frigate-hass-card the microphone button is not available even if I try to explicitly enable it.

Frigate card diagnostic information

{
  "ha_version": "2023.6.2",
  "card_version": "5.1.1",
  "browser": "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/114.0.0.0 Safari/537.36",
  "date": "2023-06-19T09:01:54.122Z",
  "frigate_version": {},
  "lang": "en",
  "timezone": "Europe/Berlin",
  "git": {
    "build_version": "5.1.1-HEAD+g2d977be",
    "build_date": "Sat, 20 May 2023 20:35:29 GMT",
    "commit_date": "Sat, 20 May 2023 13:32:32 -0700"
  },
  "config": {
    "type": "custom:frigate-card",
    "cameras": [
      {
        "camera_entity": "camera.dima_cam_hd_stream",
        "go2rtc": {
          "stream": "tapo",
          "modes": [
            "webrtc"
          ]
        }
      }
    ],
    "menu": {
      "buttons": {
        "microphone": {
          "enabled": true
        }
      },
      "style": "overlay"
    }
  }
}

Javascript errors shown in the web inspector (if applicable):

Additional information:

felipecrs commented 11 months ago

Yes actually! I spent 20 minutes playing on this yesterday, but couldn't get it to work out of the box. I do suspect there's a way though (instead I went and worked on your casting feature request!).

Oh, got it. I suspect the WebRTC integration uses a more low-level integration with go2rtc and thus it does not need direct API access to go2rtc, for example. Maybe that's why it works for WebRTC with the existing proxies.

To me I think the right fix is really a "small generic proxy integration" designed for re-use.

OMG, yes, I think that's a great idea! The Asterisk integration could also benefit from it:

dm82m commented 10 months ago

Seems that it is now directly supported: https://github.com/AlexxIT/WebRTC/releases/v3.4.0

pergolafabio commented 10 months ago

That's indeed nice, but I still prefer the frigate card because of the customize, like adding extra elements/buttons to start two audio

daxcore commented 10 months ago

tell me if i am wrong, but this will not work without frigate at all?

frigate addon is stopped, but go2rtc addon is running.

error in card:

{
  "request": {
    "type": "frigate/events/get",
    "instance_id": "frigate",
    "cameras": [
      "reolink"
    ],
    "limit": 50,
    "id": 74
  },
  "response": {
    "code": "not_found",
    "message": "Unable to find Frigate instance with ID: frigate"
  }
}

yaml:

type: custom:frigate-card
cameras:
  - camera_entity: camera.reolink
    live_provider: go2rtc
    go2rtc:
      url: https://go2rtc.example.com
      modes:
        - webrtc
      stream: reolink
menu:
  buttons:
    microphone:
      enabled: true

this is my nginx.conf:

server {
    server_name go2rtc.example.com;

    listen 80;

    if ($scheme = http) {
        return 301 https://$server_name$request_uri;
    }

    ssl_session_timeout 1d;
    ssl_session_cache shared:MozSSL:10m;
    ssl_session_tickets off;
    ssl_certificate /ssl/fullchain.pem;
    ssl_certificate_key /ssl/privkey.pem;

    # dhparams file
    ssl_dhparam /data/dhparams.pem;

    listen 443 ssl http2;
    add_header Strict-Transport-Security "max-age=31536000; includeSubDomains" always;

    proxy_buffering off;

    location / {
        proxy_pass http://homeassistant.local:1984;
        proxy_set_header Host $host;
        proxy_redirect http:// https://;
        proxy_http_version 1.1;
        proxy_set_header X-Forwarded-Host $host;
        proxy_set_header X-Forwarded-Server $host;
        proxy_set_header X-Forwarded-Proto $scheme;
        proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
        proxy_set_header Upgrade $http_upgrade;
        proxy_set_header Connection $connection_upgrade;
    }
}
dermotduffy commented 10 months ago

tell me if i am wrong, but this will not work without frigate at all?

That is probably still a Frigate camera entity. The card is trying to fetch thumbnails since it knows that's a Frigate camera. Either turn thumbnails off, don't use a Frigate camera entity (or any entity), or ask the card to use a generic camera engine with engine: generic.

felipecrs commented 10 months ago

Was anyone able to make it work? For me it is failing with:

image

There are no more details in the logs.

felipecrs commented 10 months ago

Nevermind, I was missing my own tip!

Add this to go2rtc:

api:
  origin: '*'