Generic camera password issues (camera or code?)

New to Home Assistant but the 0.90 camera changes caught my eye and I decided to try. I did get them to work, very nice. I can now change to display my front door on my TV’s if I hear the doorbell ring (for example).

But I went around in circles for a while over authentication.

The cameras are Lorex LNE8974AB which is likely a rebranded Dahua, 4K. I have them configured as follows

  - platform: generic
    name: camsouthside
    still_image_url: http://user:password@camSouthside/cgi-bin/snapshot.cgi
    stream_source: rtsp://user:password@camSouthside/cam/realmonitor?channel=1&subtype=1
    verify_ssl: false
    username: "user"
    password: "password"
    authentication: digest

I am, for now, not using secrets but the username and password are explicit (changed here to just user/password).

Here’s the thing – the http (still) image requires the credentials inside the URL. The rstp requires the credentials to be explicit as separate lines.

So in the above if I remove the last three lines, the stream stops working.

And in the above if I remove the user:password@ from the URL then the still image does not work.

Including it in all possible places does work.

This is more observation in case it helps anyone than a question. I have no idea if this is a limitation in the cameras, or an issue in the new generic IP camera code, or… ?

But it sent me around in circles for a long time as I kept trying one or the other, not all (and for this camera digest was required as well).

But once I got that it worked nicely – with one service call my TV turns on and displays the stream. Very cool.

Thanks for this!


PS. I’m on 0.90.1 not yet .2.

I have somewhat of the same problem.

My rtsp stream doesn’t work without username:password.

I like to have them in the username, password property. So i can use !secret to hide them in my config.

Not possible. You can’t have more than 1 secret in a single line. So your solution is to make the whole URL a secret.

I (now) understand that. Drawing from this thread (here) I guess the question is should the program that processes the yaml RSTP line automatically insert the username/password when provide. Is it true that if the still image has a password from the camera, the rstp stream will as well (that’s not rhetorical, I do not know; all mine done).

If the RSTP line was altered to insert the username/password (if not already there), then the username/password provided would work, the rstp line in the yaml does not need it explicit, and the secrets would work?

That could be a solution down the road. I’d say that would make a good feature request.

Linwood - when you say you can cast your cameras to the TV, is that based on voice controls through google home devices using Nabu casa cloud? I have similar cameras to yours and I can see the live stream on HA/lovelace fine, and I can also stream them to a chromecast-enabled TV (using google voice commands and the Nabu casa cloud), BUT… I have been trying to do this WITHOUT the Nabu cloud service (I would rather not pay for it as I have no use for remote cloud access whatsoever), but I find that without the Nabu cloud service google home devices are never able to stream the camera feed to anything (using DuckDNS Let’s Encrypt, etc). Would you mind sharing how you achieved that?

@lolly, This is on my list to research more fully. I am so far only using it via the Nabu casa cloud via Google voice commands, and it works about 50% of the time, which is really annoying. Sometimes the image comes up and stays for a long time; sometimes it comes up and quits within a minute or so. More often it comes up and says something like “smart camera” and hangs.

I just tried it from within home assistant without the cloud, doing a camera.play_stream using the camera and media player for a chromecast. The first try some activity and icons then black screen. Hit it again, it popped up and worked fine. So I’d say that the flaky aspects are not related to the cloud, but to some aspect of the play_stream function (which I assume is what the cloud and google voice command is using under the covers).

It’s really annoying. I wanted this to automatically come up, for example, when the doorbell is rung, or even motion from outside, but it is just not reliable enough to count on – I stand there like a fool telling it over and over to stream, trying to get it to work, instead of answering the door.

My other plan, which fell apart as well, was to use ffmpeg and its ability to build a matrix display on the fly, but they dropped that aspect recently form that utility.

So… it remains on my list, almost working, a solution just barely out of reach because it is too flakey.

But to your basic question, mine works internally. I just do the below, which so far as I am aware does not use any outside resources, needs no certificates, etc.


PS. For clarity I am streaming from and to a device on my local network, not an internet device, cell, etc.