Skip to content

Commit

Permalink
Add support to trigger doorbell by motion
Browse files Browse the repository at this point in the history
  • Loading branch information
Sunoo committed Feb 18, 2021
1 parent 7d82224 commit 3ef7ae3
Show file tree
Hide file tree
Showing 4 changed files with 14 additions and 2 deletions.
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,7 @@ Other users have been sharing configurations that work for them on our GitHub si
- `doorbell`: Exposes the doorbell device for this camera. This can be triggered with [dummy switches](https://sunoo.github.io/homebridge-camera-ffmpeg/automation/switch.html), [MQTT messages](https://sunoo.github.io/homebridge-camera-ffmpeg/automation/mqtt.html), or [via HTTP](https://sunoo.github.io/homebridge-camera-ffmpeg/automation/http.html), depending on what features are enabled in the config. (Default: `false`)
- `switches`: Enables dummy switches to trigger motion and/or doorbell, if either of those are enabled. When enabled there will be an additional switch that triggers the motion or doorbell event. See the project site for [more detailed instructions](https://sunoo.github.io/homebridge-camera-ffmpeg/automation/switch.html). (Default: `false`)
- `motionTimeout`: The number of seconds after triggering to reset the motion sensor. Set to 0 to disable resetting of motion trigger for MQTT or HTTP. (Default: `1`)
- `motionDoorbell`: Rings the doorbell when motion is activated. This allows for motion alerts to appear on Apple TVs. (Default: `false`)
- `manufacturer`: Set the manufacturer name for display in the Home app. (Default: `Homebridge`)
- `model`: Set the model for display in the Home app. (Default: `Camera FFmpeg`)
- `serialNumber`: Set the serial number for display in the Home app. (Default: `SerialNumber`)
Expand Down
8 changes: 7 additions & 1 deletion config.schema.json
Original file line number Diff line number Diff line change
Expand Up @@ -124,6 +124,11 @@
"minimum": 0,
"description": "The number of seconds after triggering to reset the motion sensor. Set to 0 to disable resetting of motion trigger for MQTT or HTTP."
},
"motionDoorbell": {
"title": "Trigger Doorbell with Motion",
"type": "boolean",
"description": "Rings the doorbell when motion is activated. This allows for motion alerts to appear on Apple TVs."
},
"unbridge": {
"title": "Unbridge Camera",
"type": "boolean",
Expand Down Expand Up @@ -344,7 +349,8 @@
"cameras[].motion",
"cameras[].doorbell",
"cameras[].switches",
"cameras[].motionTimeout"
"cameras[].motionTimeout",
"cameras[].motionDoorbell"
]
}
]
Expand Down
1 change: 1 addition & 0 deletions src/configTypes.ts
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ export type CameraConfig = {
doorbell?: boolean;
switches?: boolean;
motionTimeout?: number;
motionDoorbell?: boolean;
unbridge?: boolean;
videoConfig?: VideoConfig;
};
Expand Down
6 changes: 5 additions & 1 deletion src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -225,11 +225,15 @@ class FfmpegPlatform implements DynamicPlatformPlugin {
}
const motionTrigger = accessory.getServiceById(hap.Service.Switch, 'MotionTrigger');
if (active) {
const config = this.cameraConfigs.get(accessory.UUID);
motionSensor.updateCharacteristic(hap.Characteristic.MotionDetected, true);
if (motionTrigger) {
motionTrigger.updateCharacteristic(hap.Characteristic.On, true);
}
let timeoutConfig = this.cameraConfigs.get(accessory.UUID)?.motionTimeout ?? 1;
if (config?.motionDoorbell) {
this.doorbellHandler(accessory, true);
}
let timeoutConfig = config?.motionTimeout ?? 1;
if (timeoutConfig < minimumTimeout) {
timeoutConfig = minimumTimeout;
}
Expand Down

0 comments on commit 3ef7ae3

Please sign in to comment.