From 101cbef7f910cd667247b83f03e3a9534e4c5dc7 Mon Sep 17 00:00:00 2001 From: Brandon McFarlin Date: Tue, 28 Jul 2020 08:38:33 -0400 Subject: [PATCH] add path to login --- README.md | 10 +++++++--- package-lock.json | 17 +---------------- package.json | 2 +- src/login.ts | 14 +++++++++++++- src/nest-cam.ts | 3 ++- 5 files changed, 24 insertions(+), 22 deletions(-) diff --git a/README.md b/README.md index 2692354..ddac9f5 100755 --- a/README.md +++ b/README.md @@ -53,12 +53,16 @@ Google Accounts are configured using the `"googleAuth"` object in `config.json`, } ``` -**Note:** If the steps below do not work, refer to the [manual authentication method](https://github.com/Brandawg93/homebridge-nest-cam/wiki/Manual-Authentication). You may need to reauthenticate periodically due to your Google account settings. - -1. If the plugin is installed globally, run `homebridge-nest-cam login`, otherwise, *ensure that you are in the plugin's root directory* and run `node dist/login.js`. If your account has 2 factor authentication, use the `-h` flag. +1. If the plugin is installed globally, run `homebridge-nest-cam login`, otherwise, *ensure that you are in the plugin's root directory* and run `node dist/login.js`. 2. Login to your Nest account. 3. Copy the output to your `config.json`. +**Notes:** +- If the steps above do not work, refer to the [manual authentication method](https://github.com/Brandawg93/homebridge-nest-cam/wiki/Manual-Authentication). +- You may need to reauthenticate periodically due to your Google account settings. +- If your account has 2 factor authentication, use the `-h` flag. +- If you are unable to open the chromium browser, install it manually and specify its path via the `-p` flag. + #### options Extra options can be enabled/disabled depending on which switches and sensors you would like to see in the Home app. Here is the current list of available options: diff --git a/package-lock.json b/package-lock.json index 6dad1bd..6268186 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,6 +1,6 @@ { "name": "homebridge-nest-cam", - "version": "4.0.0-test.3", + "version": "4.0.0-test.4", "lockfileVersion": 1, "requires": true, "dependencies": { @@ -1428,12 +1428,6 @@ } } }, - "@typescript-eslint/types": { - "version": "3.7.0", - "resolved": "https://registry.npmjs.org/@typescript-eslint/types/-/types-3.7.0.tgz", - "integrity": "sha512-reCaK+hyKkKF+itoylAnLzFeNYAEktB0XVfSQvf0gcVgpz1l49Lt6Vo9x4MVCCxiDydA0iLAjTF/ODH0pbfnpg==", - "dev": true - }, "@typescript-eslint/typescript-estree": { "version": "2.34.0", "resolved": "https://registry.npmjs.org/@typescript-eslint/typescript-estree/-/typescript-estree-2.34.0.tgz", @@ -1472,15 +1466,6 @@ } } }, - "@typescript-eslint/visitor-keys": { - "version": "3.7.0", - "resolved": "https://registry.npmjs.org/@typescript-eslint/visitor-keys/-/visitor-keys-3.7.0.tgz", - "integrity": "sha512-k5PiZdB4vklUpUX4NBncn5RBKty8G3ihTY+hqJsCdMuD0v4jofI5xuqwnVcWxfv6iTm2P/dfEa2wMUnsUY8ODw==", - "dev": true, - "requires": { - "eslint-visitor-keys": "^1.1.0" - } - }, "abab": { "version": "2.0.3", "resolved": "https://registry.npmjs.org/abab/-/abab-2.0.3.tgz", diff --git a/package.json b/package.json index 40cff07..ef634c3 100644 --- a/package.json +++ b/package.json @@ -1,7 +1,7 @@ { "displayName": "Homebridge Nest Cam", "name": "homebridge-nest-cam", - "version": "4.0.0-test.3", + "version": "4.0.0-test.4", "description": "Nest cam plugin for homebridge: https://homebridge.io/", "main": "dist/index.js", "license": "GPL-3.0", diff --git a/src/login.ts b/src/login.ts index bda3872..7989760 100644 --- a/src/login.ts +++ b/src/login.ts @@ -12,6 +12,13 @@ export async function login(email?: string, password?: string): Promise { puppeteer.use(pluginStealth()); const headless = !process.argv.includes('-h'); + const path = (): string => { + if (process.argv.includes('-p')) { + const index = process.argv.indexOf('-p'); + return process.argv[index + 1]; + } + return ''; + }; const prompt = (query: string, hidden = false): Promise => new Promise((resolve, reject) => { const rl = readline.createInterface({ @@ -47,7 +54,12 @@ export async function login(email?: string, password?: string): Promise { }); try { - const browser = await puppeteer.launch({ headless: headless }); + const options: any = { headless: headless }; + const executablePath = path(); + if (executablePath) { + options.executablePath = path(); + } + const browser = await puppeteer.launch(options); console.log('Opening chromium browser...'); const page = await browser.newPage(); const pages = await browser.pages(); diff --git a/src/nest-cam.ts b/src/nest-cam.ts index 6e677e8..0850e06 100644 --- a/src/nest-cam.ts +++ b/src/nest-cam.ts @@ -221,7 +221,7 @@ export class NestCam extends EventEmitter { } } - async getFaces(): Promise { + async getFaces(): Promise> { try { if (!this.accessory.context.removed) { const response = await this.endpoints.sendRequest( @@ -237,5 +237,6 @@ export class NestCam extends EventEmitter { } catch (error) { handleError(this.log, error, 'Error getting faces'); } + return []; } }