mirror of
https://github.com/koush/scrypted.git
synced 2026-02-11 17:44:27 +00:00
homekit: add more supported sensors
This commit is contained in:
4
plugins/homekit/package-lock.json
generated
4
plugins/homekit/package-lock.json
generated
@@ -1,12 +1,12 @@
|
||||
{
|
||||
"name": "@scrypted/homekit",
|
||||
"version": "0.0.173",
|
||||
"version": "0.0.174",
|
||||
"lockfileVersion": 2,
|
||||
"requires": true,
|
||||
"packages": {
|
||||
"": {
|
||||
"name": "@scrypted/homekit",
|
||||
"version": "0.0.173",
|
||||
"version": "0.0.174",
|
||||
"dependencies": {
|
||||
"hap-nodejs": "file:../../external/HAP-NodeJS",
|
||||
"lodash": "^4.17.21",
|
||||
|
||||
@@ -40,5 +40,5 @@
|
||||
"@types/qrcode": "^1.4.1",
|
||||
"@types/url-parse": "^1.4.3"
|
||||
},
|
||||
"version": "0.0.173"
|
||||
"version": "0.0.174"
|
||||
}
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
|
||||
import { MotionSensor, BinarySensor, ScryptedDevice, ScryptedDeviceType, ScryptedInterface, Thermometer } from '@scrypted/sdk'
|
||||
import { MotionSensor, BinarySensor, ScryptedDevice, ScryptedDeviceType, ScryptedInterface, Thermometer, HumiditySensor } from '@scrypted/sdk'
|
||||
import { addSupportedType, bindCharacteristic, DummyDevice } from '../common'
|
||||
import { Characteristic, Service } from '../hap';
|
||||
import { makeAccessory } from './common';
|
||||
@@ -9,20 +9,17 @@ addSupportedType({
|
||||
probe(device: DummyDevice) {
|
||||
return device.interfaces.includes(ScryptedInterface.Thermometer) || device.interfaces.includes(ScryptedInterface.BinarySensor) || device.interfaces.includes(ScryptedInterface.MotionSensor);
|
||||
},
|
||||
getAccessory: async (device: ScryptedDevice & BinarySensor & MotionSensor & Thermometer) => {
|
||||
getAccessory: async (device: ScryptedDevice & BinarySensor & MotionSensor & Thermometer & HumiditySensor) => {
|
||||
const accessory = makeAccessory(device);
|
||||
|
||||
if (device.interfaces.includes(ScryptedInterface.BinarySensor)) {
|
||||
const contactSensorService = accessory.addService(Service.ContactSensor, device.name);
|
||||
contactSensorService.getCharacteristic(Characteristic.ContactSensorState)
|
||||
|
||||
bindCharacteristic(device, ScryptedInterface.BinarySensor, contactSensorService, Characteristic.ContactSensorState,
|
||||
() => !!device.binaryState);
|
||||
}
|
||||
|
||||
if (device.interfaces.includes(ScryptedInterface.MotionSensor)) {
|
||||
const motionSensorService = accessory.addService(Service.MotionSensor, device.name);
|
||||
|
||||
bindCharacteristic(device, ScryptedInterface.MotionSensor, motionSensorService, Characteristic.MotionDetected,
|
||||
() => !!device.motionDetected, true);
|
||||
}
|
||||
@@ -31,7 +28,12 @@ addSupportedType({
|
||||
const service = accessory.addService(Service.TemperatureSensor, device.name);
|
||||
bindCharacteristic(device, ScryptedInterface.Thermometer, service, Characteristic.CurrentTemperature,
|
||||
() => device.temperature || 0);
|
||||
}
|
||||
|
||||
if (device.interfaces.includes(ScryptedInterface.HumiditySensor)) {
|
||||
const service = accessory.addService(Service.HumiditySensor, device.name);
|
||||
bindCharacteristic(device, ScryptedInterface.HumiditySensor, service, Characteristic.CurrentRelativeHumidity,
|
||||
() => device.humidity || 0);
|
||||
}
|
||||
|
||||
// todo: more sensors.
|
||||
|
||||
Reference in New Issue
Block a user