Custom Component: Unifi Protect

One more quick question. I read thru most of this topic and not found information on 2 way audio. Does it only work in the protect app?

No you can use it via the homekit integration as well

Thanks, I’ll give it a try

And does this work on an Apple Watch as well? What about the audio latency when you use it through apple homekit?

Am i the only one that don’t have any audio from the G3 instant cam?

I think you are the only one lucky enough to own a G3 instant?

I received mine last week after a mere four month wait.
I do have audio in HA via the integration.

Same, I get audio on the G3 and G4.

Thanks for the nudge! I saw they are available again and snagged me one :slight_smile:

I also have audio on my G3 Instants.

I have a CloudKey Gen2+ and lately I’ve been getting a few error messages in my log repeatedly. I’ve not noticed it affecting functionality (i.e. my automation seems to always work when my doorbell is pressed), but I’m trying to figure out what’s going on. I’ve had some other weird network issues and some issues that seem specific to my CloudKey, so I’m wondering if this is completely on my end. Thoughts? Here’s the 3 errors I’m seeing:

Logger: custom_components.unifiprotect.data
Source: custom_components/unifiprotect/data.py:48
Integration: Unifi Protect
First occurred: May 3, 2021, 7:53:23 PM (2 occurrences)
Last logged: 4:36:43 AM

Error while updating

Traceback (most recent call last): File “/config/custom_components/unifiprotect/data.py”, line 48, in async_refresh await self._protectserver.update( File “/usr/local/lib/python3.8/site-packages/pyunifiprotect/unifi_protect_server.py”, line 144, in update updates = await self._get_events(lookback=10) File “/usr/local/lib/python3.8/site-packages/pyunifiprotect/unifi_protect_server.py”, line 419, in _get_events raise NvrError( pyunifiprotect.unifi_protect_server.NvrError: Fetching Eventlog failed: 500 - Reason: Internal Server Error

Logger: homeassistant
Source: custom_components/unifiprotect/data.py:48
First occurred: May 3, 2021, 2:24:30 PM (14 occurrences)
Last logged: 8:57:46 AM

Error doing job: Task exception was never retrieved
Traceback (most recent call last):
File “/config/custom_components/unifiprotect/data.py”, line 48, in async_refresh
await self._protectserver.update(
File “/usr/local/lib/python3.8/site-packages/pyunifiprotect/unifi_protect_server.py”, line 144, in update
updates = await self._get_events(lookback=10)
File “/usr/local/lib/python3.8/site-packages/pyunifiprotect/unifi_protect_server.py”, line 412, in _get_events
response = await self.req.get(
File “/usr/local/lib/python3.8/site-packages/aiohttp/client.py”, line 544, in _request
await resp.start(conn)
File “/usr/local/lib/python3.8/site-packages/aiohttp/client_reqrep.py”, line 890, in start
message, payload = await self._protocol.read() # type: ignore
File “/usr/local/lib/python3.8/site-packages/aiohttp/streams.py”, line 604, in read
await self._waiter
aiohttp.client_exceptions.ServerDisconnectedError: Server disconnected

Logger: homeassistant
Source: custom_components/unifiprotect/data.py:48
First occurred: May 3, 2021, 1:18:59 PM (151 occurrences)
Last logged: 10:03:23 AM

Error doing job: Task exception was never retrieved
Traceback (most recent call last):
File “/usr/local/lib/python3.8/site-packages/aiohttp/connector.py”, line 969, in _wrap_create_connection
return await self._loop.create_connection(*args, **kwargs) # type: ignore # noqa
File “/usr/local/lib/python3.8/asyncio/base_events.py”, line 1050, in create_connection
transport, protocol = await self._create_connection_transport(
File “/usr/local/lib/python3.8/asyncio/base_events.py”, line 1080, in _create_connection_transport
await waiter
File “/usr/local/lib/python3.8/asyncio/selector_events.py”, line 848, in _read_ready__data_received
data = self._sock.recv(self.max_size)
ConnectionResetError: [Errno 104] Connection reset by peer

The above exception was the direct cause of the following exception:

Traceback (most recent call last):
File “/config/custom_components/unifiprotect/data.py”, line 48, in async_refresh
await self._protectserver.update(
File “/usr/local/lib/python3.8/site-packages/pyunifiprotect/unifi_protect_server.py”, line 144, in update
updates = await self._get_events(lookback=10)
File “/usr/local/lib/python3.8/site-packages/pyunifiprotect/unifi_protect_server.py”, line 412, in _get_events
response = await self.req.get(
File “/usr/local/lib/python3.8/site-packages/aiohttp/client.py”, line 520, in _request
conn = await self._connector.connect(
File “/usr/local/lib/python3.8/site-packages/aiohttp/connector.py”, line 535, in connect
proto = await self._create_connection(req, traces, timeout)
File “/usr/local/lib/python3.8/site-packages/aiohttp/connector.py”, line 892, in _create_connection
_, proto = await self._create_direct_connection(req, traces, timeout)
File “/usr/local/lib/python3.8/site-packages/aiohttp/connector.py”, line 1051, in _create_direct_connection
raise last_exc
File “/usr/local/lib/python3.8/site-packages/aiohttp/connector.py”, line 1020, in _create_direct_connection
transp, proto = await self._wrap_create_connection(
File “/usr/local/lib/python3.8/site-packages/aiohttp/connector.py”, line 975, in _wrap_create_connection
raise client_error(req.connection_key, exc) from exc
aiohttp.client_exceptions.ClientConnectorError: Cannot connect to host 192.168.1.2:443 ssl:False [Connection reset by peer]

What version of UniFi Protect are you running? From the log it seems to be 1.x

I was on 1.17.4 when I posted this, but I just upgraded to 1.18.0.

I have just upgraded my CloudKey Plus to 2.0.27 from 1.?

I have removed the integration from HA and am trying to re add. I get a Unknown error occurred

Is there something else I need to remove before adding? Or some other simple thing I’ve missed?

This is in the logs

aiohttp.client_exceptions.ContentTypeError: 0, message='Attempt to decode JSON with unexpected mimetype: text/html; charset=utf-8', url=URL('https://192.168.1.100:443/proxy/protect/api/bootstrap')

This seems to be network related and not specific to this Integration.

Don’t worry. My error!

1 Like

I have the UniFi UDM pro icw the Doorbell, the automation for playing (not casting) an MP3 to a group of devices works fine, but i would like to send the picture of the doorbell as well. Basically, so we see on the google home who is at the door.

I see that you can send both an MP3 and ‘metadata’ as described here:

But i would like to know how to get the ‘latest’ image from the doorbell for that… Any clues?

For the latest picture i simply use camera.snapshot. At least that’s working great for the G3 Instant.

A little note to people about the latency. I’ve checked the github repo of home assistant and there is a pull request in the stream component to support LL-HLS codec in addition to HLS which according to the programmer will reduce the delay from 6-10 seconds to 1-5 seconds. So my take from that is that the latency/delay is not due the stream coming from the NVR but rather the same for all cameras using that codec.
Hopefully when this feature is proper tested it will be added to HA and we will see less delay.

For the nerds here are the link to the pull request, much info in the comments:
https://github.com/home-assistant/core/pull/49608

PS. Just installed the component and it seem to work great, will add automations and stuff when i have more time and maybe drop some more feedback. Good Job and thanks for a nice component!!

3 Likes

Thanks for the info Simon. I, and many others, really look forward to get that latency down.