UNPKG

homebridge-freeathome-local-api

Version:

Control your free@home setup using the local API provided by your System Access Point

41 lines 1.91 kB
import { FreeAtHomeAccessory } from "./freeAtHomeAccessory.js"; /** A smoke detector accessory. */ export class SmokeDetectorAccessory extends FreeAtHomeAccessory { platform; accessory; service; stateSmokeDetected; /** * Constructs a new smoke detector accessory instance. * @param platform The free@home Homebridge platform controlling the accessory * @param accessory The platform accessory. */ constructor(platform, accessory) { super(platform, accessory); this.platform = platform; this.accessory = accessory; // set initial state this.stateSmokeDetected = !!parseInt(this.accessory.context.channel.outputs?.odp0000.value ?? "0"); // get the SmokeSensor service if it exists, otherwise create a new service instance this.service = this.accessory.getService(this.platform.Service.SmokeSensor) || this.accessory.addService(this.platform.Service.SmokeSensor); // register handlers for the smoke detected characteristic this.service .getCharacteristic(this.platform.Characteristic.SmokeDetected) .onGet(() => this.stateSmokeDetected ? this.platform.Characteristic.SmokeDetected.SMOKE_DETECTED : this.platform.Characteristic.SmokeDetected.SMOKE_NOT_DETECTED); } updateDatapoint(datapoint, value) { // ignore unknown data points if (datapoint !== "odp0000") return; // do the update this.stateSmokeDetected = !!parseInt(value); this.doUpdateDatapoint("Smoke Detector", this.service, this.platform.Characteristic.SmokeDetected, this.stateSmokeDetected ? this.platform.Characteristic.SmokeDetected.SMOKE_DETECTED : this.platform.Characteristic.SmokeDetected.SMOKE_NOT_DETECTED); } } //# sourceMappingURL=smokeDetectorAccessory.js.map