Skip to content
This repository has been archived by the owner on Aug 14, 2023. It is now read-only.

Commit

Permalink
implement #20
Browse files Browse the repository at this point in the history
  • Loading branch information
Brandawg93 committed Mar 3, 2020
1 parent 325ee11 commit a49b5fb
Show file tree
Hide file tree
Showing 3 changed files with 53 additions and 16 deletions.
10 changes: 10 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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...",
Expand All @@ -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).

Expand Down
18 changes: 18 additions & 0 deletions config.schema.json
Original file line number Diff line number Diff line change
Expand Up @@ -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
}
}
}
}
}
41 changes: 25 additions & 16 deletions index.js
Original file line number Diff line number Diff line change
Expand Up @@ -90,29 +90,38 @@ 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() {
camera.checkMotion(accessory);
}, 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);
});
Expand Down

0 comments on commit a49b5fb

Please sign in to comment.