prefer EntrySensor over BinarySensor if device has both (#332)

This commit is contained in:
Billy Zoellers
2022-08-06 21:00:30 -04:00
committed by GitHub
parent 5b89c2c67f
commit c806e58cd7

View File

@@ -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);