Severe delay in cast to Google Nest hub to run automation

Hi all,

I have set up a working automation to cast 3 video feeds and a gate control opener to my Google Nest hubs in my house after someone is ringing the G4 Pro Doorbell. When pressed, I immediately get a “ping/notification” on the Nest hubs, but it the is agonizingly slow to connect HA.
After the ping and when I get connected to HA, is at least 12-15 seconds, the video feeds (rtsp low res feeds from unifi with preload activated) come a few seconds later still.
I first get a blank screen, then the HA logo and “not connected”, after about 8 seconds, it turns to “connected” and then shows me the card.

How can I solve this delay?
I am running HA in a VM on my home-built Unraid server, which should be plenty fast to run everything. It is running on an Intel i7-4930K @ 3,40 with CPUs 0/6, 1/7 and 2/8 selected with initial memory of 8192 MB and Max Memory of 16384 MB. VM is running on an MX500 crucial SSD drive. So I shouldn’t have any issues with HDD’s having to spin up, etc, which could cause the issue.

Thank you in advance,
DrBobke

Hi DrBobke,

Don’t forget that talking to the Google hub means your HA generates a request, API’s the Google server, they then generate the message and send it back to your speaker. You need to add in your internet time and the pass thru your home network a couple of times. I wouldn’t start with the computer, I would start with the network as that is going to be the choke point.

Hi Sir_Goodenough,

Thanks a lot for your message. I didn’t know that talking to the Nest Hub would be so cumbersome. I am sending the message to 6 screens in the house, which are all in 1 automation (and ending 2 min after the doorbell was rung). Would it be better in your opinion to write 6 separate automations, if that would be faster?

Our doorbell is wired through a Cat 6a cable to a PoE converter (unifi) and a 7 meter USB-C unifi cable (they don’t sell shorter ones and the other PoE converter has been out of stock for the last year or more and I finally wanted to get this working). So the doorbell feeds straight into a unifi 24 USW PoE, with the camera for the driveway also does. The gate opener is a sonoff based itching ‘plug’ which works off wifi (but that is fast enough to respond). Just for reference : the doorbell and cameras are on a separate VLAN (and subnet) for security purposes. I have configured the rtsp stream for the doorbell main camera and the driveway to show the low res version, the package camera only has one stream.

Is there something you can recommend in troubleshooting the bottleneck?
Should it help, I am based in Belgium and we have terrible upstream of 27-29 Mbps, but that should still be plenty fast enough for the request, no?

Thanks a lot!

That should be fast enough. I am able to TTS to google speakers here in the US from a link that is 1mbs up and 10mbs download get faster response that that.
How to verify or fix, not sure. Just wanted you to know that looking at big picture, the problem may not be in your house. Look broader.

So, to clarify, the audio notification is fast, it’s the actual video stream that takes a while, correct? First thing I would try is editing the automation to send to one device, maybe sending the same stream to 3 different devices is slowing things down. If it doesn’t, then you can focus on that one device. I use DashCast to stream my 3D printer to my Sony Android TV and it’s pretty fast, but also hit or miss. I appears that if it’s open in the background it just doesn’t work. I need to figure out a way to force quit. When it’s not it takes about 8 seconds for video to show.

I would also try any other device to try to stream to. In my experiences some Android devices are terrible to send video streams too. It’s hit or miss on Android, that I know. I take it by “preloaded” you mean the below is checked, correct?

I am also assuming you have WebRTC installed from HACs.

Hi guys, sorry for not posting, school has just started again and it’s been a mad dash to get everything ready. I also thought I would get notifications on posts here (they are turned on), but didn’t see an email come in.

Anyway, thanks a lot for your remarks, I will again to just cast to one device and see if that is any quicker.

Just to clarify : when someone rings the doorbell, the google nest hubs in the house “BLING” quite immediately (or maybe after like 1 second, but very quickly). Then the hub screen turns white after about 2-3 sec, then I see the Nabu Casa logo with a heart and underneath, it is stated “Not connected”. After about 5-7 seconds, I see the notification of the Nabu Casa logo and “connected”, then it seems it connects and I see the link. However, I see the gate logo, which is instantly accessible/usable. The rtsp streams that I altered and put on the dashboard, especcially the two from the doorbell (doorbell and package cam), seem very slow to load. I think it was actually loading faster before putting in the WebRTC and the rtsp streams (and get them directly from protect integration - which is the “high resolution” - I haven’t found out how to get the medium or low res streams through that). All of this together means a slowdown of around 12-15 seconds between the doorbell is pressed and I can actually press the gate open, the video streams are usually a little behind still (which is not ideal, as we then don’t really see who is there and open the gate).

The preload camera stream that you put in the screenshot is indeed the one you mention above and that I have activated.
Not sure how I should test if I can stream it to another device, but I would like to get it to work on our google nests, as we have them in the house and are working with them. I do have a few iPads lying around, but not sure if I can stream to those?

Thanks a lot for your replies.
DrBobke

On the google next hubs, are you using a web browser or the HA Android app? If so, do you have a persistent connection to HA in the companion app and does the app have all the permissions? I imagine it has all the permissions but I have seen when not having a persistent connection can cause a delay for everything. The initial sound plays before the screen comes on so it’s connected to your LAN, which makes the HA message odd. It should just connect, especially if you are using the internal IP/DNS name and not an external one over http. Although I have read of similar issues on low power ARM devices like the nspanel pro. Based on your post, it really seems like it’s just taking forever for the low power ARM CPU in the Nest to start the stream.

It’s obviously not a hardware issue based on your setup, but ffmpeg may help (see below about go2rtc) since the transcoding is CPU based and recommended for glichy streams.

