gozoinks / homebridge-camera-ffmpeg-ufv

UniFi Video plugin for Homebridge
https://www.npmjs.com/package/homebridge-camera-ffmpeg-ufv
Other
76 stars 20 forks source link

Error parsing JSON #6

Closed focher closed 6 years ago

focher commented 6 years ago

I receive the following errors and no cameras are detected:

homebridge_1 | Sat, 27 Jan 2018 01:15:15 GMT camera-ffmpeg-ufv Discovered NVR Victoria Court homebridge_1 | Sat, 27 Jan 2018 01:15:15 GMT camera-ffmpeg-ufv Error parsing JSON! TypeError: Cannot read property 'forEach' of undefined

I'm on NVR version 3.9.0

I'll probably dig into the code and find the URI to grab the JSON, which I assume should be the list of video feeds.

focher commented 6 years ago

I threw some additional debug lines in the code and this is my full JSON response from the NVR. I don't see rtspPort under the systemInfo section of the JSON, but the code looks like it's looking for that value.

homebridge_1 | Sat, 27 Jan 2018 17:10:21 GMT camera-ffmpeg-ufv Discovered NVR {"serviceState":"READY","cloudHost":"video.ubnt.com","nvrName":"Victoria Court","isHardwareNvr":true,"isLoggedIn":false,"isFactoryDefault":false,"systemInfo":{"version":"3.9.0","hash":"645141","buildType":"release","buildJobName":"ufv/v3.9.0","buildNumber":"1","buildBranch":"v3.9.0","time":"2017-12-27 23:16","platform":"Debian7.11","mongoVersion":null,"protocolVersion":66,"httpPort":7080,"httpsPort":7443,"liveWsPort":7445,"liveWssPort":7446,"maxExportLimit":10000,"localAddr":null}}

gozoinks commented 6 years ago

It looks like you might have it pointed to the cloud service. Can you make sure it is configured to look at your NVR’s local IP?

focher commented 6 years ago

Just checked that and good idea, as I notice now that "cloudHost" is set as an attribute. However, my config.json is:

{ "bridge": { "name": "Homebridge", "username": "CC:22:3D:E3:CE:30", "port": 51826, "pin": "031-45-154" }, "description": "The Homebridge configuratin file.", "accessories": [ { "accessory": "Sonos", "name": "Living Room", "room": "Living Room" } ], "platforms": [ { "platform": "camera-ffmpeg-ufv", "name": "UniFi Video (ffmpeg)", "nvrs": [ { "apiHost": "192.168.1.60", "apiPort": 7443, "apiProtocol": "https", "apiKey": "a3zRRmbGkSlLf12d≈" } ] } ] }

So it definitely has the local IP specified. It seems to be running into an issue when trying to get the list of servers.

focher commented 6 years ago

Just tried one more thing...I regenerated the API key and replaced it. That got all the cameras detected! In fact, the debug shows a lot more JSON objects and attributes (as I had added a few more console debug logging).

I'll go from here to get it all working. Thanks!