-
Notifications
You must be signed in to change notification settings - Fork 5
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #7 from hgoscenski/debounce_login
Draft: Initial attempt at naive debounce for login api
- Loading branch information
Showing
4 changed files
with
84 additions
and
22 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
USERNAME=username | ||
PASSWORD=password | ||
KEY_ID=keyId | ||
API_KEY=apiKey | ||
PERSIST_PATH=./scratch | ||
LOG_LEVEL=debug | ||
API_LOG_ENABLED=true | ||
LOCAL_DEV=true |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,5 @@ | ||
|
||
node_modules/* | ||
example/node_modules/* | ||
example/scratch/* | ||
example/scratch/* | ||
.env |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,22 +1,40 @@ | ||
//const WyzeAPI = require('../src/index') // Local Debug | ||
const WyzeAPI = require("wyze-api") | ||
const Logger = require("@ptkdev/logger"); | ||
let WyzeAPI = null; | ||
if (process.env.LOCAL_DEV) { | ||
WyzeAPI = require('../src/index'); // Local Debug | ||
} else { | ||
WyzeAPI = require("wyze-api"); | ||
} | ||
|
||
const Logger = require("@ptkdev/logger"); | ||
const logger = new Logger(); | ||
|
||
const options = { | ||
username: "username", | ||
password: "password", | ||
keyId: "keyId", | ||
apiKey: "apiKey", | ||
persistPath: "./scratch", | ||
logLevel: "debug", | ||
apiLogEnabled: true | ||
username: process.env.USERNAME, | ||
password: process.env.PASSWORD, | ||
keyId: process.env.KEY_ID, | ||
apiKey: process.env.API_KEY, | ||
persistPath: process.env.PERSIST_PATH, | ||
logLevel: process.env.LOG_LEVEL, | ||
apiLogEnabled: process.env.API_LOG_ENABLED, | ||
} | ||
const wyze = new WyzeAPI(options,logger) | ||
const wyze = new WyzeAPI(options, logger); | ||
|
||
; (async () => { | ||
async function loginCheck(iterations = 2) { | ||
var count = 0; | ||
while (count < iterations) { | ||
await wyze.maybeLogin(); | ||
wyze.access_token = ""; | ||
count += 1; | ||
} | ||
} | ||
|
||
async function deviceListCheck() { | ||
const devices = await wyze.getDeviceList() | ||
logger.debug(JSON.stringify(devices)) | ||
})() | ||
logger.debug(JSON.stringify(devices)) | ||
} | ||
|
||
|
||
(async () => { | ||
// await deviceListCheck(); | ||
// await loginCheck(4); | ||
})() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters