Ubiquiti Unifi Protect cameras

That looks like it would work great for general usage to serve images from devices.

Specifically for your Protect driver, I didn't want to alter it so I added in the detection of devices not having the image attribute.
This could have been resolved by setting a default null value for image when the device is created or fails to grab a snapshot.
I discovered this problem because I have a few G3 micros that I move around. Some were offline when writting this.
When the image attribute is not available, it returns a missing snapshot image (copied from the unofficial ring app).

Also because some devices were online but a snapshot was never taken, I executed take() before retrieving the image value.
This way you won't have to set up a polling rule. Not sure how that affects system performance though.

Regarding the existing controllers; I didn't bother with it when making this app.
I'm new to apps for Hubitat but after looking at the info in the docs this might be doable?

Possibly a migration page can be added that scans for any devices using your drivers.
After selecting the devices to migrate into the app, execute device.setDeviceNetworkId($formatedDNI)
Just spitballing there, not sure if that would affect the relationships.
There might be an undocumented setParentAppId() or something?

One thing I was able to find from your driver, not sure if it was intentional; If you add a second connection to the same controller, it will only import child devices not already on the system.
This was great for testing because I didn't have to remove all of my cameras from the standalone driver.
I could just remove one and then refresh the child devices from within the new app.
I'm assuming that you're using the UniFi UUID instead of generating a new one.

Also, that user was me, I forgot that I already had an account in the forum before posting that question. This app was a result of your answer. Thanks!

Awesome. That is funny.

I have looked high and low for a way to re-parent an existing device, but I don't think it exists. I have found use-cases for re-parenting to both apps and drivers but eventually gave up when I couldn't find any way of doing it.

How did you solve the cloud-based use-case? I just noticed that the method I used doesn't seem to work, presumably because the dashboard running on my mobile device is trying to access the image URL directly rather than through the backend on my local network like I would have expected.

On the weird behavior with multiple controllers that you saw: I set the DNI of the child motion (camera, doorbell) and button (doorbell) devices to a defined format that includes the MAC of the device plus its type of virtual device. So, when you have two parent drivers connected to the same controller, only one will actually be able to create a virtual device for a given child. I thought about further scoping the DNI value to the specific controller so that they could be duplicated, but I figured that was an unlikely corner case. It would be easy to change if needed, though -- for example in cases where someone wanted to use your app for some images and still have a standalone driver setup separately.

I noticed that the cloud dashboard url was just a very simple proxy serving the same paths.
It seems to work for any apps with OAuth and a mapping.

In fact, in the dashboardHelp page of my app, I render out the local url with with getLocalApiServerUrl(). If you change this to getApiServerUrl() you'll get the cloud url.
Their endpoint paths are both the same, only the domain changes for the most part.
So if you use the relative path for accessing the image (back two levels from the dashboard endpoint), it will load the image via the cloud or local, however you're accessing it.

It also works when accessing the Hubitat through a reverse proxy via an alternate port with TLS.

1 Like

You're right- I had a more fundamental issue that jpeg rendering to a cloud endpoint fails for some reason. Your svg method works fine. Thanks for that example!

Instead of having a tile on the dashboard with a live feed, is there a way to just install the Unifi Protect app ?
And have the app on the dashboard, then you can view the cameras from inside the app ?
Has anyone tried this ?

Just realized I never closed the loop back to this thread. Here's one method to do this, using vlc on an external machine to transcode the stream to mjpeg: App Link on Your Dashboard - #18 by tomw

So I just installed your app code and the 3 drivers, went through the steps, but #9 I can't find, The App page never populated with anything, but the devices populated great.

how can I get the "View Dashboard Snapshot Configuration"

I wrote the drivers and @JoKneeMo kindly shared one app to serve images for dashboards. I also shared my take on it, here: Ubiquiti Unifi Protect cameras - #127 by tomw

I never made mine part of the main package because I wasn't sure whether it was complete enough for users other than me. Want to try it out and I will make it part of the main package with the drivers if so?

Well I had the stuff installed and had the devices installed and could click on device and take snap and that worked, But could not get back to the APP he made to see the View Dashboard Snapshot Configuration" so I tried the proccess again and now getting an error that it cant connect to my unifi controller. So I tried to log into my controller and now it will not let me in. keeps saying my password is incorrect. (And I have lasspass auto populate it with out issue until now)

I think this broke my login into the controller as now I cant get in, and there is no password reset option. :frowning:

Can you log in to the controller outside of the Hubitat integration?

no not anymore. something broke it been fine for over a year.

That is very odd. Do you at least get its web interface to log in? Are you using a cloud or local login?

It can’t. It doesn’t make any changes to the controller.

1 Like

Ok looks like it was a time out, when I tried to recreate the setup again and add the controller back to Hubitat again, it for some reason created 8 copies, and that locked me out of the server. LOL. Going to create a user just for protect to avoid that issue in the future.

Back in my controller

1 Like

Ok so I just removed everything and started over, added the app code, and the 3 driver codes in, Added user app - Unifi Controller Manager, Enter in the info, Added controller, created child devices, I can see the links to create the dashboard links, but if I move away from the page, there is not way to get it back without deleting everything and recreating it. The app dose not ever appear as an installed app

I have not installed the other user's app before, but it is possible that you need to click Done or similar. If you want to try out my app I will be happy to assist: Ubiquiti Unifi Protect cameras - #127 by tomw

I will check it out

Got you code added and it works somewhat, added 2 cameras, one with cloud link and other with local. both showed up and updated, but only for a bit and then no more updates. It is set to refresh ever 5 seconds, yet nothing. updates anymore. I can manully update the pic in device, but the dash does not do it auto anymore (its like the image server stopped poling for updates)

Update: Removed and re added everything (Just your stuff this time) and still will not update and will not show now at all in dashboard. (Local or cloud)

OK, a couple of theories:

The image refreshes based on what is stored in the device attributes, but it doesn't actually take a new photo. You need to have something to execute the take command, like a rule that executes that when motion is detected or just does it on some time interval. That could explain the lack of updates.

On it not showing at all, you should note that the URL will change if you reinstall or use a different version of the app, since the app ID is embedded in the URL. So, you might need to check and make sure that the URL in the app configuration page for imageServer is the same one you are using in your dashboard tile. Just a hunch that those may be mismatched.

Ya I removed everything devices and child devices. App (image server) removed dashboard and started fresh. Still no poc shows when all reinstalled. Odd it worked before. I will look into it.

Did find a easy way to see it local only though and that might be all I need and then your drivers for motion. :slight_smile: