mirror of
https://github.com/koush/scrypted.git
synced 2026-02-09 00:39:56 +00:00
prefer EntrySensor over BinarySensor if device has both (#332)
This commit is contained in:
@@ -49,15 +49,16 @@ addSupportedType({
|
||||
getAccessory: async (device: ScryptedDevice & OccupancySensor & AmbientLightSensor & AmbientLightSensor & AudioSensor & BinarySensor & MotionSensor & Thermometer & HumiditySensor & FloodSensor & AirQualitySensor & PM25Sensor & VOCSensor & EntrySensor & TamperSensor & CO2Sensor, homekitPlugin: HomeKitPlugin) => {
|
||||
const accessory = makeAccessory(device, homekitPlugin);
|
||||
|
||||
if (device.interfaces.includes(ScryptedInterface.BinarySensor)) {
|
||||
const service = accessory.addService(Service.ContactSensor, device.name);
|
||||
bindCharacteristic(device, ScryptedInterface.BinarySensor, service, Characteristic.ContactSensorState,
|
||||
() => !!device.binaryState);
|
||||
} else if (device.interfaces.includes(ScryptedInterface.EntrySensor)) {
|
||||
if (device.interfaces.includes(ScryptedInterface.EntrySensor)) {
|
||||
const service = accessory.addService(Service.ContactSensor, device.name);
|
||||
bindCharacteristic(device, ScryptedInterface.EntrySensor, service, Characteristic.ContactSensorState,
|
||||
() => !!device.entryOpen);
|
||||
}
|
||||
else if (device.interfaces.includes(ScryptedInterface.BinarySensor)) {
|
||||
const service = accessory.addService(Service.ContactSensor, device.name);
|
||||
bindCharacteristic(device, ScryptedInterface.BinarySensor, service, Characteristic.ContactSensorState,
|
||||
() => !!device.binaryState);
|
||||
}
|
||||
|
||||
if (device.interfaces.includes(ScryptedInterface.OccupancySensor)) {
|
||||
const service = accessory.addService(Service.OccupancySensor, device.name);
|
||||
|
||||
Reference in New Issue
Block a user