Skip to content

Commit

Permalink
Merge commit 'fece99afa82f45a0b23a8df636f401c2ca0883eb'
Browse files Browse the repository at this point in the history
* commit 'fece99afa82f45a0b23a8df636f401c2ca0883eb':
  Add support for API Key and Key ID #105
  • Loading branch information
jfarmer08 committed Jul 5, 2023
2 parents b897fe0 + fece99a commit cae2ac3
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 2 deletions.
10 changes: 10 additions & 0 deletions config.schema.json
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,16 @@
"default": "",
"required": true
},
"keyId": {
"title": "Key ID",
"description": "API Key/ID available from the official Wyze Portal",
"type": "string"
},
"apiKey": {
"title": "API Key",
"description": "API Key/ID available from the official Wyze Portal",
"type": "string"
},
"refreshInterval": {
"title": "Refresh Interval",
"description": "Specify the number of milliseconds to wait between updates, default is 60000 ms (60 seconds)",
Expand Down
2 changes: 2 additions & 0 deletions src/WyzeSmartHome.js
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,8 @@ module.exports = class WyzeSmartHome {
return new WyzeAPI({
username: this.config.username,
password: this.config.password,
keyId: this.config.keyId,
apiKey: this.config.apiKey,
phoneId: this.config.phoneId,
mfaCode: this.config.mfaCode
}, this.log)
Expand Down
9 changes: 7 additions & 2 deletions src/wyz-api/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -119,8 +119,8 @@ module.exports = class WyzeAPI {
return result
}

_performLoginRequest (data = {}) {
const url = 'user/login'
_performLoginRequest(data = {}) {
let url = 'user/login'

data = {
email: this.username,
Expand All @@ -133,6 +133,11 @@ module.exports = class WyzeAPI {
headers: { 'x-api-key': this.authApiKey, 'User-Agent': this.userAgent }
}

if (this.apiKey && this.keyId) {
url = 'api/user/login'
config.headers = { 'apikey': this.apiKey, 'keyid': this.keyId, 'User-Agent': 'homebridge-wyze-smart-home' };
}

return this._performRequest(url, data, config)
}

Expand Down

0 comments on commit cae2ac3

Please sign in to comment.