homebridge-ring
Version:
Homebridge plugin for Ring doorbells, cameras, security alarm system and smart lighting
25 lines (24 loc) • 845 B
JavaScript
import { BaseDeviceAccessory } from "./base-device-accessory.js";
import { hap } from "./hap.js";
export class ContactSensor extends BaseDeviceAccessory {
device;
accessory;
config;
constructor(device, accessory, config) {
super();
this.device = device;
this.accessory = accessory;
this.config = config;
const { Characteristic: { ContactSensorState }, Service, } = hap;
this.registerCharacteristic({
characteristicType: ContactSensorState,
serviceType: Service.ContactSensor,
getValue: (data) => {
return data.faulted
? ContactSensorState.CONTACT_NOT_DETECTED
: ContactSensorState.CONTACT_DETECTED;
},
});
this.initSensorService(Service.ContactSensor);
}
}