I would also try the minimal version of the HA app by downloading the apk from GitHub. I know people use this on the nspanel pro to improve performance as the full version causes lots of lag. Below is from the Android APK source code page in the compile instructions. Unless you are using location tracking and getting notifications on the Google nest devices the it will run faster.

It can be downloaded from here, scroll down until you see assets for the latest release and you will see the minimal apk download. You can’t get this from HACs or the Google Play store. I only learned about this version very recently when researching if the new nspanel pro 120 was worth it or not. I really wish I had bought one at 50% off when i had the chance but I waited to long. 65, sure, 130, nope… Regardless, videos on YouTube showed it made a big performance improvement on the nspanel pro performance so worth a shot. You can probably run both at once although I could be wrong. Different apks but same version number…

Lastly, have you created a custom dashboard just for the Nest devices? Most people with the nspanel would create a new user, create a new dashboard (typically with the kiosk HACs lovelace card, although not required) and only put whats needed on that dashboard and assign it to the new user. This way, you don’t load so much onto the device at once when logging/loading HA. Might help, might not as your main issue is casting video from a camera. Probably best to use a last ditch effort.

I don’t think you can preload an RTSP stream, not unless you install go2rtc, which can be installed using a custom repository link in add ons in HA. I never installed it but per the docs it creates actual entities in HA. With WebRTC I can display streams in the dashboard, but no entities are actually created. From the docs it seemed like that is possible with [go2rtc] with the added bonus of transcoding and setting resolution and frame rate using ffmpeg (GitHub - AlexxIT/go2rtc: Ultimate camera streaming application with support RTSP, RTMP, HTTP-FLV, WebRTC, MSE, HLS, MP4, MJPEG, HomeKit, FFmpeg, etc.). I would have to re-read the docs but I know it allowed you to create names so the name:password wouldn’t show in the URL like rtsp://admin:password@someip . It can also be installed on Windows/Mac/Linux but having it as a docker add on in HA seems like the best place to install it (or docker container if not running full HA OS). Then you can leverage ffmpeg which is recommended for “glichy” streams. There is also this note about Unifi.

Ubiquiti UniFi users may want to disable HTTPS verification. Use rtspx://prefix instead ofrtsps://. And don't use ?enableSrtp suffix

streams:
  sonoff_camera: rtsp://rtsp:[email protected]/av_stream/ch0
  glichy_camera: ffmpeg:rtsp://username:[email protected]/live/ch00_1 

The Android app has both a full flavor that uses Google Play Services to offer features like location tracking and notifications. There is also a minimal flavor that does not require Google Play Services and can be found in the releases section. The minimal flavor does not have location tracking or notifications.

Hi ginandbacon,

Thanks a lot for your lenghty reply, I really appreciate it. I have been playing around with the instruction in the last couple of hours, but can’t really figure it out.
I am currently using an automation action called “Google Cast: Show dashboard view

I have tried following all the steps in the GitHub - home-assistant/android: 📱 Home Assistant Companion for Android guide. I installed Android Studio on my pc (which is usually always running) and I have created a project with Firebase, as outlined in the instructions. I had a difficult time finding the google-services.json file, but after putting the firebase project live and opening an app, it seems I got some kinds of code.
I have also (I think) gotten the 4 android apps installed in android studio:

  • io.homeassistant.companion.android
  • io.homeassistant.companion.android.debug
  • io.homeassistant.companion.android.minimal
  • io.homeassistant.companion.android.minimal.debug
    But then I can’t find the /app, /automotive and /wear folders. I think the guide is likely written by someone who knows all the ins and outs of how to do it, but for a noob like me, it’s impossible to figure out (like creating the app itself, you are greeted with 8 or 10 options for which kind of app you wish to create, so I am not even sure if I did that right).
    I was then looking into installing the minimal app as suggested, which I downloaded, but I then cannot find where I can install that into HA. There should be a web terminal or SSH addon, but I can’t find those in my HA (again, I am running HA as a VM on my Unraid).

I indeed created a custom dashboard for the Nest devices to use. I think I have only one user in my HA to use. I do think I made a lovelace card to get it running.
I have tried to install the go2rtc, but I can’t find it in HA either and through the add ons, I have no idea how to do it.
Is there some kind of step by step youtube vid or smth else that can help? I am fairly new to HA and everything, but have already made a lot of automations (using unifi camera’s to trigger lights on, etc).

Any help would be greatly appreciated!

Best regards,
DrBobke

Regarding the apk file, you don’t have to compile it yourself. See the image in the previous post. You just have to go to the releases (linked above) and scroll down to assess for the latest build and you will see the image posted above. Sorry if I wasn’t more clear. I had linked that page because it gave a description between the 2. There’s also a minimal version for Android auto, which may have been what you were running into. Regardless simply download it and side load the apk. You may have to turn on allow installs from unknown sources in the nest settings for it to install.

For go2RTC you have to actually add it as a custom repository in add ons for it to show up by going to settings, then add the repository. Below is from one of the pages linked above. After you add it then it will show up and you can install it. You can do this is HACs also, although not needed for this, for custom integrations. I’m not sure what the process is to have it be an official add on or even a HACs integration.

About the only downside is these obviously aren’t tested but then again none of the HACs integrations are either. They only test and validate the 2.8K+ supported integrations. I’ve never personally had any issues with adding custom add ons or integrations but obviously create a full backup and store it somewheres besides the HA server if you have not already it up to store backups on the network.

Install Add-On:
Settings > Add-ons > Plus > Repositories > Add GitHub - AlexxIT/hassio-addons: Hass.io addons: go2rtc and SSH Tunnel
go2rtc > Install > Start
Setup Integration