UNPKG

homebridge-virtual-accessories

Version:
26 lines 1.25 kB
/* eslint-disable brace-style */ import { InvalidSensorValueType, SensorValueUpdateNotAllowed } from '../../errors.js'; import { Sensor } from '../sensor.js'; import { Trigger } from './trigger.js'; /** * WebhookTrigger - Trigger implementation */ export class WebhookTrigger extends Trigger { constructor(sensor, name) { super(sensor, name); } triggerSensor(value, accessoryId) { this.log.debug(`[${this.sensorConfig.accessoryName}] Request update triggered state to ${value}`); if (accessoryId !== this.sensorConfig.accessoryID) { this.log.error(`[${this.sensorConfig.accessoryName}] Accessory Id ${accessoryId} is not valid for this accessory`); throw new SensorValueUpdateNotAllowed(`Invalid accessory id: ${accessoryId}`); } else if (typeof value !== 'boolean') { this.log.error(`[${this.sensorConfig.accessoryName}] Value ${value} is not valid for a Security System triggered state`); throw new InvalidSensorValueType(`Invalid sensor value: ${value}`); } const sensorState = value ? Sensor.TRIGGERED : Sensor.NORMAL; this.sensor.triggerSensorState(sensorState, this); } } //# sourceMappingURL=triggerWebhook.js.map