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

Unifi OS: Authenticated, returning session - Cannot get cameras #49

Closed janthony6 closed 4 years ago

janthony6 commented 4 years ago

Describe the bug Installed the plugin and finally got it to Authenticate. I'm using a UDMP with Unifi-OS.

Specifications RPBi4 UDMP - UnifiOS

Logging [Unifi protect cameras & motion sensors] Authenticated, returning session [Unifi protect cameras & motion sensors] Cannot get cameras: Error: ERROR: Could not enumerate motion sensors: Error: Invalid response, missing: cameras on data

beele commented 4 years ago

Could you provide a debug log? (be sure to redact sensitive data/information from it)

3uperduck commented 4 years ago

I've same problem RPi 3B UDMP with Unifi-OS. G3 Fiex

log [Unifi] Endpoint Style: UnifiOS [Unifi] WARNING: No previous session found, a new session must be created! [Unifi] Authenticated, returning session [Unifi] Cannot get cameras: Error: ERROR: Could not enumerate motion sensors: Error: Invalid response, missing: cameras on data

config.json { "name": "Unifi", "unifi": { "enhanced_classes": [], "controller": "https://192.168.50.1/protect/", "controller_rtsp": "rtsp://192.168.50.1:7447/7EmlHT0ArDZCMIvG", "username": "-----------", "password": "-----------", "motion_interval": 5000, "motion_repeat_interval": 30000, "motion_score": 50, "enhanced_motion": true, "enhanced_motion_score": 50, "save_snapshot": false, "debug": false }, "googlePhotos": { "upload_gphotos": false, "auth_redirectUrl": "http://localhost:8080/oauth2-callback" }, "videoConfig": { "maxStreams": 2, "maxWidth": 1024, "maxHeight": 576, "maxFPS": 15, "maxBitrate": 3000, "vcodec": "libx264", "packetSize": 376, "audio": false, "additionalCommandline": "-protocol_whitelist https,crypto,srtp,rtp,udp" }

cmfrazier commented 4 years ago

Same issue here. Protect Controller 1.14.10

Log

[Unifi] WARNING: No previous session found, a new session must be created!
[Unifi] Authenticated, returning session
[Unifi] Cannot get cameras: Error: ERROR: Could not enumerate motion sensors: Error: Invalid response, missing: cameras on data

Config


            "name": "Unifi protect cameras & motion sensors",
            "unifi": {
                "enhanced_classes": [],
                "controller": "https://10.0.1.1/protect",
                "controller_rtsp": "rtsp://10.0.1.1:7447",
                "username": "####",
                "password": "####",
                "motion_interval": 5000,
                "motion_repeat_interval": 30000,
                "motion_score": 50,
                "enhanced_motion": true,
                "enhanced_motion_score": 50,
                "save_snapshot": false,
                "debug": false
            },
            "googlePhotos": {
                "upload_gphotos": false,
                "auth_redirectUrl": "http://localhost:8080/oauth2-callback"
            },
            "videoConfig": {
                "maxStreams": 2,
                "maxWidth": 1920,
                "maxHeight": 1080,
                "maxFPS": 25,
                "maxBitrate": 6000,
                "vcodec": "h264_omx",
                "packetSize": 376,
                "audio": true,
                "additionalCommandline": "-protocol_whitelist https,crypto,srtp,rtp,udp"
            },
            "platform": "UnifiProtectMotion"
        }```
beele commented 4 years ago

without debug full logs I can't really do much...

3uperduck commented 4 years ago

how does debug full logs mean?

beele commented 4 years ago

set the debug option to true in the unifi config object: https://github.com/beele/homebridge-unifi-protect-camera-motion#unifi-config-fields restart homebridge and pipe the output of it to a file. Redact passwords & tokens from that file and upload it here.

3uperduck commented 4 years ago

That's it

[2020-6-11 7:57:01 ├F10: PM┤] [Unifi] Endpoint Style: UnifiOS [2020-6-11 7:57:01 ├F10: PM┤] [Unifi] WARNING: No previous session found, a new session must be created! [2020-6-11 7:57:01 ├F10: PM┤] [Unifi] { url: 'https://192.168.50.1/protect//api/auth/login', method: 'post', data: { username: '----------------', password: '--------------' }, headers: { common: { Accept: 'application/json, text/plain, /' }, delete: {}, get: {}, head: {}, post: { 'Content-Type': 'application/x-www-form-urlencoded' }, put: { 'Content-Type': 'application/x-www-form-urlencoded' }, patch: { 'Content-Type': 'application/x-www-form-urlencoded' }, 'Content-Type': 'application/json', 'X-CSRF-Token': '-------------------------------------------------------------' }, transformRequest: [ [Function: transformRequest] ], transformResponse: [ [Function: transformResponse] ], timeout: 1000, withCredentials: true, adapter: [Function: httpAdapter], responseType: 'json', xsrfCookieName: 'XSRF-TOKEN', xsrfHeaderName: 'X-XSRF-TOKEN', maxContentLength: -1, validateStatus: [Function: validateStatus], httpsAgent: Agent { _events: [Object: null prototype] { free: [Function], newListener: [Function: maybeEnableKeylog] }, _eventsCount: 2, _maxListeners: undefined, defaultPort: 443, protocol: 'https:', options: { rejectUnauthorized: false, path: null }, requests: {}, sockets: {}, freeSockets: {}, keepAliveMsecs: 1000, keepAlive: false, maxSockets: Infinity, maxFreeSockets: 256, maxCachedSessions: 100, _sessionCache: { map: {}, list: [] },

} } [2020-6-11 7:57:01 ├F10: PM┤] [Unifi] { status: 200, statusText: 'OK', headers: { vary: 'Origin', 'x-dns-prefetch-control': 'off', 'x-frame-options': 'SAMEORIGIN', 'strict-transport-security': 'max-age=15552000; includeSubDomains', 'x-download-options': 'noopen', 'x-content-type-options': 'nosniff', 'x-xss-protection': '1; mode=block', 'accept-ranges': 'bytes', 'x-csrf-token': '------------------------------------------------------------------', 'content-type': 'text/html; charset=utf-8', 'content-length': '357', 'x-response-time': '2ms', 'set-cookie': [ 'TOKEN=-----------------------------------------------------------------------------; path=/; secure; httponly' ], date: 'Thu, 11 Jun 2020 11:57:01 GMT', connection: 'close' }, config: { url: 'https://192.168.50.1/protect//api/auth/login', method: 'post', data: '{"username":"-----------------","password":"------------------"}', headers: { Accept: 'application/json, text/plain, /', 'Content-Type': 'application/json', 'X-CSRF-Token': '------------------------------------------------------', 'User-Agent': 'axios/0.19.2', 'Content-Length': 48 }, transformRequest: [ [Function: transformRequest] ], transformResponse: [ [Function: transformResponse] ], timeout: 1000, withCredentials: true, adapter: [Function: httpAdapter], responseType: 'json', xsrfCookieName: 'XSRF-TOKEN', xsrfHeaderName: 'X-XSRF-TOKEN', maxContentLength: -1, validateStatus: [Function: validateStatus], httpsAgent: Agent { _events: [Object: null prototype], _eventsCount: 2, _maxListeners: undefined, defaultPort: 443, protocol: 'https:', options: [Object], requests: {}, sockets: [Object], freeSockets: {}, keepAliveMsecs: 1000, keepAlive: false, maxSockets: Infinity, maxFreeSockets: 256, maxCachedSessions: 100, _sessionCache: [Object],

}

}, request: ClientRequest { _events: [Object: null prototype] { socket: [Array], abort: [Function], aborted: [Function], error: [Function], timeout: [Array], prefinish: [Function: requestOnPrefinish] }, _eventsCount: 6, _maxListeners: undefined, outputData: [], outputSize: 0, writable: true, _last: true, chunkedEncoding: false, shouldKeepAlive: false, useChunkedEncodingByDefault: true, sendDate: false, _removedConnection: false, _removedContLen: false, _removedTE: false, _contentLength: null, _hasBody: true, _trailer: '', finished: true, _headerSent: true, socket: TLSSocket { _tlsOptions: [Object], _secureEstablished: true, _securePending: false, _newSessionPending: false, _controlReleased: true, secureConnecting: true, _SNICallback: null, servername: false, alpnProtocol: false, authorized: false, authorizationError: 'DEPTH_ZERO_SELF_SIGNED_CERT', encrypted: true, _events: [Object: null prototype], _eventsCount: 10, connecting: false, _hadError: false, _parent: null, _host: null, _readableState: [ReadableState], readable: true, _maxListeners: undefined, _writableState: [WritableState], writable: false, allowHalfOpen: false, _sockname: null, _pendingData: null, _pendingEncoding: '', server: undefined, _server: null, ssl: [TLSWrap], _requestCert: true, _rejectUnauthorized: false, parser: null, _httpMessage: [Circular], timeout: 1000,

  [Symbol(verified)]: true,
  [Symbol(pendingSession)]: null,
  [Symbol(asyncId)]: 72,
  [Symbol(kHandle)]: [TLSWrap],
  [Symbol(kSetNoDelay)]: false,
  [Symbol(lastWriteQueueSize)]: 0,
  [Symbol(timeout)]: Timeout {
    _idleTimeout: 1000,
    _idlePrev: [TimersList],
    _idleNext: [Timeout],
    _idleStart: 9974,
    _onTimeout: [Function: bound ],
    _timerArgs: undefined,
    _repeat: null,
    _destroyed: false,
    [Symbol(refed)]: false,
    [Symbol(asyncId)]: 82,
    [Symbol(triggerId)]: 76
  },
  [Symbol(kBuffer)]: null,
  [Symbol(kBufferCb)]: null,
  [Symbol(kBufferGen)]: null,
  [Symbol(kCapture)]: false,
  [Symbol(kBytesRead)]: 0,
  [Symbol(kBytesWritten)]: 0,
  [Symbol(connect-options)]: [Object]
},
connection: TLSSocket {
  _tlsOptions: [Object],
  _secureEstablished: true,
  _securePending: false,
  _newSessionPending: false,
  _controlReleased: true,
  secureConnecting: true,
  _SNICallback: null,
  servername: false,
  alpnProtocol: false,
  authorized: false,
  authorizationError: 'DEPTH_ZERO_SELF_SIGNED_CERT',
  encrypted: true,
  _events: [Object: null prototype],
  _eventsCount: 10,
  connecting: false,
  _hadError: false,
  _parent: null,
  _host: null,
  _readableState: [ReadableState],
  readable: true,
  _maxListeners: undefined,
  _writableState: [WritableState],
  writable: false,
  allowHalfOpen: false,
  _sockname: null,
  _pendingData: null,
  _pendingEncoding: '',
  server: undefined,
  _server: null,
  ssl: [TLSWrap],
  _requestCert: true,
  _rejectUnauthorized: false,
  parser: null,
  _httpMessage: [Circular],
  timeout: 1000,
  [Symbol(res)]: [TLSWrap],
  [Symbol(verified)]: true,
  [Symbol(pendingSession)]: null,
  [Symbol(asyncId)]: 72,
  [Symbol(kHandle)]: [TLSWrap],
  [Symbol(kSetNoDelay)]: false,
  [Symbol(lastWriteQueueSize)]: 0,
  [Symbol(timeout)]: Timeout {
    _idleTimeout: 1000,
    _idlePrev: [TimersList],
    _idleNext: [Timeout],
    _idleStart: 9974,
    _onTimeout: [Function: bound ],
    _timerArgs: undefined,
    _repeat: null,
    _destroyed: false,
    [Symbol(refed)]: false,
    [Symbol(asyncId)]: 82,
    [Symbol(triggerId)]: 76
  },
  [Symbol(kBuffer)]: null,
  [Symbol(kBufferCb)]: null,
  [Symbol(kBufferGen)]: null,
  [Symbol(kCapture)]: false,
  [Symbol(kBytesRead)]: 0,
  [Symbol(kBytesWritten)]: 0,
  [Symbol(connect-options)]: [Object]
},
_header: 'POST /protect//api/auth/login HTTP/1.1\r\n' +
  'Accept: application/json, text/plain, */*\r\n' +
  'Content-Type: application/json\r\n' +
  'X-CSRF-Token: ------------------------------------------' +
  'User-Agent: axios/0.19.2\r\n' +
  'Content-Length: 48\r\n' +
  'Host: 192.168.50.1\r\n' +
  'Connection: close\r\n' +
  '\r\n',
_onPendingData: [Function: noopPendingOutput],
agent: Agent {
  _events: [Object: null prototype],
  _eventsCount: 2,
  _maxListeners: undefined,
  defaultPort: 443,
  protocol: 'https:',
  options: [Object],
  requests: {},
  sockets: [Object],
  freeSockets: {},
  keepAliveMsecs: 1000,
  keepAlive: false,
  maxSockets: Infinity,
  maxFreeSockets: 256,
  maxCachedSessions: 100,
  _sessionCache: [Object],
  [Symbol(kCapture)]: false
},
socketPath: undefined,
method: 'POST',
insecureHTTPParser: undefined,
path: '/protect//api/auth/login',
_ended: true,
res: IncomingMessage {
  _readableState: [ReadableState],
  readable: false,
  _events: [Object: null prototype],
  _eventsCount: 3,
  _maxListeners: undefined,
  socket: [TLSSocket],
  connection: [TLSSocket],
  httpVersionMajor: 1,
  httpVersionMinor: 1,
  httpVersion: '1.1',
  complete: true,
  headers: [Object],
  rawHeaders: [Array],
  trailers: {},
  rawTrailers: [],
  aborted: false,
  upgrade: false,
  url: '',
  method: null,
  statusCode: 200,
  statusMessage: 'OK',
  client: [TLSSocket],
  _consuming: true,
  _dumped: false,
  req: [Circular],
  responseUrl: 'https://192.168.50.1/protect//api/auth/login',
  redirects: [],
  [Symbol(kCapture)]: false
},
aborted: false,
timeoutCb: [Function: emitRequestTimeout],
upgradeOrConnect: false,
parser: null,
maxHeadersCount: null,
reusedSocket: false,
_redirectable: Writable {
  _writableState: [WritableState],
  writable: true,
  _events: [Object: null prototype],
  _eventsCount: 2,
  _maxListeners: undefined,
  _options: [Object],
  _redirectCount: 0,
  _redirects: [],
  _requestBodyLength: 48,
  _requestBodyBuffers: [],
  _onNativeResponse: [Function],
  _currentRequest: [Circular],
  _currentUrl: 'https://192.168.50.1/protect//api/auth/login',
  [Symbol(kCapture)]: false
},
[Symbol(kCapture)]: false,
[Symbol(kNeedDrain)]: false,
[Symbol(corked)]: 0,
[Symbol(kOutHeaders)]: [Object: null prototype] {
  accept: [Array],
  'content-type': [Array],
  'x-csrf-token': [Array],
  'user-agent': [Array],
  'content-length': [Array],
  host: [Array]
}

}, data: '\n' + '<!doctype html>\n' + '\n' + '\n' + '\n' + '\n' + '\n' + '

\n' + '\n' + '\n' } [2020-6-11 7:57:01 ├F10: PM┤] [Unifi] Authenticated, returning session [2020-6-11 7:57:01 ├F10: PM┤] [Unifi] { url: 'https://192.168.50.1/protect//proxy/protect/api/bootstrap', method: 'get', headers: { common: { Accept: 'application/json, text/plain, /' }, delete: {}, get: {}, head: {}, post: { 'Content-Type': 'application/x-www-form-urlencoded' }, put: { 'Content-Type': 'application/x-www-form-urlencoded' }, patch: { 'Content-Type': 'application/x-www-form-urlencoded' }, 'Content-Type': 'application/json', 'X-CSRF-Token': '---------------------------------------------------', Cookie: 'TOKEN=--------------------------------; path=/; secure; httponly' }, transformRequest: [ [Function: transformRequest] ], transformResponse: [ [Function: transformResponse] ], timeout: 1000, withCredentials: true, adapter: [Function: httpAdapter], responseType: 'json', xsrfCookieName: 'XSRF-TOKEN', xsrfHeaderName: 'X-XSRF-TOKEN', maxContentLength: -1, validateStatus: [Function: validateStatus], httpsAgent: Agent { _events: [Object: null prototype] { free: [Function], newListener: [Function: maybeEnableKeylog] }, _eventsCount: 2, _maxListeners: undefined, defaultPort: 443, protocol: 'https:', options: { rejectUnauthorized: false, path: null }, requests: {}, sockets: { '192.168.50.1:443::::::::false::::::::::': [Array] }, freeSockets: {}, keepAliveMsecs: 1000, keepAlive: false, maxSockets: Infinity, maxFreeSockets: 256, maxCachedSessions: 100, _sessionCache: { map: [Object], list: [Array] },

} } [2020-6-11 7:57:01 ├F10: PM┤] [Unifi] { status: 200, statusText: 'OK', headers: { vary: 'Origin', 'x-dns-prefetch-control': 'off', 'x-frame-options': 'SAMEORIGIN', 'strict-transport-security': 'max-age=15552000; includeSubDomains', 'x-download-options': 'noopen', 'x-content-type-options': 'nosniff', 'x-xss-protection': '1; mode=block', 'accept-ranges': 'bytes', 'x-csrf-token': '-------------------------------------------', 'content-type': 'text/html; charset=utf-8', 'content-length': '357', 'x-response-time': '2ms', 'set-cookie': [ 'TOKEN=--------------------------------------------------; path=/; secure; httponly' ], date: 'Thu, 11 Jun 2020 11:57:01 GMT', connection: 'close' }, config: { url: 'https://192.168.50.1/protect//proxy/protect/api/bootstrap', method: 'get', headers: { Accept: 'application/json, text/plain, /', 'Content-Type': 'application/json', 'X-CSRF-Token': '-----------------------------------------------------', Cookie: 'TOKEN=-----------------------------------------; path=/; secure; httponly', 'User-Agent': 'axios/0.19.2' }, transformRequest: [ [Function: transformRequest] ], transformResponse: [ [Function: transformResponse] ], timeout: 1000, withCredentials: true, adapter: [Function: httpAdapter], responseType: 'json', xsrfCookieName: 'XSRF-TOKEN', xsrfHeaderName: 'X-XSRF-TOKEN', maxContentLength: -1, validateStatus: [Function: validateStatus], httpsAgent: Agent { _events: [Object: null prototype], _eventsCount: 2, _maxListeners: undefined, defaultPort: 443, protocol: 'https:', options: [Object], requests: {}, sockets: [Object], freeSockets: {}, keepAliveMsecs: 1000, keepAlive: false, maxSockets: Infinity, maxFreeSockets: 256, maxCachedSessions: 100, _sessionCache: [Object],

},
data: undefined

}, request: ClientRequest { _events: [Object: null prototype] { socket: [Array], abort: [Function], aborted: [Function], error: [Function], timeout: [Array], prefinish: [Function: requestOnPrefinish] }, _eventsCount: 6, _maxListeners: undefined, outputData: [], outputSize: 0, writable: true, _last: true, chunkedEncoding: false, shouldKeepAlive: false, useChunkedEncodingByDefault: false, sendDate: false, _removedConnection: false, _removedContLen: false, _removedTE: false, _contentLength: 0, _hasBody: true, _trailer: '', finished: true, _headerSent: true, socket: TLSSocket { _tlsOptions: [Object], _secureEstablished: true, _securePending: false, _newSessionPending: false, _controlReleased: true, secureConnecting: true, _SNICallback: null, servername: false, alpnProtocol: false, authorized: false, authorizationError: 'DEPTH_ZERO_SELF_SIGNED_CERT', encrypted: true, _events: [Object: null prototype], _eventsCount: 10, connecting: false, _hadError: false, _parent: null, _host: null, _readableState: [ReadableState], readable: true, _maxListeners: undefined, _writableState: [WritableState], writable: false, allowHalfOpen: false, _sockname: null, _pendingData: null, _pendingEncoding: '', server: undefined, _server: null, ssl: [TLSWrap], _requestCert: true, _rejectUnauthorized: false, parser: null, _httpMessage: [Circular], timeout: 1000,

  [Symbol(verified)]: true,
  [Symbol(pendingSession)]: null,
  [Symbol(asyncId)]: 98,
  [Symbol(kHandle)]: [TLSWrap],
  [Symbol(kSetNoDelay)]: false,
  [Symbol(lastWriteQueueSize)]: 0,
  [Symbol(timeout)]: Timeout {
    _idleTimeout: 1000,
    _idlePrev: [TimersList],
    _idleNext: [Timeout],
    _idleStart: 10014,
    _onTimeout: [Function: bound ],
    _timerArgs: undefined,
    _repeat: null,
    _destroyed: false,
    [Symbol(refed)]: false,
    [Symbol(asyncId)]: 112,
    [Symbol(triggerId)]: 102
  },
  [Symbol(kBuffer)]: null,
  [Symbol(kBufferCb)]: null,
  [Symbol(kBufferGen)]: null,
  [Symbol(kCapture)]: false,
  [Symbol(kBytesRead)]: 0,
  [Symbol(kBytesWritten)]: 0,
  [Symbol(connect-options)]: [Object]
},
connection: TLSSocket {
  _tlsOptions: [Object],
  _secureEstablished: true,
  _securePending: false,
  _newSessionPending: false,
  _controlReleased: true,
  secureConnecting: true,
  _SNICallback: null,
  servername: false,
  alpnProtocol: false,
  authorized: false,
  authorizationError: 'DEPTH_ZERO_SELF_SIGNED_CERT',
  encrypted: true,
  _events: [Object: null prototype],
  _eventsCount: 10,
  connecting: false,
  _hadError: false,
  _parent: null,
  _host: null,
  _readableState: [ReadableState],
  readable: true,
  _maxListeners: undefined,
  _writableState: [WritableState],
  writable: false,
  allowHalfOpen: false,
  _sockname: null,
  _pendingData: null,
  _pendingEncoding: '',
  server: undefined,
  _server: null,
  ssl: [TLSWrap],
  _requestCert: true,
  _rejectUnauthorized: false,
  parser: null,
  _httpMessage: [Circular],
  timeout: 1000,
  [Symbol(res)]: [TLSWrap],
  [Symbol(verified)]: true,
  [Symbol(pendingSession)]: null,
  [Symbol(asyncId)]: 98,
  [Symbol(kHandle)]: [TLSWrap],
  [Symbol(kSetNoDelay)]: false,
  [Symbol(lastWriteQueueSize)]: 0,
  [Symbol(timeout)]: Timeout {
    _idleTimeout: 1000,
    _idlePrev: [TimersList],
    _idleNext: [Timeout],
    _idleStart: 10014,
    _onTimeout: [Function: bound ],
    _timerArgs: undefined,
    _repeat: null,
    _destroyed: false,
    [Symbol(refed)]: false,
    [Symbol(asyncId)]: 112,
    [Symbol(triggerId)]: 102
  },
  [Symbol(kBuffer)]: null,
  [Symbol(kBufferCb)]: null,
  [Symbol(kBufferGen)]: null,
  [Symbol(kCapture)]: false,
  [Symbol(kBytesRead)]: 0,
  [Symbol(kBytesWritten)]: 0,
  [Symbol(connect-options)]: [Object]
},
_header: 'GET /protect//proxy/protect/api/bootstrap HTTP/1.1\r\n' +
  'Accept: application/json, text/plain, */*\r\n' +
  'Content-Type: application/json\r\n' +
  'X-CSRF-Token: -----------------------------------------------\r\n' +
  'Cookie: TOKEN=-------------------------------------------------------; path=/; secure; httponly\r\n' +
  'User-Agent: axios/0.19.2\r\n' +
  'Host: 192.168.50.1\r\n' +
  'Connection: close\r\n' +
  '\r\n',
_onPendingData: [Function: noopPendingOutput],
agent: Agent {
  _events: [Object: null prototype],
  _eventsCount: 2,
  _maxListeners: undefined,
  defaultPort: 443,
  protocol: 'https:',
  options: [Object],
  requests: {},
  sockets: [Object],
  freeSockets: {},
  keepAliveMsecs: 1000,
  keepAlive: false,
  maxSockets: Infinity,
  maxFreeSockets: 256,
  maxCachedSessions: 100,
  _sessionCache: [Object],
  [Symbol(kCapture)]: false
},
socketPath: undefined,
method: 'GET',
insecureHTTPParser: undefined,
path: '/protect//proxy/protect/api/bootstrap',
_ended: true,
res: IncomingMessage {
  _readableState: [ReadableState],
  readable: false,
  _events: [Object: null prototype],
  _eventsCount: 3,
  _maxListeners: undefined,
  socket: [TLSSocket],
  connection: [TLSSocket],
  httpVersionMajor: 1,
  httpVersionMinor: 1,
  httpVersion: '1.1',
  complete: true,
  headers: [Object],
  rawHeaders: [Array],
  trailers: {},
  rawTrailers: [],
  aborted: false,
  upgrade: false,
  url: '',
  method: null,
  statusCode: 200,
  statusMessage: 'OK',
  client: [TLSSocket],
  _consuming: true,
  _dumped: false,
  req: [Circular],
  responseUrl: 'https://192.168.50.1/protect//proxy/protect/api/bootstrap',
  redirects: [],
  [Symbol(kCapture)]: false
},
aborted: false,
timeoutCb: [Function: emitRequestTimeout],
upgradeOrConnect: false,
parser: null,
maxHeadersCount: null,
reusedSocket: false,
_redirectable: Writable {
  _writableState: [WritableState],
  writable: true,
  _events: [Object: null prototype],
  _eventsCount: 2,
  _maxListeners: undefined,
  _options: [Object],
  _redirectCount: 0,
  _redirects: [],
  _requestBodyLength: 0,
  _requestBodyBuffers: [],
  _onNativeResponse: [Function],
  _currentRequest: [Circular],
  _currentUrl: 'https://192.168.50.1/protect//proxy/protect/api/bootstrap',
  [Symbol(kCapture)]: false
},
[Symbol(kCapture)]: false,
[Symbol(kNeedDrain)]: false,
[Symbol(corked)]: 0,
[Symbol(kOutHeaders)]: [Object: null prototype] {
  accept: [Array],
  'content-type': [Array],
  'x-csrf-token': [Array],
  cookie: [Array],
  'user-agent': [Array],
  host: [Array]
}

}, data: '\n' + '<!doctype html>\n' + '\n' + '\n' + '\n' + '\n' + '\n' + '

\n' + '\n' + '\n' } [2020-6-11 7:57:01 ├F10: PM┤] [Unifi] Cannot get cameras: Error: ERROR: Could not enumerate motion sensors: Error: Invalid response, missing: cameras on data

3uperduck commented 4 years ago

I've change "https://192.168.50.1/protect/" to "https://192.168.50.1/protect" but same result

beele commented 4 years ago

The strange thing is that the login is working but the subsequent call returns no data...

3uperduck commented 4 years ago

yeah, Unifi is always open beta......

cmfrazier commented 4 years ago

[6/11/2020, 15:19:00] [Unifi protect cameras & motion sensors] {
  url: 'https://10.0.1.1/protect/proxy/protect/api/bootstrap',
  method: 'get',
  headers: {
    common: { Accept: 'application/json, text/plain, */*' },
    delete: {},
    get: {},
    head: {},
    post: { 'Content-Type': 'application/x-www-form-urlencoded' },
    put: { 'Content-Type': 'application/x-www-form-urlencoded' },
    patch: { 'Content-Type': 'application/x-www-form-urlencoded' },
    'Content-Type': 'application/json',
    'X-CSRF-Token': 'TOKEN',
    Cookie: 'TOKEN=eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJjc3JmVG9rZW4iOiJhMDM2YTljMS00NjRmLTQ0MDItOGNjZS1kYTU5MmI5ODJjMDkiLCJpYXQiOjE1OTE5MDY3NDAsImV4cCI6MTU5MTkxMDM0MH0._Jy-59X83DEed8OGv-Ks_PtP6aNdo7PJPIgm275LXAk; path=/; secure; httponly'
  },
  transformRequest: [ [Function: transformRequest] ],
  transformResponse: [ [Function: transformResponse] ],
  timeout: 1000,
  withCredentials: true,
  adapter: [Function: httpAdapter],
  responseType: 'json',
  xsrfCookieName: 'XSRF-TOKEN',
  xsrfHeaderName: 'X-XSRF-TOKEN',
  maxContentLength: -1,
  validateStatus: [Function: validateStatus],
  httpsAgent: Agent {
    _events: [Object: null prototype] {
      free: [Function],
      newListener: [Function: maybeEnableKeylog]
    },
    _eventsCount: 2,
    _maxListeners: undefined,
    defaultPort: 443,
    protocol: 'https:',
    options: { rejectUnauthorized: false, path: null },
    requests: {},
    sockets: { '10.0.1.1:443::::::::false::::::::::': [Array] },
    freeSockets: {},
    keepAliveMsecs: 1000,
    keepAlive: false,
    maxSockets: Infinity,
    maxFreeSockets: 256,
    maxCachedSessions: 100,
    _sessionCache: { map: [Object], list: [Array] },
    [Symbol(kCapture)]: false
  }
}
[6/11/2020, 15:19:00] [Unifi protect cameras & motion sensors] {
  status: 200,
  statusText: 'OK',
  headers: {
    vary: 'Origin',
    'x-dns-prefetch-control': 'off',
    'x-frame-options': 'SAMEORIGIN',
    'strict-transport-security': 'max-age=15552000; includeSubDomains',
    'x-download-options': 'noopen',
    'x-content-type-options': 'nosniff',
    'x-xss-protection': '1; mode=block',
    'accept-ranges': 'bytes',
    'x-csrf-token': 'TOKEN',
    'content-type': 'text/html; charset=utf-8',
    'content-length': '357',
    'x-response-time': '3ms',
    'set-cookie': [
      'TOKEN=TOKEN; path=/; secure; httponly'
    ],
    date: 'Thu, 11 Jun 2020 20:19:00 GMT',
    connection: 'close'
  },
  config: {
    url: 'https://10.0.1.1/protect/proxy/protect/api/bootstrap',
    method: 'get',
    headers: {
      Accept: 'application/json, text/plain, */*',
      'Content-Type': 'application/json',
      'X-CSRF-Token': 'TOKEN',
      Cookie: 'TOKEN=TOKEN; path=/; secure; httponly',
      'User-Agent': 'axios/0.19.2'
    },
    transformRequest: [ [Function: transformRequest] ],
    transformResponse: [ [Function: transformResponse] ],
    timeout: 1000,
    withCredentials: true,
    adapter: [Function: httpAdapter],
    responseType: 'json',
    xsrfCookieName: 'XSRF-TOKEN',
    xsrfHeaderName: 'X-XSRF-TOKEN',
    maxContentLength: -1,
    validateStatus: [Function: validateStatus],
    httpsAgent: Agent {
      _events: [Object: null prototype],
      _eventsCount: 2,
      _maxListeners: undefined,
      defaultPort: 443,
      protocol: 'https:',
      options: [Object],
      requests: {},
      sockets: [Object],
      freeSockets: {},
      keepAliveMsecs: 1000,
      keepAlive: false,
      maxSockets: Infinity,
      maxFreeSockets: 256,
      maxCachedSessions: 100,
      _sessionCache: [Object],
      [Symbol(kCapture)]: false
    },
    data: undefined
  },
  request: ClientRequest {
    _events: [Object: null prototype] {
      socket: [Array],
      abort: [Function],
      aborted: [Function],
      error: [Function],
      timeout: [Array],
      prefinish: [Function: requestOnPrefinish]
    },
    _eventsCount: 6,
    _maxListeners: undefined,
    outputData: [],
    outputSize: 0,
    writable: true,
    _last: true,
    chunkedEncoding: false,
    shouldKeepAlive: false,
    useChunkedEncodingByDefault: false,
    sendDate: false,
    _removedConnection: false,
    _removedContLen: false,
    _removedTE: false,
    _contentLength: 0,
    _hasBody: true,
    _trailer: '',
    finished: true,
    _headerSent: true,
    socket: TLSSocket {
      _tlsOptions: [Object],
      _secureEstablished: true,
      _securePending: false,
      _newSessionPending: false,
      _controlReleased: true,
      _SNICallback: null,
      servername: false,
      alpnProtocol: false,
      authorized: false,
      authorizationError: 'DEPTH_ZERO_SELF_SIGNED_CERT',
      encrypted: true,
      _events: [Object: null prototype],
      _eventsCount: 10,
      connecting: false,
      _hadError: false,
      _parent: null,
      _host: null,
      _readableState: [ReadableState],
      readable: true,
      _maxListeners: undefined,
      _writableState: [WritableState],
      writable: false,
      allowHalfOpen: false,
      _sockname: null,
      _pendingData: null,
      _pendingEncoding: '',
      server: undefined,
      _server: null,
      ssl: [TLSWrap],
      _requestCert: true,
      _rejectUnauthorized: false,
      parser: null,
      _httpMessage: [Circular],
      timeout: 1000,
      [Symbol(res)]: [TLSWrap],
      [Symbol(asyncId)]: 507,
      [Symbol(kHandle)]: [TLSWrap],
      [Symbol(kSetNoDelay)]: false,
      [Symbol(lastWriteQueueSize)]: 0,
      [Symbol(timeout)]: Timeout {
        _idleTimeout: 1000,
        _idlePrev: [TimersList],
        _idleNext: [Timeout],
        _idleStart: 6547,
        _onTimeout: [Function: bound ],
        _timerArgs: undefined,
        _repeat: null,
        _destroyed: false,
        [Symbol(refed)]: false,
        [Symbol(asyncId)]: 520,
        [Symbol(triggerId)]: 511
      },
      [Symbol(kBuffer)]: null,
      [Symbol(kBufferCb)]: null,
      [Symbol(kBufferGen)]: null,
      [Symbol(kCapture)]: false,
      [Symbol(kBytesRead)]: 0,
      [Symbol(kBytesWritten)]: 0,
      [Symbol(connect-options)]: [Object]
    },
    connection: TLSSocket {
      _tlsOptions: [Object],
      _secureEstablished: true,
      _securePending: false,
      _newSessionPending: false,
      _controlReleased: true,
      _SNICallback: null,
      servername: false,
      alpnProtocol: false,
      authorized: false,
      authorizationError: 'DEPTH_ZERO_SELF_SIGNED_CERT',
      encrypted: true,
      _events: [Object: null prototype],
      _eventsCount: 10,
      connecting: false,
      _hadError: false,
      _parent: null,
      _host: null,
      _readableState: [ReadableState],
      readable: true,
      _maxListeners: undefined,
      _writableState: [WritableState],
      writable: false,
      allowHalfOpen: false,
      _sockname: null,
      _pendingData: null,
      _pendingEncoding: '',
      server: undefined,
      _server: null,
      ssl: [TLSWrap],
      _requestCert: true,
      _rejectUnauthorized: false,
      parser: null,
      _httpMessage: [Circular],
      timeout: 1000,
      [Symbol(res)]: [TLSWrap],
      [Symbol(asyncId)]: 507,
      [Symbol(kHandle)]: [TLSWrap],
      [Symbol(kSetNoDelay)]: false,
      [Symbol(lastWriteQueueSize)]: 0,
      [Symbol(timeout)]: Timeout {
        _idleTimeout: 1000,
        _idlePrev: [TimersList],
        _idleNext: [Timeout],
        _idleStart: 6547,
        _onTimeout: [Function: bound ],
        _timerArgs: undefined,
        _repeat: null,
        _destroyed: false,
        [Symbol(refed)]: false,
        [Symbol(asyncId)]: 520,
        [Symbol(triggerId)]: 511
      },
      [Symbol(kBuffer)]: null,
      [Symbol(kBufferCb)]: null,
      [Symbol(kBufferGen)]: null,
      [Symbol(kCapture)]: false,
      [Symbol(kBytesRead)]: 0,
      [Symbol(kBytesWritten)]: 0,
      [Symbol(connect-options)]: [Object]
    },
    _header: 'GET /protect/proxy/protect/api/bootstrap HTTP/1.1\r\n' +
      'Accept: application/json, text/plain, */*\r\n' +
      'Content-Type: application/json\r\n' +
      'X-CSRF-Token: f153649c-4a8b-42fc-88ae-e328ce03ced2\r\n' +
      'Cookie: TOKEN=TOKEN; path=/; secure; httponly\r\n' +
      'User-Agent: axios/0.19.2\r\n' +
      'Host: 10.0.1.1\r\n' +
      'Connection: close\r\n' +
      '\r\n',
    _onPendingData: [Function: noopPendingOutput],
    agent: Agent {
      _events: [Object: null prototype],
      _eventsCount: 2,
      _maxListeners: undefined,
      defaultPort: 443,
      protocol: 'https:',
      options: [Object],
      requests: {},
      sockets: [Object],
      freeSockets: {},
      keepAliveMsecs: 1000,
      keepAlive: false,
      maxSockets: Infinity,
      maxFreeSockets: 256,
      maxCachedSessions: 100,
      _sessionCache: [Object],
      [Symbol(kCapture)]: false
    },
    socketPath: undefined,
    method: 'GET',
    insecureHTTPParser: undefined,
    path: '/protect/proxy/protect/api/bootstrap',
    _ended: true,
    res: IncomingMessage {
      _readableState: [ReadableState],
      readable: false,
      _events: [Object: null prototype],
      _eventsCount: 3,
      _maxListeners: undefined,
      socket: [TLSSocket],
      connection: [TLSSocket],
      httpVersionMajor: 1,
      httpVersionMinor: 1,
      httpVersion: '1.1',
      complete: true,
      headers: [Object],
      rawHeaders: [Array],
      trailers: {},
      rawTrailers: [],
      aborted: false,
      upgrade: false,
      url: '',
      method: null,
      statusCode: 200,
      statusMessage: 'OK',
      client: [TLSSocket],
      _consuming: true,
      _dumped: false,
      req: [Circular],
      responseUrl: 'https://10.0.1.1/protect/proxy/protect/api/bootstrap',
      redirects: [],
      [Symbol(kCapture)]: false
    },
    aborted: false,
    timeoutCb: [Function: emitRequestTimeout],
    upgradeOrConnect: false,
    parser: null,
    maxHeadersCount: null,
    reusedSocket: false,
    _redirectable: Writable {
      _writableState: [WritableState],
      writable: true,
      _events: [Object: null prototype],
      _eventsCount: 2,
      _maxListeners: undefined,
      _options: [Object],
      _redirectCount: 0,
      _redirects: [],
      _requestBodyLength: 0,
      _requestBodyBuffers: [],
      _onNativeResponse: [Function],
      _currentRequest: [Circular],
      _currentUrl: 'https://10.0.1.1/protect/proxy/protect/api/bootstrap',
      [Symbol(kCapture)]: false
    },
    [Symbol(kCapture)]: false,
    [Symbol(kNeedDrain)]: false,
    [Symbol(corked)]: 0,
    [Symbol(kOutHeaders)]: [Object: null prototype] {
      accept: [Array],
      'content-type': [Array],
      'x-csrf-token': [Array],
      cookie: [Array],
      'user-agent': [Array],
      host: [Array]
    }
  },
  data: '\n' +
    '<!doctype html>\n' +
    '<html lang="en">\n' +
    '<head>\n' +
    '<meta charset="utf-8">\n' +
    '<meta name="viewport" content="width=device-width,initial-scale=1"><link href="/2.css" rel="stylesheet"></head>\n' +
    '<body>\n' +
    '<div id="root"></div>\n' +
    '<script type="text/javascript" src="/vendor.0016115f.chunk.js"></script><script type="text/javascript" src="/main.2a54c508.js"></script></body>\n' +
    '</html>\n'
}
[6/11/2020, 15:19:00] [Unifi protect cameras & motion sensors] Cannot get cameras: Error: ERROR: Could not enumerate motion sensors: Error: Invalid response, missing: cameras on data```
beele commented 4 years ago

