Skip to content

Commit bd5e800

Browse files
add video doorbell functionality (#488)
* add video doorbell functionality * bump version, add changelog * fix typo * it's a feature 😎 * Update package.json * Update config.schema.json * Update config.schema.json * Update config.schema.json * remove unneeded functions * adapt indentation to rest of code * revert local test config * add subtype to motion/doorbell switches * Update config.schema.json * Update CHANGELOG.md * add credit * Create nodejs.yml * Create package-lock.json Co-authored-by: Donavan Becker <9875439+donavanbecker@users.noreply.github.com>
1 parent 52b3af2 commit bd5e800

File tree

7 files changed

+514
-10
lines changed

7 files changed

+514
-10
lines changed

.github/workflows/nodejs.yml

Lines changed: 51 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,51 @@
1+
name: NodeJS
2+
3+
on:
4+
push:
5+
branches: master
6+
pull_request:
7+
release: # Run when release is created
8+
types: [created]
9+
10+
jobs:
11+
build:
12+
13+
strategy:
14+
matrix:
15+
node-version: [10.x, 12.x, 13.x]
16+
os: [ubuntu-latest]
17+
18+
runs-on: ${{ matrix.os }}
19+
20+
steps:
21+
- uses: actions/checkout@v1
22+
- name: Use Node.js ${{ matrix.node-version }}
23+
uses: actions/setup-node@v1
24+
with:
25+
node-version: ${{ matrix.node-version }}
26+
- name: npm install, build and test
27+
run: |
28+
npm ci
29+
npm run build --if-present
30+
npm test
31+
env:
32+
CI: true
33+
34+
publish-npm:
35+
# publish only if we are on our own repo, event was 'release' (a tag was created) and the tag starts with "v" (aka version tag)
36+
if: github.repository == 'donavanbecker/homebridge-honeywell-home' && github.event_name == 'release' && startsWith(github.ref, 'refs/tags/v')
37+
38+
needs: build # only run if build succeeds
39+
40+
runs-on: ubuntu-latest
41+
42+
steps:
43+
- uses: actions/checkout@v1
44+
- uses: actions/setup-node@v1
45+
with:
46+
node-version: 10 # use the minimum required version
47+
registry-url: https://registry.npmjs.org/
48+
- run: npm ci
49+
- run: npm publish
50+
env:
51+
NODE_AUTH_TOKEN: ${{ secrets.npm_token }}

CHANGELOG.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,11 @@
22

33
All notable changes to this project will be documented in this file. This project uses [Semantic Versioning](https://semver.org/).
44

5+
## v1.1.0 (2020-05-13)
6+
7+
### Features
8+
* Adds an option to have a camera behave like a video doorbell, including a switch to trigger doorbell events (automate the switch to get notifications)
9+
* Add Manufacturer, Model, Serial, and Firmware Revision into config.schema.json.
510

611
## v1.0.0 (2020-05-11)
712

README.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,7 @@
5050

5151
* `uploader` enable uploading of snapshots to Google Drive, defaults to `false`. See wiki for more detailed instructions.
5252
* `motion` enable a dummy switch and motion sensor to trigger picture notifications in iOS 13, defaults to `false`. See wiki for more detailed instructions.
53+
* `doorbell` enable doorbell function for this camera (image notifications). When enabled there will be an additional switch that triggers the doorbell event, automate it to use it with other HomeKit switches, HTTP events etc.
5354
* `manufacturer` set manufacturer name for display in the Home app
5455
* `model` set model for display in the Home app
5556
* `serialNumber` set serial number for display in the Home app
@@ -172,3 +173,7 @@ A somewhat complicated example:
172173
We have started collecting tested configurations in the wiki, so please before raising an issue with your configuration, please check the [wiki](https://github.com/KhaosT/homebridge-camera-ffmpeg/wiki). Also if you have a working configuration that you would like to share, please add it to the [wiki](https://github.com/KhaosT/homebridge-camera-ffmpeg/wiki).
173174

174175
https://github.com/KhaosT/homebridge-camera-ffmpeg/wiki
176+
177+
## Credit
178+
179+
Homebridge Camera FFmpeg was originally created by [Khaos Tian](https://twitter.com/khaost).

config.schema.json

Lines changed: 30 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
"pluginType": "platform",
44
"singular": true,
55
"headerDisplay": "Cameras are exposed to HomeKit as separate accessories and each needs to be manually paired.\n\n1. Open the Home <img src='https://user-images.githubusercontent.com/3979615/78010622-4ea1d380-738e-11ea-8a17-e6a465eeec35.png' height='16.42px'> app on your device.\n2. Tap the Home tab, then tap <img src='https://user-images.githubusercontent.com/3979615/78010869-9aed1380-738e-11ea-9644-9f46b3633026.png' height='16.42px'>.\n3. Tap *Add Accessory*, and select *I Don't Have a Code or Cannot Scan*.\n4. Enter the Homebridge PIN, this can be found under the QR code in Homebridge UI or your Homebridge logs, alternatively you can select *Use Camera* and scan the QR code again.\n\nFor help and examples of common configurations please read the [wiki](https://github.com/KhaosT/homebridge-camera-ffmpeg/wiki).",
6-
"footerDisplay": "The **ffmpeg** binary must be installed on your system for this plugin to work.",
6+
"footerDisplay": "The **ffmpeg** binary must be installed on your system for this plugin to work. If you are using a custom compiled FFmpeg, to use Audio must compile with libfdk-aac enabled.",
77
"schema": {
88
"name": {
99
"title": "Name",
@@ -33,19 +33,28 @@
3333
"type": "boolean"
3434
},
3535
"manufacturer": {
36+
"name": "Manufacturer",
3637
"type": "string"
3738
},
3839
"model": {
40+
"name": "Model",
3941
"type": "string"
4042
},
4143
"serialNumber": {
44+
"name": "Camera Serial",
4245
"type": "string"
4346
},
4447
"firmwareRevision": {
48+
"name": "Firmware Version",
4549
"type": "string"
4650
},
4751
"motion": {
48-
"title": "Enable IOS 13 Motion Notifications",
52+
"title": "Enable iOS 13 Motion Notifications",
53+
"type": "boolean"
54+
},
55+
"doorbell": {
56+
"title": "Enable Doorbell",
57+
"description": "Set this up as a doorbell with a switch as trigger (automate the switch to get notifications).",
4958
"type": "boolean"
5059
},
5160
"videoConfig": {
@@ -127,7 +136,7 @@
127136
"title": "Packet Size",
128137
"type": "number",
129138
"placeholder": 1316,
130-
"multipleOf": 188.0
139+
"multipleOf": 188
131140
},
132141
"videoFilter": {
133142
"title": "Allows a custom video filter to be passed to FFmpeg via -vf",
@@ -152,7 +161,7 @@
152161
"description": " Select the stream used for audio"
153162
},
154163
"audio": {
155-
"title": "Enable Audio (requires ffmpeg with libfdk-aac)",
164+
"title": "Enable Audio",
156165
"type": "boolean"
157166
},
158167
"vflip": {
@@ -185,7 +194,22 @@
185194
"cameras[].videoConfig.stillImageSource",
186195
"cameras[].videoConfig.vcodec",
187196
"cameras[].videoConfig.audio",
197+
"cameras[].motion",
198+
"cameras[].doorbell",
188199
"cameras[].videoConfig.debug",
200+
{
201+
"key": "cameras[]",
202+
"type": "section",
203+
"title": "Customization Settings",
204+
"expandable": true,
205+
"expanded": false,
206+
"items": [
207+
"cameras[].manufacturer",
208+
"cameras[].model",
209+
"cameras[].serialNumber",
210+
"cameras[].firmwareRevision"
211+
]
212+
},
189213
{
190214
"key": "cameras[].videoConfig",
191215
"type": "section",
@@ -205,11 +229,10 @@
205229
"cameras[].videoConfig.mapvideo",
206230
"cameras[].videoConfig.mapaudio",
207231
"cameras[].videoConfig.vflip",
208-
"cameras[].videoConfig.hflip",
209-
"cameras[].motion"
232+
"cameras[].videoConfig.hflip"
210233
]
211234
}
212235
]
213236
}
214237
]
215-
}
238+
}

