diff --git a/README.md b/README.md index 31df571..997a55e 100755 --- a/README.md +++ b/README.md @@ -47,12 +47,17 @@ The Homebridge Docker container requires an extra environment variable to instal ### Setting up the Config.json Setting up a Google Account with homebridge-nest is a pain, but only needs to be done once, as long as you do not log out of your Google Account. +#### googleAuth Google Accounts are configured using the `"googleAuth"` object in `config.json`, which contains three fields, `"issueToken"`, `"cookies"` and `"apiKey"`, and looks like this: ``` { "platform": "Nest-cam", "ffmpegCodec": "libx264", + "options": { + "motionDetection": true, + "streamingSwitch": true + }, "googleAuth": { "issueToken": "https://accounts.google.com/o/oauth2/iframerpc?action=issueToken...", "cookies": "SMSV=ADHTe...", @@ -77,6 +82,11 @@ The values of `"issueToken"`, `"cookies"` and `"apiKey"` are specific to your Go 13. In the Headers tab, under Request Headers, copy the entire `x-goog-api-key` (do not include the `x-goog-api-key:` name). This is your `"apiKey"` in `config.json`. 14. Do not log out of `home.nest.com`, as this will invalidate your credentials. Just close the browser tab. +#### options +Extra options can be enabled/disabled depending on which switches and sensors you would like to see in the Home app. Here are the current list of available options: +- motionDetection: enable/disable the motion sensor +- streamingSwitch: enable/disable the ability to turn the camera on or off + ## Join the Discord Unfortunately, there is no way for me to test every subscription, camera type, and feature. If you would like to help me test new features and enhancements, join the [Discord Server](https://discord.gg/E6dnwsE) and let me know what you would like to test. Also, if you have general questions or support, feel free to [ask in the server](https://discord.gg/e7bPJnJ). diff --git a/config.schema.json b/config.schema.json index 8d84c38..96dd4b7 100644 --- a/config.schema.json +++ b/config.schema.json @@ -34,6 +34,24 @@ "default": "libx264", "required": true, "description": "Ensure that the installed ffmpeg binary has support for the specified codec." + }, + "options": { + "title": "Options", + "type": "object", + "properties": { + "motionDetection": { + "title": "Motion Detection", + "type": "boolean", + "default": true, + "required": true + }, + "streamingSwitch": { + "title": "Streaming Switch", + "type": "boolean", + "default": true, + "required": true + } + } } } } diff --git a/index.js b/index.js index 40a5525..9245b88 100755 --- a/index.js +++ b/index.js @@ -90,7 +90,11 @@ class NestCamPlatform { accessoryInformation.setCharacteristic(Characteristic.FirmwareRevision, camera.softwareVersion); self.log.info('Create camera - ' + name); //Add motion detection - if (camera.detectors.includes('motion')) { + let motionDetection = self.config.options['motionDetection']; + if (typeof motionDetection === 'undefined') { + motionDetection = true; + } + if (camera.detectors.includes('motion') && motionDetection) { var motion = new Service.MotionSensor(name); accessory.addService(motion); setInterval(async function() { @@ -98,21 +102,26 @@ class NestCamPlatform { }, UPDATE_INTERVAL); } //Add enabled/disabled service - accessory.addService(Service.Switch, 'Streaming') - .setCharacteristic(Characteristic.On, camera.enabled) - .getCharacteristic(Characteristic.On) - .on('set', async function(value, callback) { - await camera.toggleActive(value); - self.log.info('Setting %s to %s', accessory.displayName, (value ? 'on' : 'off')); - callback(); - }); - //Check enabled/disabled state - setInterval(async function() { - await camera.updateInfo(); - let service = accessory.getService(Service.Switch); - service.updateCharacteristic(Characteristic.On, camera.enabled); - }, UPDATE_INTERVAL); - + let streamingSwitch = self.config.options['streamingSwitch']; + if (typeof streamingSwitch === 'undefined') { + streamingSwitch = true; + } + if (streamingSwitch) { + accessory.addService(Service.Switch, 'Streaming') + .setCharacteristic(Characteristic.On, camera.enabled) + .getCharacteristic(Characteristic.On) + .on('set', async function(value, callback) { + await camera.toggleActive(value); + self.log.info('Setting %s to %s', accessory.displayName, (value ? 'on' : 'off')); + callback(); + }); + //Check enabled/disabled state + setInterval(async function() { + await camera.updateInfo(); + let service = accessory.getService(Service.Switch); + service.updateCharacteristic(Characteristic.On, camera.enabled); + }, UPDATE_INTERVAL); + } accessory.configureCameraSource(camera); configuredAccessories.push(accessory); });