keshavdv / unifi-cam-proxy

Enable non-Ubiquiti cameras to work with Unifi NVR
MIT License
1.68k stars 235 forks source link

Unifi Protect Dream Machine Pro #6

Closed nixis closed 3 years ago

nixis commented 3 years ago

Hi,

thanks for the that nice piece of software.

I have some trouble to adopt a camera, because I cant create an adoption token in the Unifi protect settings / dashboard, there is no option to generate or show a token. Bildschirmfoto 2020-09-14 um 11 00 33

If I run the command at the first time: unifi-cam-proxy --host 192.168.XXX.1 --cert client.pem --mac 'AA:BB:CC:00:11:22' --verbose --token '' rtsp -s rtsp://wowzaec2demo.streamlock.net/vod/mp4:BigBuckBunny_175k.mov

I get this message: 2020-09-14 11:05:29 unifi-camera-proxy RTSPCam[936] INFO /tmp/tmp93ukHV 2020-09-14 11:05:29 unifi-camera-proxy RTSPCam[936] INFO ffmpeg -y -re -rtsp_transport tcp -i "rtsp://wowzaec2demo.streamlock.net/vod/mp4:BigBuckBunny_175k.mov" -vf fps=1 -update 1 /tmp/tmp93ukHV/screen.jpg 2020-09-14 11:05:29 unifi-camera-proxy Core[936] INFO Creating ws connection to wss://192.168.XXX.1:7442/camera/1.0/ws?token= Traceback (most recent call last): File "/usr/local/bin/unifi-cam-proxy", line 11, in <module> sys.exit(main()) File "/usr/local/lib/python2.7/dist-packages/unifi/main.py", line 58, in main c.run() File "/usr/local/lib/python2.7/dist-packages/unifi/core.py", line 745, in run ws = websocket.create_connection(uri, sslopt=ssl_opts, header=headers) File "/usr/local/lib/python2.7/dist-packages/websocket/_core.py", line 515, in create_connection websock.connect(url, **options) File "/usr/local/lib/python2.7/dist-packages/websocket/_core.py", line 226, in connect self.handshake_response = handshake(self.sock, *addrs, **options) File "/usr/local/lib/python2.7/dist-packages/websocket/_handshake.py", line 80, in handshake status, resp = _get_resp_headers(sock) File "/usr/local/lib/python2.7/dist-packages/websocket/_handshake.py", line 165, in _get_resp_headers raise WebSocketBadStatusException("Handshake status %d %s", status, status_message, resp_headers) websocket._exceptions.WebSocketBadStatusException: Handshake status 403 Forbidden

Now I can manually adopt the camera at the Dashboard: Bildschirmfoto 2020-09-14 um 11 06 42 Bildschirmfoto 2020-09-14 um 11 08 10

Now I run the same command a second time unifi-cam-proxy --host 192.168.XXX.1 --cert client.pem --mac 'AA:BB:CC:00:11:22' --verbose --token '' rtsp -s rtsp://wowzaec2demo.streamlock.net/vod/mp4:BigBuckBunny_175k.mov

