I’ve been using HA for over 7 years now and back then camera support sucked, and today nothing has changed…
I run HA on a Raspberry Pi 3B with 1GB RAM and a small SSD.
The only way I have cameras working reliably(ish) in HA is unnecessarily convoluted and complex…, it goes like this.
Instead of using each camera manufactures integration, I use MotionEye running on another machine, all cameras go to this MotionEye server and then I use the HA MotionEye integration to expose all the cameras to HA. This has the following advantages
- You can change the native resolution of the cameras in MotionEye. (eg. down sample from a 4K camera to lower resolution)
- Consistent motion detection between different camera manufacturers
- MJPEG output stream to HA
- MotionEye will limit the output frame rate to 1fps when no motion is detected
- Storage of snapshots and video on the MotionEye server all accessable from HA
So, “Why MJPEG!!!” I can hear you all screaming…, because its simple, resilient to poor network connectivity, low latency (<250ms), uses virtually no CPU and is compatible with everything made since 1995. Every other form of streaming I’ve tried, from MPEG to WebRTC IMHO suck, with combinations of high CPU on both client and server side, larger delays and virtually no resilience to network issues.
And… “Why not Frigate”…, IMHO over complicated and very CPU intensive. I run my MotionEye server on a small low power Celeron fanless PC I bought over 10 years ago for $100.
For each of my 5 cameras I also define a HA proxy camera to down sample from 640x480 to 160x120 which can be used to make composite views in lovelace cards, or where there are bandwidth limitations.
So, using this setup I can have all 5 of my cameras displayed in the same lovelace card. With one ‘selected’ camera at the higher resolution and 4 others at low-res this uses < 80kbits/sec. With all five cameras in low-res this uses < 30kbits/sec.
This works great, but there are still problems with lovelace displays and casting.
-
Simple one first, ‘Playing’ a camera stream on a chormecast device will timeout after 5 mins with no warning or error in home assistant. SOLUTION: you have to restart any streams you are casting every 5 mins, annoying, but better than staring at a frozen image.
-
Lovelace cards are more complex…, I found that switching between dashboard cards that contain other camera displays will cause the live displays to freeze in either the card you are switching too, or switching back from. Also switching camera display cards around on the same dashboard, eg. with conditional cards, will also cause the displays to freeze. SOLUTION: Detect when these changes happen eg. for dashboard navigation events use BrowserMod, and then when changing the display, hide the card, wait a short interval, then display the card again. This is easily done with a conditional card wrapped around your lovelace camera cards(s). eg.
automation:
- id: hide-then-show-camera-dashboard
alias: Hide then show camera dashboard
trigger:
- platform: state
entity_id: input_select.camera_display
action:
- service: script.turn_on
entity_id: script.flip_camera_dashboard
initial_state: true
script:
flip_camera_dashboard:
sequence:
- service: input_boolean.turn_off
target:
entity_id: input_boolean.show_camera_dashboard
- delay:
milliseconds: 250
- service: input_boolean.turn_on
target:
entity_id: input_boolean.show_camera_dashboard
So, after years of messing around with cameras, using this setup my camera cards in lovelace never freeze, and I can cast any single or combination of cameras to all eight of my cast devices (chromecasts & Google Hubs) simultaneously with no freezes, approximately 250ms delay and no CPU use on HA.
Anyway, rant over…, wouldn’t it be nice if cameras just worked