HELP WANTED. I need someone with an UDM & dev knowledge. ==> I need an example (postman request, can be screenshots) of how the request should look and what the response is to get the overview of the cameras

madrobby commented 4 years ago

Hi there, I've the exact same issue.


[6/30/2020, 12:08:01 PM] [Unifi protect cameras & motion sensors] WARNING: No previous session found, a new session must be created!
[6/30/2020, 12:08:01 PM] [Unifi protect cameras & motion sensors] Authenticated, returning session
[6/30/2020, 12:08:04 PM] [Unifi protect cameras & motion sensors] Cannot get cameras: Error: ERROR: Could not enumerate motion sensors: Error: No response received!```
beele commented 4 years ago

I don't have the required device so unless someone provides me with the info I need this will not get fixed

cmfrazier commented 4 years ago

I don't have the required device so unless someone provides me with the info I need this will not get fixed

I’m happy to help, but I need a little instruction. I’m familiar with SSHing into my UDMP, jut need some direction from there.

madrobby commented 4 years ago

I don't have the required device so unless someone provides me with the info I need this will not get fixed

Happy to help as well if you give detailed instructions of what info you need! I’ve been a programmer for 30 years. :) But haven’t done anything with the Unifi APIs.

wr commented 4 years ago

Also happy to help.

beele commented 4 years ago

Ok, so here's what you can attempt:

Screenshot 2020-07-03 at 07 40 15 Screenshot 2020-07-03 at 07 40 44
wr commented 4 years ago

Here is the full response for the bootstrap call, with sensitive info removed. This is a UDM Pro on the latest stable fw with a single G4 Pro camera on the latest stable fw:

{
    "authUserId": "{{auth user id}}",
    "accessKey": "{{access key}}",
    "cameras": [
        {
            "isDeleting": false,
            "mac": "{{mac address}}",
            "host": "{{camera ip address}}",
            "connectionHost": "{{udm ip address}}",
            "type": "{{camera model, this one is a G4 Pro}}",
            "name": "{{camera name}}",
            "upSince": 1593701384957,
            "lastSeen": 1593757214366,
            "connectedSince": 1593733993139,
            "state": "CONNECTED",
            "hardwareRevision": "9",
            "firmwareVersion": "4.23.7",
            "firmwareBuild": "ae5c6d8.200507.1038",
            "isUpdating": false,
            "isAdopting": false,
            "isManaged": true,
            "isProvisioned": true,
            "isRebooting": false,
            "isSshEnabled": false,
            "canManage": false,
            "isAttemptingToConnect": false,
            "isHidden": false,
            "lastMotion": 1593756239412,
            "micVolume": 100,
            "isMicEnabled": true,
            "isRecording": true,
            "isMotionDetected": false,
            "phyRate": 1000,
            "hdrMode": true,
            "isProbingForWifi": false,
            "apMac": null,
            "apRssi": null,
            "elementInfo": null,
            "chimeDuration": 300,
            "isDark": true,
            "lastRing": null,
            "wiredConnectionState": {
                "phyRate": 1000
            },
            "channels": [
                {
                    "id": 0,
                    "videoId": "video1",
                    "name": "High",
                    "enabled": true,
                    "isRtspEnabled": true,
                    "rtspAlias": "{{rstp alias}}",
                    "width": 3840,
                    "height": 2160,
                    "fps": 24,
                    "bitrate": 16000000,
                    "minBitrate": 2000000,
                    "maxBitrate": 16000000,
                    "minClientAdaptiveBitRate": 0,
                    "minMotionAdaptiveBitRate": 2000000,
                    "fpsValues": [
                        1,
                        2,
                        3,
                        4,
                        5,
                        6,
                        8,
                        9,
                        10,
                        12,
                        15,
                        16,
                        18,
                        20,
                        24
                    ],
                    "idrInterval": 5
                },
                {
                    "id": 1,
                    "videoId": "video3",
                    "name": "Medium",
                    "enabled": true,
                    "isRtspEnabled": false,
                    "rtspAlias": null,
                    "width": 1280,
                    "height": 720,
                    "fps": 15,
                    "bitrate": 1200000,
                    "minBitrate": 750000,
                    "maxBitrate": 4000000,
                    "minClientAdaptiveBitRate": 150000,
                    "minMotionAdaptiveBitRate": 750000,
                    "fpsValues": [
                        1,
                        2,
                        3,
                        4,
                        5,
                        6,
                        8,
                        9,
                        10,
                        12,
                        15,
                        16,
                        18,
                        20,
                        24
                    ],
                    "idrInterval": 5
                },
                {
                    "id": 2,
                    "videoId": "video2",
                    "name": "Low",
                    "enabled": true,
                    "isRtspEnabled": false,
                    "rtspAlias": null,
                    "width": 640,
                    "height": 360,
                    "fps": 15,
                    "bitrate": 200000,
                    "minBitrate": 32000,
                    "maxBitrate": 1022260,
                    "minClientAdaptiveBitRate": 0,
                    "minMotionAdaptiveBitRate": 0,
                    "fpsValues": [
                        1,
                        2,
                        3,
                        4,
                        5,
                        6,
                        8,
                        9,
                        10,
                        12,
                        15,
                        16,
                        18,
                        20,
                        24
                    ],
                    "idrInterval": 5
                }
            ],
            "ispSettings": {
                "aeMode": "auto",
                "irLedMode": "auto",
                "irLedLevel": 255,
                "wdr": 1,
                "icrSensitivity": 1,
                "brightness": 50,
                "contrast": 50,
                "hue": 52,
                "saturation": 50,
                "sharpness": 50,
                "denoise": 100,
                "isFlippedVertical": false,
                "isFlippedHorizontal": false,
                "isAutoRotateEnabled": false,
                "isLdcEnabled": true,
                "is3dnrEnabled": true,
                "isExternalIrEnabled": false,
                "isAggressiveAntiFlickerEnabled": false,
                "isPauseMotionEnabled": false,
                "dZoomCenterX": 50,
                "dZoomCenterY": 50,
                "dZoomScale": 0,
                "dZoomStreamId": 4,
                "focusMode": "touch",
                "focusPosition": 0,
                "touchFocusX": 750,
                "touchFocusY": 687,
                "zoomPosition": 0
            },
            "talkbackSettings": {
                "typeFmt": "aac",
                "typeIn": "serverudp",
                "bindAddr": "0.0.0.0",
                "bindPort": 7004,
                "filterAddr": null,
                "filterPort": null,
                "channels": 1,
                "samplingRate": 22050,
                "bitsPerSample": 16,
                "quality": 100
            },
            "osdSettings": {
                "isNameEnabled": true,
                "isDateEnabled": true,
                "isLogoEnabled": true,
                "isDebugEnabled": false
            },
            "ledSettings": {
                "isEnabled": true,
                "blinkRate": 0
            },
            "speakerSettings": {
                "isEnabled": true,
                "areSystemSoundsEnabled": false,
                "volume": 80
            },
            "recordingSettings": {
                "prePaddingSecs": 2,
                "postPaddingSecs": 2,
                "minMotionEventTrigger": 1000,
                "endMotionEventDelay": 3000,
                "suppressIlluminationSurge": false,
                "mode": "always",
                "geofencing": "off",
                "useNewMotionAlgorithm": true,
                "enablePirTimelapse": false
            },
            "recordingSchedule": null,
            "motionZones": [
                {
                    "name": "{{motion zone name}}",
                    "color": "#AB46BC",
                    "points": [
                        [
                            0,
                            0.435
                        ],
                        [
                            0.174,
                            0.443
                        ],
                        [
                            0.315,
                            0.297
                        ],
                        [
                            0.732,
                            0.415
                        ],
                        [
                            0.92,
                            0.457
                        ],
                        [
                            1,
                            0.516
                        ],
                        [
                            1,
                            1
                        ],
                        [
                            0,
                            1
                        ]
                    ],
                    "sensitivity": 75
                },
                {
                    "name": "{{motion zone name}}",
                    "color": "#586CED",
                    "points": [
                        [
                            0,
                            0.123
                        ],
                        [
                            0.311,
                            0.081
                        ],
                        [
                            0.768,
                            0.101
                        ],
                        [
                            1,
                            0.143
                        ],
                        [
                            1,
                            0.339
                        ],
                        [
                            0,
                            0.412
                        ]
                    ],
                    "sensitivity": 40
                }
            ],
            "privacyZones": [],
            "stats": {
                "rxBytes": 876210958,
                "txBytes": 46583272988,
                "wifi": {
                    "channel": null,
                    "frequency": null,
                    "linkSpeedMbps": null,
                    "signalQuality": 50,
                    "signalStrength": 0
                },
                "battery": {
                    "percentage": null,
                    "isCharging": false,
                    "sleepState": "awake"
                },
                "video": {
                    "recordingStart": 1593643093545,
                    "recordingEnd": 1593757226207,
                    "recordingStartLQ": 1593643093550,
                    "recordingEndLQ": 1593757226143,
                    "timelapseStart": 1593643093582,
                    "timelapseEnd": 1593757076223,
                    "timelapseStartLQ": 1593643093582,
                    "timelapseEndLQ": 1593756157253
                },
                "wifiQuality": 50,
                "wifiStrength": 0
            },
            "featureFlags": {
                "canAdjustIrLedLevel": true,
                "canMagicZoom": false,
                "canOpticalZoom": true,
                "canTouchFocus": true,
                "hasAccelerometer": false,
                "hasAec": false,
                "hasBattery": false,
                "hasBluetooth": false,
                "hasChime": false,
                "hasExternalIr": false,
                "hasIcrSensitivity": true,
                "hasLdc": false,
                "hasLedIr": true,
                "hasLedStatus": true,
                "hasLineIn": false,
                "hasMic": true,
                "hasPrivacyMask": true,
                "hasRtc": false,
                "hasSdCard": false,
                "hasSpeaker": false,
                "hasWifi": false,
                "hasHdr": true,
                "hasAutoICROnly": true,
                "hasMotionZones": true,
                "hasLcdScreen": false
            },
            "pirSettings": {
                "pirSensitivity": 100,
                "pirMotionClipLength": 15,
                "timelapseFrameInterval": 15,
                "timelapseTransferInterval": 600
            },
            "lcdMessage": {},
            "wifiConnectionState": {
                "channel": null,
                "frequency": null,
                "phyRate": null,
                "signalQuality": null,
                "signalStrength": null
            },
            "id": "{{id}}",
            "isConnected": true,
            "platform": "s5l",
            "hasSpeaker": false,
            "hasWifi": false,
            "audioBitrate": 64000,
            "modelKey": "camera"
        }
    ],
    "users": [
        {
            "permissions": [],
            "lastLoginIp": "{{a local ip address}}",
            "lastLoginTime": 1593652777242,
            "isOwner": false,
            "enableNotifications": false,
            "settings": {
                "flags": {}
            },
            "groups": [
                "{{a group id}}"
            ],
            "location": {
                "isAway": false,
                "homeAwaySince": 1593722912067,
                "latitude": {{lat}},
                "longitude": {{long}}
            },
            "alertRules": [],
            "id": "{id}",
            "hasAcceptedInvite": true,
            "allPermissions": [
                "nvr:read:*",
                "liveview:create",
                "user:read,write,delete:$",
                "camera:read,readmedia:*"
            ],
            "cloudAccount": {
                "firstName": "{{name}}",
                "lastName": "{{name}}",
                "email": "{{email}}",
                "profileImg": null,
                "user": "{{user id}}",
                "id": "{{user id}}",
                "cloudId": "{{cloud id}}",
                "name": "{{name}}",
                "modelKey": "cloudIdentity",
                "location": {
                    "isAway": false,
                    "homeAwaySince": 1593722912067,
                    "latitude": {{lat}},
                    "longitude": {{long}},
                    "modelKey": "userLocation"
                }
            },
            "name": "{{name}}",
            "firstName": "{{name}}",
            "lastName": "{{name}}",
            "email": "{{email}}",
            "localUsername": "{{email}}",
            "modelKey": "user"
        },
        {
            "permissions": [
                "liveview:*:{{??}}"
            ],
            "lastLoginIp": "{{a local ip}}",
            "lastLoginTime": 1593756995123,
            "isOwner": true,
            "enableNotifications": true,
            "settings": {
                "flags": {}
            },
            "groups": [
                "{{a group}}"
            ],
            "location": {
                "isAway": false,
                "homeAwaySince": 1593722881560,
                "latitude": {{lat}},
                "longitude": {{long}}
            },
            "alertRules": [
                {
                    "id": "{{id}}",
                    "name": "Default",
                    "when": "always",
                    "schedule": {
                        "items": []
                    },
                    "system": {
                        "connectDisconnect": [
                            "push",
                            "email"
                        ],
                        "update": []
                    },
                    "cameras": [
                        {
                            "connectDisconnect": [
                                "push",
                                "email"
                            ],
                            "motion": [
                                "push"
                            ],
                            "camera": null
                        },
                        {
                            "connectDisconnect": [],
                            "motion": [
                                "push"
                            ],
                            "camera": "{{id}}"
                        }
                    ],
                    "users": [],
                    "geofencing": "off"
                }
            ],
            "id": "{{id}}",
            "hasAcceptedInvite": true,
            "allPermissions": [
                "liveview:*:{{??}}",
                "nvr:read:*",
                "liveview:create",
                "user:read,write,delete:$",
                "nvr:write,delete:*",
                "group:create,read,write,delete:*",
                "camera:create,read,write,delete,readmedia,deletemedia:*",
                "viewer:create,read,write,delete:*",
                "light:create,read,write,delete:*",
                "bridge:create,read,write,delete:*",
                "sensor:create,read,write,delete:*",
                "user:create,read,write,delete:*",
                "recordingSchedule:create,read,write,delete:*"
            ],
            "cloudAccount": {
                "firstName": "{{name}}",
                "lastName": "{{name}}",
                "email": "{{email}}",
                "profileImg": null,
                "user": "{{id}}",
                "id": "{{id}}",
                "cloudId": "{{cloud id}}",
                "name": "{{name}}",
                "modelKey": "cloudIdentity",
                "location": {
                    "isAway": false,
                    "homeAwaySince": 1593722881560,
                    "latitude": {{lat}},
                    "longitude": {{long}},
                    "modelKey": "userLocation"
                }
            },
            "name": "{{name}}",
            "firstName": "{{name}}",
            "lastName": "{{name}}",
            "email": "{{email}}",
            "localUsername": "{{email}}",
            "modelKey": "user"
        }
    ],
    "groups": [
        {
            "name": "View Only",
            "permissions": [
                "nvr:read:*",
                "liveview:create",
                "user:read,write,delete:$",
                "camera:read,readmedia:*"
            ],
            "type": "preset",
            "isDefault": false,
            "id": "{{id}}",
            "modelKey": "group"
        },
        {
            "name": "Administrators",
            "permissions": [
                "nvr:read:*",
                "liveview:create",
                "user:read,write,delete:$",
                "nvr:write,delete:*",
                "group:create,read,write,delete:*",
                "camera:create,read,write,delete,readmedia,deletemedia:*",
                "viewer:create,read,write,delete:*",
                "light:create,read,write,delete:*",
                "bridge:create,read,write,delete:*",
                "sensor:create,read,write,delete:*",
                "user:create,read,write,delete:*",
                "recordingSchedule:create,read,write,delete:*"
            ],
            "type": "preset",
            "isDefault": true,
            "id": "{{id}}",
            "modelKey": "group"
        }
    ],
    "liveviews": [
        {
            "name": "Custom View 4",
            "isGlobal": true,
            "layout": 4,
            "slots": [
                {
                    "cameras": [
                        "{{id}}"
                    ],
                    "cycleMode": "time",
                    "cycleInterval": 10
                },
                {
                    "cameras": [],
                    "cycleMode": "time",
                    "cycleInterval": 10
                },
                {
                    "cameras": [],
                    "cycleMode": "time",
                    "cycleInterval": 10
                },
                {
                    "cameras": [],
                    "cycleMode": "time",
                    "cycleInterval": 10
                }
            ],
            "owner": "{{id}}",
            "id": "{{id}}",
            "modelKey": "liveview"
        }
    ],
    "nvr": {
        "mac": "{{mac}}",
        "host": "{{udm ip address}}",
        "name": "UniFi",
        "canAutoUpdate": true,
        "isStatsGatheringEnabled": true,
        "timezone": "America/Los_Angeles",
        "version": "1.14.10",
        "firmwareVersion": "1.7.2",
        "uiVersion": null,
        "hardwarePlatform": "alpinev2",
        "ports": {
            "ump": 7449,
            "http": 7080,
            "https": 7443,
            "rtsp": 7447,
            "rtmp": 1935,
            "elementsWss": 7442,
            "cameraHttps": 7444,
            "cameraTcp": 7877,
            "liveWs": 7445,
            "liveWss": 7446,
            "tcpStreams": 7448,
            "emsCLI": 7440,
            "emsLiveFLV": 7550,
            "cameraEvents": 7551,
            "ucore": 11081,
            "discoveryClient": 0
        },
        "setupCode": null,
        "uptime": 101657000,
        "lastSeen": 1593757224269,
        "isUpdating": false,
        "lastUpdateAt": null,
        "isConnectedToCloud": true,
        "cloudConnectionError": null,
        "isStation": false,
        "enableAutomaticBackups": true,
        "enableStatsReporting": false,
        "isSshEnabled": false,
        "errorCode": null,
        "releaseChannel": "release",
        "availableUpdate": null,
        "hosts": [
            "{{ip}}"
        ],
        "hardwareId": "{{hardware id}}",
        "hardwareRevision": "113-00723-08",
        "hostType": 59925,
        "isHardware": true,
        "timeFormat": "12h",
        "recordingRetentionDurationMs": null,
        "enableCrashReporting": true,
        "disableAudio": false,
        "wifiSettings": {
            "useThirdPartyWifi": false,
            "ssid": null,
            "password": null
        },
        "locationSettings": {
            "isAway": false,
            "isGeofencingEnabled": true,
            "latitude": {{lat}},
            "longitude": {{long}},
            "radius": 200
        },
        "featureFlags": {
            "beta": false,
            "dev": false
        },
        "storageInfo": {
            "totalSize": null,
            "totalSpaceUsed": null,
            "storageUtilization": [],
            "hardDrives": []
        },
        "doorbellSettings": {
            "defaultMessageText": "WELCOME",
            "defaultMessageResetTimeoutMs": 60000,
            "customMessages": [],
            "allMessages": [
                {
                    "type": "LEAVE_PACKAGE_AT_DOOR",
                    "text": "LEAVE PACKAGE AT DOOR"
                },
                {
                    "type": "DO_NOT_DISTURB",
                    "text": "DO NOT DISTURB"
                }
            ]
        },
        "id": "{{id}}",
        "isAdopted": true,
        "isAway": false,
        "isSetup": true,
        "network": "Ethernet",
        "type": "UDM-PRO",
        "upSince": 1593655566305,
        "modelKey": "nvr"
    },
    "lastUpdateId": "{{id}}",
    "cloudPortalUrl": "https://protect.ui.com/",
    "viewers": [],
    "lights": [],
    "bridges": [],
    "sensors": []
}
beele commented 4 years ago

Thx, that looks like what I expected. Could you also provide the request headers, possible there is something missing or not set correctly from the plugin which causes the bootstrap call to return some html (probably an error) instead of the json data

wr commented 4 years ago

yep, apologies, was just about to edit my comment but I'll put the headers here for continuity:

Summary
URL: https://{{domain}}/proxy/protect/api/bootstrap
Status: 200
Source: Network
Address: 127.0.0.1:49159
Initiator: 
main.2a54c508.js:1:13250

Request
:method: GET
:scheme: https
:authority: {{domain}}
:path: /proxy/protect/api/bootstrap
Accept: application/json
Cookie: TOKEN={{token}}
Accept-Encoding: gzip, deflate, br
Host: {{domain}}
User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_5) AppleWebKit/605.1.15 (KHTML, like Gecko) Version/13.1.1 Safari/605.1.15
Referer: https://{{domain}}/protect/cameras
Accept-Language: en-us
Connection: keep-alive
x-csrf-token: {{csrf token}}

Response
:status: 200
Content-Type: application/json; charset=utf-8
ETag: W/"{{etag}}"
X-DNS-Prefetch-Control: off
Set-Cookie: TOKEN={{token}}; path=/; secure; httponly
X-XSS-Protection: 1; mode=block
Date: Fri, 03 Jul 2020 06:37:11 GMT
Access-Control-Allow-Credentials: true
Content-Length: 10923
X-Content-Type-Options: nosniff
Accept-Ranges: bytes
X-Frame-Options: SAMEORIGIN
Vary: Origin
Server: nginx
x-download-options: noopen
Strict-Transport-Security: max-age=15552000; includeSubDomains, max-age=15768000; includeSubdomains; preload
beele commented 4 years ago

Can you try with this beta build (probably will not work yet, but I've added some logging, no debug flag required) Please be reminded that this is the new beta branch with the new camera setup so any old cameras in the home app will no longer work (incompatible with the new camera setup) The extra logging should shed some light where things possibly go wrong sudo npm i -g --unsafe-perm=true homebridge-unifi-protect-camera-motion@0.4.1-Beta.2

wr commented 4 years ago

here's the log output:

TOKEN={{token}}; path=/; secure; httponly
{
    "url": "https://{{udm ip}}/protect//proxy/protect/api/bootstrap",
    "method": "get",
    "headers": {
        "Content-Type": "application/json",
        "Accept": "application/json",
        "Cookie": "TOKEN={{token}}; path=/; secure; httponly",
        "x-csrf-token": "{{csrf token}}"
    },
    "responseType": "json",
    "timeout": 1000
}

I also tried "controller": "https://{{udm ip}}" in config, which doesn't work and doesn't spit out the logs. I also tried "controller": "https://{{udm ip}}/" which did return the logs— "url": "https://{{udm ip}}//proxy/protect/api/bootstrap",

beele commented 4 years ago

Hmmm, could you try with a tool like Postman to create a get request with the request headers as shown in the debug output? If it doesn't work we could try adding more headers like Host/Referer. I also see that my plugin adds the "; path=/; secure; httponly" to the token while I don't see that in the browser output (could be hidden maybe)

wr commented 4 years ago

I’ve never used that, so I’ll have to do some learning first. Bedtime for now though.

beele commented 4 years ago

Ok, thx for helping out! I've also pushed a new beta build with which now also logs the response code/text & body sudo npm i -g --unsafe-perm=true homebridge-unifi-protect-camera-motion@0.4.1-Beta.3

wr commented 4 years ago
[7/3/2020, 7:46:47 AM] [Unifi protect cameras & motion sensors] Authenticated, returning session
TOKEN={{token}}; path=/; secure; httponly
{
    "url": "https://{{udm ip}}/protect//proxy/protect/api/bootstrap",
    "method": "get",
    "headers": {
        "Content-Type": "application/json",
        "Accept": "application/json",
        "Cookie": "TOKEN={{token}}; path=/; secure; httponly",
        "x-csrf-token": "{{csrf token}}"
    },
    "responseType": "json",
    "timeout": 1000
}
200
OK
"\n<!doctype html>\n<html lang=\"en\">\n<head>\n<meta charset=\"utf-8\">\n<meta name=\"viewport\" content=\"width=device-width,initial-scale=1\"><link href=\"/2.css\" rel=\"stylesheet\"></head>\n<body>\n<div id=\"root\"></div>\n<script type=\"text/javascript\" src=\"/vendor.0016115f.chunk.js\"></script><script type=\"text/javascript\" src=\"/main.2a54c508.js\"></script></body>\n</html>\n"
madrobby commented 4 years ago

@beele If you like we could schedule a session where I can give you remote access to the Mac Mini that's running homebridge for me, so you could debug there. DM me if interested. :)

beele commented 4 years ago

@wr Ok seems like something is wrong with the request, just need to figure out what. @madrobby Ok we might be able to set something up in the coming week.

I've created a postman collection with the request: https://www.getpostman.com/collections/efa3c973b8ff004bbb46 You should be able to open this in postman and replace the {{}} params with your actual values (you can get them from the homebridge log)

Edit: To open the collection in postman: File > Import > Link > Paste the URL & Click Continue > Import (confirmation screen)

wr commented 4 years ago

@beele I've run that in Postman and played around a bit with the request, and I think I've found the issue.

The URL we're trying to hit is https://{{udm ip}}/protect/proxy/protect/api/bootstrap, which gets us this response:

<!doctype html>
<html lang="en">

<head>
    <meta charset="utf-8">
    <meta name="viewport" content="width=device-width,initial-scale=1">
    <link href="/2.css" rel="stylesheet">
</head>

<body>
    <div id="root"></div>
    <script type="text/javascript" src="/vendor.0016115f.chunk.js"></script>
    <script type="text/javascript" src="/main.2a54c508.js"></script>
</body>

</html>

but when I tried https://{{udm ip}}/proxy/protect/api/bootstrap, I get this response:

{
    "authUserId": "{{userid}}",
    "accessKey": "{{accesskey}}",
    "cameras": [
        {
            "isDeleting": false,
            "mac": "{{mac}}",
            "host": "{{cam ip}}",
            "connectionHost": "{{udm ip}}",
            "type": "UVC G4 Pro",
            "name": "{{name}}",
            "upSince": 1593701384957,
            "lastSeen": 1594048490187,
            "connectedSince": 1593733993139,
            "state": "CONNECTED",
            "hardwareRevision": "9",
            "firmwareVersion": "4.23.7",
            "firmwareBuild": "ae5c6d8.200507.1038",
            "isUpdating": false,
            "isAdopting": false,
            "isManaged": true,
            "isProvisioned": true,
            "isRebooting": false,
            "isSshEnabled": false,
            "canManage": false,
            "isAttemptingToConnect": false,
            "isHidden": false,
            "lastMotion": 1594047879177,
            "micVolume": 100,
            "isMicEnabled": true,
            "isRecording": true,
            "isMotionDetected": false,
            "phyRate": 1000,
            "hdrMode": true,
            "isProbingForWifi": false,
            "apMac": null,
            "apRssi": null,
            "elementInfo": null,
            "chimeDuration": 300,
            "isDark": false,
            "lastRing": null,
            "wiredConnectionState": {
                "phyRate": 1000
            },
            "channels": [
                {
                    "id": 0,
                    "videoId": "video1",
                    "name": "High",
                    "enabled": true,
                    "isRtspEnabled": true,
                    "rtspAlias": "{{rstp alias}}",
                    "width": 3840,
                    "height": 2160,
                    "fps": 24,
                    "bitrate": 16000000,
                    "minBitrate": 2000000,
                    "maxBitrate": 16000000,
                    "minClientAdaptiveBitRate": 0,
                    "minMotionAdaptiveBitRate": 2000000,
                    "fpsValues": [
                        1,
                        2,
                        3,
                        4,
                        5,
                        6,
                        8,
                        9,
                        10,
                        12,
                        15,
                        16,
                        18,
                        20,
                        24
                    ],
                    "idrInterval": 5
                },
                {
                    "id": 1,
                    "videoId": "video3",
                    "name": "Medium",
                    "enabled": true,
                    "isRtspEnabled": false,
                    "rtspAlias": null,
                    "width": 1280,
                    "height": 720,
                    "fps": 15,
                    "bitrate": 1200000,
                    "minBitrate": 750000,
                    "maxBitrate": 4000000,
                    "minClientAdaptiveBitRate": 150000,
                    "minMotionAdaptiveBitRate": 750000,
                    "fpsValues": [
                        1,
                        2,
                        3,
                        4,
                        5,
                        6,
                        8,
                        9,
                        10,
                        12,
                        15,
                        16,
                        18,
                        20,
                        24
                    ],
                    "idrInterval": 5
                },
                {
                    "id": 2,
                    "videoId": "video2",
                    "name": "Low",
                    "enabled": true,
                    "isRtspEnabled": false,
                    "rtspAlias": null,
                    "width": 640,
                    "height": 360,
                    "fps": 15,
                    "bitrate": 200000,
                    "minBitrate": 32000,
                    "maxBitrate": 1022260,
                    "minClientAdaptiveBitRate": 0,
                    "minMotionAdaptiveBitRate": 0,
                    "fpsValues": [
                        1,
                        2,
                        3,
                        4,
                        5,
                        6,
                        8,
                        9,
                        10,
                        12,
                        15,
                        16,
                        18,
                        20,
                        24
                    ],
                    "idrInterval": 5
                }
            ],
            "ispSettings": {
                "aeMode": "auto",
                "irLedMode": "auto",
                "irLedLevel": 255,
                "wdr": 1,
                "icrSensitivity": 1,
                "brightness": 50,
                "contrast": 50,
                "hue": 52,
                "saturation": 50,
                "sharpness": 50,
                "denoise": 100,
                "isFlippedVertical": false,
                "isFlippedHorizontal": false,
                "isAutoRotateEnabled": false,
                "isLdcEnabled": true,
                "is3dnrEnabled": true,
                "isExternalIrEnabled": false,
                "isAggressiveAntiFlickerEnabled": false,
                "isPauseMotionEnabled": false,
                "dZoomCenterX": 50,
                "dZoomCenterY": 50,
                "dZoomScale": 0,
                "dZoomStreamId": 4,
                "focusMode": "touch",
                "focusPosition": 0,
                "touchFocusX": 750,
                "touchFocusY": 687,
                "zoomPosition": 0
            },
            "talkbackSettings": {
                "typeFmt": "aac",
                "typeIn": "serverudp",
                "bindAddr": "0.0.0.0",
                "bindPort": 7004,
                "filterAddr": null,
                "filterPort": null,
                "channels": 1,
                "samplingRate": 22050,
                "bitsPerSample": 16,
                "quality": 100
            },
            "osdSettings": {
                "isNameEnabled": true,
                "isDateEnabled": true,
                "isLogoEnabled": true,
                "isDebugEnabled": false
            },
            "ledSettings": {
                "isEnabled": true,
                "blinkRate": 0
            },
            "speakerSettings": {
                "isEnabled": true,
                "areSystemSoundsEnabled": false,
                "volume": 80
            },
            "recordingSettings": {
                "prePaddingSecs": 2,
                "postPaddingSecs": 2,
                "minMotionEventTrigger": 1000,
                "endMotionEventDelay": 3000,
                "suppressIlluminationSurge": false,
                "mode": "always",
                "geofencing": "off",
                "useNewMotionAlgorithm": true,
                "enablePirTimelapse": false
            },
            "recordingSchedule": null,
            "motionZones": [
                {
                    "name": "{{name}}",
                    "color": "#AB46BC",
                    "points": [
                        [
                            0,
                            0.435
                        ],
                        [
                            0.174,
                            0.443
                        ],
                        [
                            0.315,
                            0.297
                        ],
                        [
                            0.732,
                            0.415
                        ],
                        [
                            0.92,
                            0.457
                        ],
                        [
                            1,
                            0.516
                        ],
                        [
                            1,
                            1
                        ],
                        [
                            0,
                            1
                        ]
                    ],
                    "sensitivity": 75
                },
                {
                    "name": "{{name}}",
                    "color": "#586CED",
                    "points": [
                        [
                            0,
                            0.123
                        ],
                        [
                            0.311,
                            0.081
                        ],
                        [
                            0.768,
                            0.101
                        ],
                        [
                            1,
                            0.143
                        ],
                        [
                            1,
                            0.339
                        ],
                        [
                            0,
                            0.412
                        ]
                    ],
                    "sensitivity": 40
                }
            ],
            "privacyZones": [],
            "stats": {
                "rxBytes": 4806690557,
                "txBytes": 268066165548,
                "wifi": {
                    "channel": null,
                    "frequency": null,
                    "linkSpeedMbps": null,
                    "signalQuality": 50,
                    "signalStrength": 0
                },
                "battery": {
                    "percentage": null,
                    "isCharging": false,
                    "sleepState": "awake"
                },
                "video": {
                    "recordingStart": 1593643093545,
                    "recordingEnd": 1594048498785,
                    "recordingStartLQ": 1593643093550,
                    "recordingEndLQ": 1594048498773,
                    "timelapseStart": 1593643093582,
                    "timelapseEnd": 1594048008770,
                    "timelapseStartLQ": 1593643093582,
                    "timelapseEndLQ": 1594046933703
                },
                "wifiQuality": 50,
                "wifiStrength": 0
            },
            "featureFlags": {
                "canAdjustIrLedLevel": true,
                "canMagicZoom": false,
                "canOpticalZoom": true,
                "canTouchFocus": true,
                "hasAccelerometer": false,
                "hasAec": false,
                "hasBattery": false,
                "hasBluetooth": false,
                "hasChime": false,
                "hasExternalIr": false,
                "hasIcrSensitivity": true,
                "hasLdc": false,
                "hasLedIr": true,
                "hasLedStatus": true,
                "hasLineIn": false,
                "hasMic": true,
                "hasPrivacyMask": true,
                "hasRtc": false,
                "hasSdCard": false,
                "hasSpeaker": false,
                "hasWifi": false,
                "hasHdr": true,
                "hasAutoICROnly": true,
                "hasMotionZones": true,
                "hasLcdScreen": false
            },
            "pirSettings": {
                "pirSensitivity": 100,
                "pirMotionClipLength": 15,
                "timelapseFrameInterval": 15,
                "timelapseTransferInterval": 600
            },
            "lcdMessage": {},
            "wifiConnectionState": {
                "channel": null,
                "frequency": null,
                "phyRate": null,
                "signalQuality": null,
                "signalStrength": null
            },
            "id": "{{id}}",
            "isConnected": true,
            "platform": "s5l",
            "hasSpeaker": false,
            "hasWifi": false,
            "audioBitrate": 64000,
            "modelKey": "camera"
        }
    ],
    "users": [
        {
            "permissions": [],
            "lastLoginIp": "10.0.1.204",
            "lastLoginTime": 1593998160632,
            "isOwner": false,
            "enableNotifications": false,
            "settings": {
                "flags": {}
            },
            "groups": [
                "{{group}}"
            ],
            "location": {
                "isAway": false,
                "homeAwaySince": 1593973558608,
                "latitude": {{lat}},
                "longitude": {{long}}
            },
            "alertRules": [],
            "id": "{{id}}",
            "hasAcceptedInvite": true,
            "allPermissions": [
                "nvr:read:*",
                "liveview:create",
                "user:read,write,delete:$",
                "camera:read,readmedia:*"
            ],
            "cloudAccount": {
                "firstName": "{{name}}",
                "lastName": "{{name}}",
                "email": "{{email}}",
                "profileImg": null,
                "user": "{{user}}",
                "id": "{{id}}",
                "cloudId": "{{cloudid}}",
                "name": "{{name}}",
                "modelKey": "cloudIdentity",
                "location": {
                    "isAway": false,
                    "homeAwaySince": 1593973441937,
                    "latitude": {{lat}},
                    "longitude": {{long}},
                    "modelKey": "userLocation"
                }
            },
            "name": "{{name}}",
            "firstName": "{{name}}",
            "lastName": "{{name}}",
            "email": "{{email}}",
            "localUsername": "{{uname}}",
            "modelKey": "user"
        }
    ],
    "groups": [
        {
            "name": "View Only",
            "permissions": [
                "nvr:read:*",
                "liveview:create",
                "user:read,write,delete:$",
                "camera:read,readmedia:*"
            ],
            "type": "preset",
            "isDefault": false,
            "id": "{{id}}",
            "modelKey": "group"
        },
        {
            "name": "Administrators",
            "permissions": [
                "nvr:read:*",
                "liveview:create",
                "user:read,write,delete:$",
                "nvr:write,delete:*",
                "group:create,read,write,delete:*",
                "camera:create,read,write,delete,readmedia,deletemedia:*",
                "viewer:create,read,write,delete:*",
                "light:create,read,write,delete:*",
                "bridge:create,read,write,delete:*",
                "sensor:create,read,write,delete:*",
                "user:create,read,write,delete:*",
                "recordingSchedule:create,read,write,delete:*"
            ],
            "type": "preset",
            "isDefault": true,
            "id": "{{id}}",
            "modelKey": "group"
        }
    ],
    "liveviews": [
        {
            "name": "Custom View 4",
            "isGlobal": true,
            "layout": 4,
            "slots": [
                {
                    "cameras": [
                        "{{id}}"
                    ],
                    "cycleMode": "time",
                    "cycleInterval": 10
                },
                {
                    "cameras": [],
                    "cycleMode": "time",
                    "cycleInterval": 10
                },
                {
                    "cameras": [],
                    "cycleMode": "time",
                    "cycleInterval": 10
                },
                {
                    "cameras": [],
                    "cycleMode": "time",
                    "cycleInterval": 10
                }
            ],
            "owner": "{{id}}",
            "id": "{{id}}",
            "modelKey": "liveview"
        }
    ],
    "nvr": {
        "mac": "{{mac}}",
        "host": "{{udm ip}}",
        "name": "UniFi",
        "canAutoUpdate": true,
        "isStatsGatheringEnabled": true,
        "timezone": "America/Los_Angeles",
        "version": "1.14.10",
        "firmwareVersion": "1.7.2",
        "uiVersion": null,
        "hardwarePlatform": "alpinev2",
        "ports": {
            "ump": 7449,
            "http": 7080,
            "https": 7443,
            "rtsp": 7447,
            "rtmp": 1935,
            "elementsWss": 7442,
            "cameraHttps": 7444,
            "cameraTcp": 7877,
            "liveWs": 7445,
            "liveWss": 7446,
            "tcpStreams": 7448,
            "emsCLI": 7440,
            "emsLiveFLV": 7550,
            "cameraEvents": 7551,
            "ucore": 11081,
            "discoveryClient": 0
        },
        "setupCode": null,
        "uptime": 392933000,
        "lastSeen": 1594048500303,
        "isUpdating": false,
        "lastUpdateAt": null,
        "isConnectedToCloud": true,
        "cloudConnectionError": null,
        "isStation": false,
        "enableAutomaticBackups": true,
        "enableStatsReporting": false,
        "isSshEnabled": false,
        "errorCode": null,
        "releaseChannel": "release",
        "availableUpdate": null,
        "hosts": [
        ],
        "hardwareId": "{{hwid}}",
        "hardwareRevision": "113-00723-08",
        "hostType": 59925,
        "isHardware": true,
        "timeFormat": "12h",
        "recordingRetentionDurationMs": null,
        "enableCrashReporting": true,
        "disableAudio": false,
        "wifiSettings": {
            "useThirdPartyWifi": false,
            "ssid": null,
            "password": null
        },
        "locationSettings": {
            "isAway": false,
            "isGeofencingEnabled": true,
            "latitude": {{lat}},
            "longitude": {{long}},
            "radius": 200
        },
        "featureFlags": {
            "beta": false,
            "dev": false
        },
        "storageInfo": {
            "totalSize": null,
            "totalSpaceUsed": null,
            "storageUtilization": [],
            "hardDrives": []
        },
        "doorbellSettings": {
            "defaultMessageText": "WELCOME",
            "defaultMessageResetTimeoutMs": 60000,
            "customMessages": [],
            "allMessages": [
                {
                    "type": "LEAVE_PACKAGE_AT_DOOR",
                    "text": "LEAVE PACKAGE AT DOOR"
                },
                {
                    "type": "DO_NOT_DISTURB",
                    "text": "DO NOT DISTURB"
                }
            ]
        },
        "id": "{{id}}",
        "isAdopted": true,
        "isAway": false,
        "isSetup": true,
        "network": "Ethernet",
        "type": "UDM-PRO",
        "upSince": 1593655567079,
        "modelKey": "nvr"
    },
    "lastUpdateId": "{{id}}",
    "cloudPortalUrl": "https://protect.ui.com/",
    "viewers": [],
    "lights": [],
    "bridges": [],
    "sensors": []
}
beele commented 4 years ago

@wr thx for the info!

@janthony6 @3uperduck @cmfrazier @madrobby To what is the controller url set in your config? It should be set to just the bare ip/domain of your device running Unifi OS (not with a /protect at the end!) Stupid of me to only notice this now but I was reading in the old closed ticket about unifi OS.

cmfrazier commented 4 years ago

@beele removing /protect from the controller URL fixed it.

wr commented 4 years ago

i have tried a few different urls, all without success:

https://{{udm ip}} - returns no debug data on the latest beta https://{{udm ip}}/ - returns debug data showing an extra slash in the request url ("url": "https://{{udm ip}}//proxy/protect/api/bootstrap", but still no cameras in Homekit

I've also tried with /protect in the url with no luck, but obviously it shouldn't work based on what i know now

beele commented 4 years ago

@wr I'm looking in the code and find the // issue very weird. That the double // works is ok, the url parser probably ignores the double slash, that it doesn't work without the trailing slash is what I'm trying to figure out

beele commented 4 years ago

@cmfrazier Are you running the latest beta I posted or an earlier version of the plugin?

wr commented 4 years ago

yeah, especially weird that it works now for @cmfrazier—i'm envious! :D

cmfrazier commented 4 years ago

@cmfrazier Are you running the latest beta I posted or an earlier version of the plugin?

No beta, just the latest public version.

beele commented 4 years ago

@wr I've published a new beta with some small code rollbacks that are different between the latest public and the beta.

sudo npm i -g --unsafe-perm=true homebridge-unifi-protect-camera-motion@0.4.1-Beta.4

wr commented 4 years ago
[7/6/2020, 11:23:26 AM] [Unifi protect cameras & motion sensors] Endpoint Style: UnifiOS
[7/6/2020, 11:23:26 AM] [Unifi protect cameras & motion sensors] WARNING: No previous session found, a new session must be created!
{
    "url": "https://{{udm ip}}/api/auth/login",
    "method": "post",
    "headers": {
        "Content-Type": "application/json",
        "X-CSRF-Token": "{{csrf token}}"
    },
    "data": {
        "username": "{{uname}}",
        "password": "{{pw}}"
    },
    "responseType": "json",
    "withCredentials": true,
    "timeout": 1000
}
[7/6/2020, 11:23:29 AM] [Unifi protect cameras & motion sensors] Cannot get cameras: Error: ERROR: Could not enumerate motion sensors: Error: Authentication failed: {}
madrobby commented 4 years ago

Seeing the same with latest beta as @wr above

beele commented 4 years ago
[7/6/2020, 11:23:26 AM] [Unifi protect cameras & motion sensors] Endpoint Style: UnifiOS
[7/6/2020, 11:23:26 AM] [Unifi protect cameras & motion sensors] WARNING: No previous session found, a new session must be created!
{
    "url": "https://{{udm ip}}/api/auth/login",
    "method": "post",
    "headers": {
        "Content-Type": "application/json",
        "X-CSRF-Token": "{{csrf token}}"
    },
    "data": {
        "username": "{{uname}}",
        "password": "{{pw}}"
    },
    "responseType": "json",
    "withCredentials": true,
    "timeout": 1000
}
[7/6/2020, 11:23:29 AM] [Unifi protect cameras & motion sensors] Cannot get cameras: Error: ERROR: Could not enumerate motion sensors: Error: Authentication failed: {}

Is that with the / at the end? Because I don't see a double slash in the url. If not could you try adding the / at the end?

wr commented 4 years ago

that was without the trailing slash. here is it with:

[7/6/2020, 11:44:27 AM] [Unifi protect cameras & motion sensors] Endpoint Style: UnifiOS
[7/6/2020, 11:44:27 AM] [Unifi protect cameras & motion sensors] WARNING: No previous session found, a new session must be created!
{
    "url": "https://{{udm ip}}//api/auth/login",
    "method": "post",
    "headers": {
        "Content-Type": "application/json",
        "X-CSRF-Token": "{{csrf token}}"
    },
    "data": {
        "username": "{{uname}}",
        "password": "{{pw}}"
    },
    "responseType": "json",
    "withCredentials": true,
    "timeout": 1000
}
200
OK
"\n<!doctype html>\n<html lang=\"en\">\n<head>\n<meta charset=\"utf-8\">\n<meta name=\"viewport\" content=\"width=device-width,initial-scale=1\"><link href=\"/2.css\" rel=\"stylesheet\"></head>\n<body>\n<div id=\"root\"></div>\n<script type=\"text/javascript\" src=\"/vendor.0016115f.chunk.js\"></script><script type=\"text/javascript\" src=\"/main.2a54c508.js\"></script></body>\n</html>\n"
[7/6/2020, 11:44:28 AM] [Unifi protect cameras & motion sensors] Authenticated, returning session
{
    "url": "https://{{udm ip}}//proxy/protect/api/bootstrap",
    "method": "get",
    "headers": {
        "Content-Type": "application/json",
        "X-CSRF-Token": "{{csrf token}}",
        "Cookie": "TOKEN={{token}}; path=/; secure; httponly"
    },
    "responseType": "json",
    "timeout": 1000
}
beele commented 4 years ago

@wr was there ay further output from the second call for the cameras?

wr commented 4 years ago

[7/7/2020, 7:59:33 AM] [Unifi protect cameras & motion sensors] Cannot get cameras: Error: ERROR: Could not enumerate motion sensors: TypeError: Cannot read property 'status' of undefined

beele commented 4 years ago

Hmm seems like the request for the camera info is failing altogether now. If you try to mimic the same request in postman does it work then? (for the camera data)

wr commented 4 years ago

It seemed to... when I hit https://{{udm ip}}/proxy/protect/api/bootstrap in postman (see my post from a few days ago) I do successfully get the list of cameras.

beele commented 4 years ago

Hmm, seems like this will need some actual debugging. I'll get in touch with @madrobby to set something up so we can hopefully get this working

madrobby commented 4 years ago

I've upgraded my UDM-PRO to the latest beta firmware and now cameras are enumerated correctly and I can see snapshots in the Home app. However, I can't live-stream video. What should I take a look at?

hfagelnour commented 4 years ago

I've upgraded my UDM-PRO to the latest beta firmware and now cameras are enumerated correctly and I can see snapshots in the Home app. However, I can't live-stream video. What should I take a look at?

What versions of UnifiOS and protect are u running?

madrobby commented 4 years ago

UDM-PRO 1.8.0-rc.7 Protect Controller 1.14.11-beta6, Web UI 1.23.0-beta.9

On Jul 19, 2020, at 11:49 AM, hfagelnour notifications@github.com wrote:

I've upgraded my UDM-PRO to the latest beta firmware and now cameras are enumerated correctly and I can see snapshots in the Home app. However, I can't live-stream video. What should I take a look at?

What versions of UnifiOS and protect are u running?

— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub https://github.com/beele/homebridge-unifi-protect-camera-motion/issues/49#issuecomment-660690074, or unsubscribe https://github.com/notifications/unsubscribe-auth/AAAA2PQAPQX7J6SZ3OIZXE3R4M52PANCNFSM4NPGSMFQ.