homebridge-nest-cam2
Advanced tools
Comparing version 2.0.0 to 2.1.0-beta.0
@@ -40,3 +40,3 @@ "use strict"; | ||
}; | ||
const setMotionInterval = async function (camera, accessory) { | ||
const setAlertInterval = async function (camera, accessory) { | ||
setInterval(async function () { | ||
@@ -59,2 +59,3 @@ camera.checkMotion(accessory); | ||
this.motionDetection = true; | ||
this.doorbellAlerts = true; | ||
this.streamingSwitch = false; | ||
@@ -82,2 +83,6 @@ this.log = log; | ||
} | ||
const doorbellAlerts = config.options['doorbellAlerts']; | ||
if (typeof doorbellAlerts !== 'undefined') { | ||
this.doorbellAlerts = doorbellAlerts; | ||
} | ||
const streamingSwitch = config.options['streamingSwitch']; | ||
@@ -141,2 +146,3 @@ if (typeof streamingSwitch !== 'undefined') { | ||
const motion = accessory.getService('Motion'); | ||
const doorbell = accessory.getService('Doorbell'); | ||
const enabledSwitch = accessory.getService('Streaming'); | ||
@@ -151,3 +157,3 @@ // Motion configuration | ||
// Check existing motion service | ||
setMotionInterval(camera, accessory); | ||
setAlertInterval(camera, accessory); | ||
} | ||
@@ -160,5 +166,26 @@ } | ||
accessory.addService(motion); | ||
setMotionInterval(camera, accessory); | ||
setAlertInterval(camera, accessory); | ||
} | ||
} | ||
// Doorbell configuration | ||
if (doorbell) { | ||
if (!this.doorbellAlerts) { | ||
// Remove doorbell service | ||
accessory.removeService(doorbell); | ||
} | ||
else if (!this.motionDetection) { | ||
// Check existing doorbell service | ||
setAlertInterval(camera, accessory); | ||
} | ||
} | ||
else { | ||
// Add doorbell service | ||
if (camera.detectors.includes('doorbellPress') && this.doorbellAlerts) { | ||
const doorbell = new hap.Service.Doorbell('Doorbell'); | ||
accessory.addService(doorbell); | ||
if (!this.motionDetection) { | ||
setAlertInterval(camera, accessory); | ||
} | ||
} | ||
} | ||
// Streaming configuration | ||
@@ -165,0 +192,0 @@ if (enabledSwitch) { |
@@ -14,2 +14,3 @@ "use strict"; | ||
this.motionDetected = false; | ||
this.doorbellRang = false; | ||
this.serialNumber = ''; | ||
@@ -87,9 +88,21 @@ this.softwareVersion = ''; | ||
if (response.length > 0) { | ||
const trigger = response[0]; | ||
if (trigger.is_important && !this.motionDetected) { | ||
this.setMotion(accessory, true); | ||
for (let i = 0; i < response.length; i++) { | ||
const trigger = response[i]; | ||
if (trigger.is_important && trigger.types.includes('doorbell') && !this.doorbellRang) { | ||
this.setDoorbell(accessory, true); | ||
break; | ||
} | ||
if (trigger.is_important && trigger.types.includes('motion') && !this.motionDetected) { | ||
this.setMotion(accessory, true); | ||
break; | ||
} | ||
} | ||
} | ||
else if (this.motionDetected) { | ||
this.setMotion(accessory, false); | ||
else { | ||
if (this.motionDetected) { | ||
this.setMotion(accessory, false); | ||
} | ||
if (this.doorbellRang) { | ||
this.setDoorbell(accessory, false); | ||
} | ||
} | ||
@@ -114,4 +127,12 @@ } | ||
} | ||
setDoorbell(accessory, state) { | ||
this.log.debug(`Setting ${accessory.displayName} Doorbell to ${state}`); | ||
const service = accessory.getService(this.hap.Service.Doorbell); | ||
if (service) { | ||
service.updateCharacteristic(this.hap.Characteristic.ProgrammableSwitchEvent, state); | ||
this.doorbellRang = state; | ||
} | ||
} | ||
} | ||
exports.NestCam = NestCam; | ||
//# sourceMappingURL=nestcam.js.map |
{ | ||
"name": "homebridge-nest-cam2", | ||
"version": "2.0.0", | ||
"version": "2.1.0-beta.0", | ||
"description": "Nest cam plugin for homebridge: https://homebridge.io/", | ||
@@ -5,0 +5,0 @@ "main": "dist/index.js", |
# homebridge-nest-cam2 | ||
<img align="right" width="100" src="https://i.imgur.com/EJ0z6P3.png"> | ||
View your Nest cams in HomeKit using [Homebridge](https://github.com/nfarina/homebridge) with this plugin. | ||
@@ -20,9 +22,12 @@ | ||
- This plugin *does not* use the old access token authentication method as it is no longer supported. | ||
- As of v2.0.0, this plugin is *no longer* supported on HOOBS. To install an older version that is still supported by HOOBS, run `npm -g i homebridge-nest-cam2@hoobs`. | ||
## Installation | ||
1. Install ffmpeg | ||
2. Install this plugin using: npm install -g homebridge-nest-cam2 | ||
3. Add google authentication to ``config.json`` | ||
4. Run [Homebridge](https://github.com/nfarina/homebridge) | ||
1. Install this plugin using: `npm install -g homebridge-nest-cam2` | ||
2. Add google authentication to `config.json` | ||
3. Run [Homebridge](https://github.com/nfarina/homebridge) | ||
### FFMPEG | ||
In order to use the below ffmpeg options, you must specify your custom ffmpeg path in the `pathToFfmpeg` config option. | ||
#### Raspberry Pi | ||
@@ -34,5 +39,2 @@ You may want to use OMX for transcoding as the CPU on the board can be slow. If so, make sure the ffmpeg installed on your Pi has `h264_omx` support and set the `ffmpegCodec` option below to `h264_omx`. You can always compile ffmpeg from source using [these instructions](https://github.com/legotheboss/YouTube-files/wiki/(RPi)-Compile-FFmpeg-with-the-OpenMAX-H.264-GPU-acceleration). | ||
#### Docker | ||
The Homebridge Docker container requires an extra environment variable to install ffmpeg: `PACKAGES=ffmpeg`. The Docker container also requires the `libx264` codec as it uses the ffmpeg inside the container and not the ffmpeg on the device running the container. | ||
### Setting up the Config.json | ||
@@ -80,2 +82,3 @@ 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. | ||
- motionDetection: enable/disable the motion sensor | ||
- doorbellAlerts: enable/disable doorbell ring notifications | ||
- streamingSwitch: enable/disable the ability to turn the camera on or off | ||
@@ -82,0 +85,0 @@ - disableAudio: enable/disable the audio stream |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
No v1
QualityPackage is not semver >=1. This means it is not stable and does not support ^ ranges.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
Major refactor
Supply chain riskPackage has recently undergone a major refactor. It may be unstable or indicate significant internal changes. Use caution when updating to versions that include significant changes.
Found 1 instance in 1 package
195697
1485
99
3
2