Skip to content

Commit

Permalink
hap: merge in sirens as child devices (#674)
Browse files Browse the repository at this point in the history
* hap: merge in sirens as child devices

* add subtype to onOff base
  • Loading branch information
leedsalex authored Mar 31, 2023
1 parent a9e6d76 commit 58c3348
Show file tree
Hide file tree
Showing 4 changed files with 40 additions and 34 deletions.
48 changes: 24 additions & 24 deletions plugins/homekit/package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

8 changes: 4 additions & 4 deletions plugins/homekit/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@scrypted/homekit",
"version": "1.2.21",
"version": "1.2.22",
"description": "HomeKit Plugin for Scrypted",
"scripts": {
"scrypted-setup-project": "scrypted-setup-project",
Expand Down Expand Up @@ -38,14 +38,14 @@
"check-disk-space": "^3.3.1",
"hap-nodejs": "^0.11.0",
"lodash": "^4.17.21",
"mkdirp": "^2.1.5"
"mkdirp": "^2.1.6"
},
"devDependencies": {
"@scrypted/common": "file:../../common",
"@scrypted/sdk": "file:../../sdk",
"@types/debug": "^4.1.7",
"@types/lodash": "^4.14.191",
"@types/node": "^18.15.5",
"@types/lodash": "^4.14.192",
"@types/node": "^18.15.11",
"@types/url-parse": "^1.4.8"
}
}
16 changes: 11 additions & 5 deletions plugins/homekit/src/types/camera.ts
Original file line number Diff line number Diff line change
Expand Up @@ -303,13 +303,19 @@ addSupportedType({
}
}

// if the camera is a device provider, merge in child devices and
// ensure the devices are skipped by the rest of homekit by
// reporting that they've been merged
if (device.interfaces.includes(ScryptedInterface.DeviceProvider)) {
// merge in lights
const { devices } = mergeOnOffDevicesByType(device as ScryptedDevice as ScryptedDevice & DeviceProvider, accessory, ScryptedDeviceType.Light);

// ensure child devices are skipped by the rest of homekit by
// reporting that they've been merged
devices.map(device => homekitPlugin.mergedDevices.add(device.id));
mergeOnOffDevicesByType(device as ScryptedDevice as ScryptedDevice & DeviceProvider, accessory, ScryptedDeviceType.Light).devices.forEach(device => {
homekitPlugin.mergedDevices.add(device.id)
});

// merge in sirens
mergeOnOffDevicesByType(device as ScryptedDevice as ScryptedDevice & DeviceProvider, accessory, ScryptedDeviceType.Siren).devices.forEach(device => {
homekitPlugin.mergedDevices.add(device.id)
});
}

return accessory;
Expand Down
2 changes: 1 addition & 1 deletion plugins/homekit/src/types/onoff-base.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ export function probe(device: DummyDevice): boolean {
}

export function getService(device: ScryptedDevice & OnOff, accessory: Accessory, serviceType: any): Service {
const service = accessory.addService(serviceType, device.name);
const service = accessory.addService(serviceType, device.name, device.nativeId);
service.getCharacteristic(Characteristic.On)
.on(CharacteristicEventTypes.SET, (value: CharacteristicValue, callback: CharacteristicSetCallback) => {
callback();
Expand Down

0 comments on commit 58c3348

Please sign in to comment.