dermotduffy / frigate-hass-card

A Lovelace card for Frigate in Home Assistant
MIT License
477 stars 53 forks source link

Add multiple camera support #249

Closed dermotduffy closed 2 years ago

dermotduffy commented 2 years ago

Add support for multiple cameras:

Significant configuration changes required. Automated upgrade is available for visual editor users, for YAML users manual update is required using the following transition guide:

Before (Shows all impacted values) After (Only include values as needed)
```yaml camera_entity: camera.office frigate: camera_name: office_door client_id: frigate-server-2 label: person url: http://my-frigate-server/ zone: office_door live: provide: webrtc webrtc: entity: camera.office_rtsp url: 'rtsp://USERNAME:PASSWORD@CAMERA:554/RTSP_PATH' any_other_webrtc_option: value ``` ```yaml cameras: - camera_entity: camera.office camera_name: office_door client_id: frigate-server-2 label: person frigate_url: http://my-frigate-server/ # Note: Key name change. zone: office_door live_provider: webrtc # Note: Key name change. webrtc: entity: camera.office_rtsp url: 'rtsp://USERNAME:PASSWORD@CAMERA:554/RTSP_PATH' live: webrtc: any_other_webrtc_option: value ```
```yaml menu: conditions: [key]: [value] ``` ```yaml overrides: - conditions: [key]: [value] overrides: menu: mode: none ```
github-actions[bot] commented 2 years ago

πŸŽ‰ HACS repository validator action summary πŸŽ‰ βœ… The repository is not archived βœ… hacs.json has the 'name' key set βœ… The repository has a description βœ… The repository has topics βœ… The repository has issues enabled βœ… This day ends with an 'y' (Monday) βœ… README.md exists βœ… Information file has images βšͺ Ignored check: hacs

NickM-27 commented 2 years ago

Just curious, is this ready for testing? I'd be happy to clone it into my HA and give feedback if anything comes up

dermotduffy commented 2 years ago

Hi @NickM-27 -- thanks for the interest and offer to help! It's getting closer, and I'm very actively working on finishing up this PR. Maybe give it a few days, and hopefully I'll get this merged in -- then I'd really welcome that testing (before I do a new official build). Thanks again.

NickM-27 commented 2 years ago

@dermotduffy sure sounds good! Would the best way to do it be to take everything in src/ and put that in the Lovelace directory? I just noticed official releases have a js.gz file instead of all the separate files.

dermotduffy commented 2 years ago

@NickM-27 Best bet would be to build it yourself (https://github.com/dermotduffy/frigate-hass-card#building) and use that output. I can also attach a js.gz file to this PR when it's done to make that simpler.

NickM-27 commented 2 years ago

@dermotduffy Ah! Didn't see that at the bottom, feel free to include but I'll be able to build it myself no problem

NickM-27 commented 2 years ago

@dermotduffy I know this is still a WIP but I finished work early today and decided to give this branch a gander. I have to be honest it has been very positive!

The auto-migration worked well, swiping between my 3 cameras is smooth on all platforms and the lazy loading is still quite quick. Previously I had 3 frigate cards on the same dashboard page and it was pretty often that at least one would stay a white screen and not load, but with this single card I have not experienced that issue. The camera-switcher button is also very helpful when I am viewing clips as well!

The only thing I have found so far (you may be aware of it, but figured I would just mention it) is if I am viewing clips and use the camera switcher to view clips from another camera, there is a <- (back button) card that appears first. However, when I press that back button card it disappears and the clips remain the same instead of loading the clips from the previously selected camera. πŸ‘

In any case, I am quite happy and so far with my setup things have been working great.

dermotduffy commented 2 years ago

Hi @NickM-27 . Fantastic! Thank you for the testing. I didn't know about the 'back button' issue, I'll look into that. There are a few other things I need to also wrap up, but it's getting pretty close.

dermotduffy commented 2 years ago

@NickM-27 For whatever reason I cannot reproduce the "Back button" issue you describe. Here's what I do:

At this point, as per your bug report, I'd expect to have the back button stay there -- but I don't, it disappears and is replaced with the clips of the new camera (which is what I'd expect).

Help?

NickM-27 commented 2 years ago

@dermotduffy I am not drilling down that may be the difference. I'll attach a screen recording so you can see.

https://user-images.githubusercontent.com/14866235/149450578-8c7f066c-2196-4cd3-8595-95085a22dec5.MOV

dermotduffy commented 2 years ago

@NickM-27 Huh. Weird, I still cannot reproduce that even without the drill down and I don't think I changed anything in this part of the code since you tested. Mind pasting your config?

NickM-27 commented 2 years ago

Just to remove a variable, I have been re-building to keep my card up to date with your commits so that isn't a concern.

type: custom:frigate-card
view:
  default: live
menu:
  mode: below
  buttons:
    frigate: false
    frigate_ui: true
    snapshots: false
    image: false
    clips: true
    download: true
    fullscreen: true
    live: true
live:
  preload: true
  controls:
    thumbnails:
      mode: none
    next_previous:
      style: none
controls:
  thumbnails:
    mode: below
    media: clips
event_viewer:
  controls:
    next_previous:
      style: none
    thumbnails:
      mode: below
dimensions:
  aspect_ratio_mode: dynamic
cameras:
  - camera_entity: camera.front_doorbell_cam
    frigate_url: http://192.168.50.106:5000
    live_provider: frigate-jsmpeg
  - camera_entity: camera.backyard_cam
    frigate_url: http://192.168.50.106:5000
    live_provider: frigate-jsmpeg
  - camera_entity: camera.office_cam
    frigate_url: http://192.168.50.106:5000
    live_provider: frigate-jsmpeg
NickM-27 commented 2 years ago

Okay scratch that last comment, it is happening on all devices. I just had a brain fart.

NickM-27 commented 2 years ago

@dermotduffy also I followed your steps and the back button remained after switching cameras. I wonder if one of my configs is weird?

https://user-images.githubusercontent.com/14866235/149453246-dd233325-b722-4c92-9c31-1278230f1fc1.MOV

dermotduffy commented 2 years ago

@NickM-27 OK, if I use your whole config, with my cameras, I can reproduce it! Leave it with me.

Update: Something to do with live.preload.

NickM-27 commented 2 years ago

Huh, never would have thought preload was the culprit. Glad I was able to help

NickM-27 commented 2 years ago

Okay that fixed the back button bug for me πŸ‘ I haven't found anything else either

dermotduffy commented 2 years ago

@NickM-27 Great, thanks for rechecking, it was a subtle one -- but getting your exact config was the key thing to make progress, so thanks for that.

This PR is now pretty close...