beele / homebridge-unifi-protect-camera-motion

Camera & Motion sensor support for Unifi Protect cameras in Homekit via Homebridge
Apache License 2.0
103 stars 12 forks source link

Unexpected token < in JSON at position 1 #94

Open Timdebruijn opened 3 years ago

Timdebruijn commented 3 years ago

Describe the bug Homebridge can't access API

Specifications What hardware and OS is your Homebridge running on?
A VM in VMware ESXI7, i5-8500T, 2GB ram, Ubuntu 20.04, Home bridge v1.3.4, homebridge-unifi-protect-camera-motion v0.4.5 The Unifi hardware: Cloud Key Gen2 Plus, firmware 2.1.11, protect 1.19.0

Logging

[9/14/2021, 1:30:25 PM] --- [9/14/2021, 1:30:25 PM] Loaded plugin: homebridge-config-ui-x@4.41.2 [9/14/2021, 1:30:25 PM] Registering platform 'homebridge-config-ui-x.config' [9/14/2021, 1:30:25 PM] --- 2021-09-14 13:30:26.101181: I tensorflow/core/platform/cpu_feature_guard.cc:142] Your CPU supports instructions that this TensorFlow binary was not compiled to use: AVX2 FMA 2021-09-14 13:30:26.116694: I tensorflow/core/platform/profile_utils/cpu_utils.cc:94] CPU Frequency: 2112000000 Hz 2021-09-14 13:30:26.117013: I tensorflow/compiler/xla/service/service.cc:168] XLA service 0x66848d0 initialized for platform Host (this does not guarantee that XLA will be used). Devices: 2021-09-14 13:30:26.117034: I tensorflow/compiler/xla/service/service.cc:176] StreamExecutor device (0): Host, Default Version [9/14/2021, 1:30:26 PM] Loaded plugin: homebridge-unifi-protect-camera-motion@0.4.5 [9/14/2021, 1:30:26 PM] Registering platform 'homebridge-unifi-protect-camera-motion.UnifiProtectMotion' [9/14/2021, 1:30:26 PM] --- [9/14/2021, 1:30:26 PM] Loading 2 platforms... [9/14/2021, 1:30:26 PM] [Config] Initializing config platform... [9/14/2021, 1:30:26 PM] [Config] Running in Service Mode [9/14/2021, 1:30:26 PM] [Unifi protect cameras & motion sensors] Initializing UnifiProtectMotion platform... Preparing Advertiser for 'Homebridge 1650 XXX' using bonjour-hap backend! Setup Payload: X-HM://00242XXXXXX Enter this code with your HomeKit app on your iOS device to pair with Homebridge:

┌────────────┐     
│ XXX-XX-XXX │     
└────────────┘     

Starting to advertise 'Homebridge 1650 DF75' using bonjour-hap backend! [9/14/2021, 1:30:26 PM] Homebridge v1.3.4 (Homebridge 1650) is running on port 51411. [9/14/2021, 1:30:26 PM] [Unifi protect cameras & motion sensors] Endpoint Style: UnifiOS [9/14/2021, 1:30:26 PM] [Unifi protect cameras & motion sensors] Cannot get cameras: Error: ERROR: Could not enumerate motion sensors: FetchError: invalid json response body at https://192.x.x.x/protect/proxy/protect/api/bootstrap reason: Unexpected token < in JSON at position 1 [9/14/2021, 1:30:28 PM] [Unifi protect cameras & motion sensors] Motion checking setup done!

To Reproduce Steps to reproduce the behavior:

  1. start the server with the plugin

Expected behavior Not the fetch error

beele commented 2 years ago

I'm also using UnifiOs and cannot reproduce this issue

dpankros commented 1 year ago

In the overwhelming majority of situations, that error is caused by a web server returning an error and, instead of providing JSON as requested, it's sending an error HTML page. (The "<" is the first character of the HTML page, but is illegal in JSON at that position and, hence, the error.) The first thing I'd do is to manually hit that url and see what you get: curl -vl 'https://192.x.x.x/protect/proxy/protect/api/bootstrap' I don't know if it's a POST or GET, but that should work for a GET. For a POST, we'd need to know what payload is being sent to get a reliable response. If it returns an error, try to figure out why (bad URL, for example).