Silvenga / unifi-udm-api-proxy

A compatibility shim to support accessing the new UnifiOs API.
MIT License
11 stars 5 forks source link

Feature-Request: proxy as docker image for Hass.io (Raspberry Pi 4) #9

Closed adandl closed 4 years ago

adandl commented 4 years ago

Hello Mark!

I'm writing to you because I don't know if this should be raised as an issue in Github. I use your unifi-udm-api-proxy and it works just fine - thank you very much. Currently this runs on my Synology under Docker, but I'm wondering if you are working on providing this docker image also under hassio's addons? https://www.home-assistant.io/addons?

Keeping the Unifi Proxy on the same hardware as home assistant would reduce complexity of the setup.

What do you think? I use a Raspberry Pi 4 (32 bit) system.

Thank you!

Silvenga commented 4 years ago

I like this idea, but first ARM images will need to be created - possibly all architectures that Home-Assistant supports - tracking via https://github.com/Silvenga/unifi-udm-api-proxy/issues/10.

Silvenga commented 4 years ago

Done via https://github.com/Silvenga/unifi-udm-api-proxy-ha

@adandl can you try it and let me know if it works? I run HA in a VM, so I can only test amd64. My guess is that the PI4 will use the armv7 32-bit variant.

adandl commented 4 years ago

Hello Silvenga! Wow - thanks for providing it so quickly. I have an issue though - most probably with the configuration - can you pls look at this and advice?

Docker-Image seems to start up correctly: info: UdmApi.Proxy.Startup[0] Checking if database '/data/data.db' requires migrations. info: UdmApi.Proxy.Startup[0] Migration '20200323005645_Init' is missing, and will be applied. info: UdmApi.Proxy.Startup[0] Migration completed. info: Microsoft.Hosting.Lifetime[0] Now listening on: https://[::]:443 info: Microsoft.Hosting.Lifetime[0] Now listening on: http://[::]:80 info: Microsoft.Hosting.Lifetime[0] Application started. Press Ctrl+C to shut down. info: Microsoft.Hosting.Lifetime[0] Hosting environment: HASSIO info: Microsoft.Hosting.Lifetime[0] Content root path: /app

Here is my config unifiprotect: host: https://61535f70-unifi-udm-api-proxy:443 username: secretuser password: secretpassword image_width: 640 minimum_score: 0 And this is the error-message I receive in the log-file: Unable to connect to NVR: HTTPSConnectionPool(host='https', port=443): Max retries exceeded with url: //61535f70-unifi-udm-api-proxy:443:7443/api/auth (Caused by NewConnectionError('<urllib3.connection.VerifiedHTTPSConnection object at 0xb2428850>: Failed to establish a new connection: [Errno -3] Try again'))

Silvenga commented 4 years ago

I see in the logs, which means unifiprotect constructed the wrong endpoint address.

//61535f70-unifi-udm-api-proxy:443:7443

Try changing your config to:

unifiprotect: 
  host: 61535f70-unifi-udm-api-proxy
  port: 443 # This isn't documented, but it does work.
  username: secretuser 
  password: secretpassword 
  image_width: 640 
  minimum_score: 0
Silvenga commented 4 years ago

@adandl I pushed an update to have the proxy also listen on the default port.

So, if you could, can you try to update and update your config to:

unifiprotect: 
  host: 61535f70-unifi-udm-api-proxy
  username: secretuser 
  password: secretpassword 
  image_width: 640 
  minimum_score: 0
adandl commented 4 years ago

Success! I had to specify the port as you suggested in an earlier post. (without specifying it tried to access port: 7443.

Here is my docker-config: udm: uri: 'https://192.168.1.1'

and here is the configuration.yaml: unifiprotect: host: 61535f70-unifi-udm-api-proxy port: 443 username: secretuser password: secretpassword image_width: 640 minimum_score: 0

I have a suggestion for the next improvement :) simple mind - why not move the api-code from your proxy directly into @briis "Unifi Protect Integration for Home Assistant" to avoid the proxy ;-). I know i have no coding-skills - so maybe this is much more complex than it sounds :)

Kind regards and stay well!

Albert

Silvenga commented 4 years ago

Awesome @adandl!

To answer your question,

adandl commented 4 years ago

Hello @Silvenga! I switch to Intel NUC (because of bad performance of my PI). Any chance you could provide this image also for Intel Platform? Thanks a lot! Albert

Silvenga commented 4 years ago

Yep, I published an image for x64.

adandl commented 4 years ago

Thank you!!!! so quick :-) !!!