index.js

Lines changed: 22 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,11 @@ ffmpegPlatform.prototype.didFinishLaunching = function() {
5151
}
5252

5353
var uuid = UUIDGen.generate(cameraName);
54-
var cameraAccessory = new Accessory(cameraName, uuid, hap.Accessory.Categories.CAMERA);
54+
var accessoryType = hap.Accessory.Categories.CAMERA;
55+
if(cameraConfig.doorbell){
56+
accessoryType = hap.Accessory.Categories.VIDEO_DOORBELL;
57+
}
58+
var cameraAccessory = new Accessory(cameraName, uuid, accessoryType);
5559
var cameraAccessoryInfo = cameraAccessory.getService(Service.AccessoryInformation);
5660
if (cameraConfig.manufacturer) {
5761
cameraAccessoryInfo.setCharacteristic(Characteristic.Manufacturer, cameraConfig.manufacturer);
@@ -66,9 +70,25 @@ ffmpegPlatform.prototype.didFinishLaunching = function() {
6670
cameraAccessoryInfo.setCharacteristic(Characteristic.FirmwareRevision, cameraConfig.firmwareRevision);
6771
}
6872

73+
if(cameraConfig.doorbell) {
74+
var doorbellService = new Service.Doorbell(cameraName+" Doorbell");
75+
cameraAccessory.addService(doorbellService);
76+
var switchService = new Service.Switch(cameraName + " Doorbell Trigger", "DoorbellTrigger");
77+
switchService.getCharacteristic(Characteristic.On)
78+
.on('set', function(state, callback){
79+
if(state){
80+
cameraAccessory.getService(Service.Doorbell).getCharacteristic(Characteristic.ProgrammableSwitchEvent).setValue(0);
81+
setTimeout(function(){
82+
switchService.getCharacteristic(Characteristic.On).updateValue(false);
83+
}, 1000);
84+
}
85+
callback(null, state);
86+
});
87+
cameraAccessory.addService(switchService);
88+
}
6989
cameraAccessory.context.log = self.log;
7090
if (cameraConfig.motion) {
71-
var button = new Service.Switch(cameraName);
91+
var button = new Service.Switch(cameraName, "MotionTrigger");
7292
cameraAccessory.addService(button);
7393

7494
var motion = new Service.MotionSensor(cameraName);

0 commit comments

Comments
 (0)