Problem to get cameras running constantly

Hi,
I have HA running for a few days now, and I am so happy I gave it a try.
After getting a lot devices running, I get struggled with my cameras.

I have two (older) Dahua IP cameras running. They are integrated in my Synology. It doesn’t matter how I integrate the camera in HA (via Synology, Generic Camera, MJPEG Camera) the stream of the cameras disappears after a few minutes and the card is blank without any message. When I click on the blank card, the popup with the camera stream opens and the stream is running.
The HA app is running on a wall-installed tablet with Android 8.

Hope that anybody can help.

Regards
Martin

That’s typical behavior for camera streams. IIRC, it’s a 5(?) minute timeout on the stream when being viewed in the UI.

Are there ways to do a permanent stream?

Check “preload stream” option. Camera - Home Assistant

1 Like

It Does indeed matter in which Card(s) you expose your cams
I Have Cams in Tapo-Camera-Integration And Generic-Camera-Integration
3 Tapo-Cams in “picture-entity-cards & Custom:frigate-cards
3 DLink-Cams in Custom:frigate-cards

6 Cams in 1 View, they doesn’t go blank
Also 1 cams in/as “background” in graph-card ( Card-mod ), doesn’t go blank (the way you describe, sometimes for awhile, not often)

I also have 3 Cams inside custom:expander-card in a horizontal-stack in a grid(span 2 Columns) … They sometimes “behave” as you describe ( Thou for unknown reason not today),

Whether above also depends upon which browser is used i can’t tell ( as i haven’t digged deep into this) Maybe even the latest HA updates could be the reason why those last mentioned don’t turn blank now.
But surely from where and how you “fetch” the View, does matter, a “sunken” mobile-wifi / browser etc, could/would cause “lack in updating” in some scenarios

PS: picture-entity-card( chose “Live” ) … I don’t have “Preload Stream” enabled anywhere, as i rather want as low usage as possible

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

1 Like