I get this message: 2020-09-14 11:12:00 unifi-camera-proxy RTSPCam[981] INFO /tmp/tmpwKcKgZ 2020-09-14 11:12:00 unifi-camera-proxy RTSPCam[981] INFO ffmpeg -y -re -rtsp_transport tcp -i "rtsp://wowzaec2demo.streamlock.net/vod/mp4:BigBuckBunny_175k.mov" -vf fps=1 -update 1 /tmp/tmpwKcKgZ/screen.jpg 2020-09-14 11:12:00 unifi-camera-proxy Core[981] INFO Creating ws connection to wss://192.168.XXX.1:7442/camera/1.0/ws?token= 2020-09-14 11:12:01 unifi-camera-proxy Core[981] INFO Initiating adoption with token [] and mac [AA:BB:CC:00:11:22] 2020-09-14 11:12:01 unifi-camera-proxy Core[981] DEBUG Sending: {'from': 'ubnt_avclient', 'functionName': 'ubnt_avclient_hello', 'inResponseTo': 0, 'to': 'UniFiVideo', 'responseExpected': False, 'messageId': 1, 'payload': {'connectionHost': '192.168.XXX.1', 'connectionSecurePort': 7442, 'rebootTimeoutSec': 30, 'name': 'unifi-cam-proxy', 'adoptionCode': '', 'idleTime': 191.96, 'protocolVersion': 67, 'mac': 'AA:BB:CC:00:11:22', 'uptime': 0.04075288772583008, 'fwVersion': 'UVC.S2L.v4.14.14.67.037e886.190630.1017', 'semver': 'v4.4.8', 'ip': '192.168.1.10', 'upgradeTimeoutSec': 150, 'model': 'UVC G3', 'hwrev': 19, 'totalLoad': 0.5474}} 2020-09-14 11:12:01 unifi-camera-proxy Core[981] INFO Processing [ubnt_avclient_hello] message 2020-09-14 11:12:01 unifi-camera-proxy Core[981] DEBUG Message contents: {u'from': u'UniFiVideo', u'functionName': u'ubnt_avclient_hello', u'inResponseTo': 1, u'to': u'ubnt_avclient', u'messageId': 11280, u'payload': {u'controllerName': u'unifi', u'overrideUuid': True, u'protocolVersion': 67}} Traceback (most recent call last): File "/usr/local/bin/unifi-cam-proxy", line 11, in <module> sys.exit(main()) File "/usr/local/lib/python2.7/dist-packages/unifi/main.py", line 58, in main c.run() File "/usr/local/lib/python2.7/dist-packages/unifi/core.py", line 759, in run reconnect = self.process(ws, msg) File "/usr/local/lib/python2.7/dist-packages/unifi/core.py", line 666, in process if m["responseExpected"] == False and m["functionName"] not in [ KeyError: 'responseExpected'

In the message I found a IP that not belongs to me "192.168.1.10", I found out this is the default camera ip, I dont use this option, because I connect to my cam directly to the rtsp stream like the bunny video.

Please help! What can i Do to get this working?

ZeekWorld commented 3 years ago

Can someone running this on UDM post some instructions on how to achieve it please? I have a UDM with 2 unifi cams and would like to add some none unifi. I gave the wiki a try, but got nowhere. Thanks in advance.

keshavdv commented 3 years ago

@ZeekWorld What steps did you try and what errors did you hit? In general, for troubleshooting assistance, the bare minimum is at least:

  1. The full unifi-cam-proxy command you're running with personal info redacted and make/model of the camera you are using
  2. Last 20-30 lines of unifi-cam-proxy output in a linked Gist/pastebin
ZeekWorld commented 3 years ago

Good morning @keshavdv , thank you for the quick response. Like I mentioned above, I got stuck with the Wiki. UDM Pro with Protect 1.18.0, two G3 Instant Cameras. Per the Wiki, I logged in via SSH to the UDM but can't run any of the commands under "Usage" on wiki Perhaps I am doing it wrong, it is why I asked if anybody with a UDM Pro could help with the steps by steps instreuctions. Thanks in advance!

image

image

keshavdv commented 3 years ago

Ah, this software is not intended to be run on the UDM itself, so you'll need a separate computer (e.g. Raspberry Pi, always running desktop/laptop) on which you should try running these commands.

ZeekWorld commented 3 years ago

I understand, but there are lots of messages here from user running it on the UDM.

jurajs5 commented 3 years ago

I understand, but there are lots of messages here from user running it on the UDM.

please read as "using with", not "running on". - you really need some other device to run this tool

keshavdv commented 3 years ago

@ZeekWorld I don't think anybody in this thread has tried it and I don't have access to one to be able to help troubleshoot, but it looks like the UDMP has native support for containers, so you might be able to run it on it with a variation of the following commands:

  1. Go through steps from #20 to enable SSH on G3 Instant
  2. Run the following on the UDMP itself
    scp ubnt@<your-g3-instant-IP>:/var/etc/persistent/server.pem /root/client.pem
    podman pull keshavdv/unifi-cam-proxy
    podman run --rm -v "/root/client.pem:/client.pem" keshavdv/unifi-cam-proxy unifi-cam-proxy --verbose --ip "<Camera IP>" --host <NVR IP> --cert /client.pem --token <Adoption token> rtsp -s rtsp://wowzaec2demo.streamlock.net/vod/mp4:BigBuckBunny_175k.mov