From c806e58cd75f5ee97a227a15910cff86dfdb59c4 Mon Sep 17 00:00:00 2001 From: Billy Zoellers Date: Sat, 6 Aug 2022 21:00:30 -0400 Subject: [PATCH] prefer EntrySensor over BinarySensor if device has both (#332) --- plugins/homekit/src/types/sensor.ts | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/plugins/homekit/src/types/sensor.ts b/plugins/homekit/src/types/sensor.ts index dc0a6d2e0..84aac241b 100644 --- a/plugins/homekit/src/types/sensor.ts +++ b/plugins/homekit/src/types/sensor.ts @@ -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);