UNPKG

homebridge-bold

Version:
25 lines (24 loc) 1.16 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.SwitchAccessory = void 0; const base_accessory_1 = require("./base-accessory"); class SwitchAccessory extends base_accessory_1.BaseAccessory { constructor(platform, accessory, deviceConfig) { super(platform, accessory, deviceConfig); this.platform = platform; this.accessory = accessory; this.deviceConfig = deviceConfig; let switchService = accessory.getService(this.platform.hap.Service.Switch); if (!switchService) { switchService = accessory.addService(this.platform.hap.Service.Switch); } let on = switchService.getCharacteristic(this.platform.hap.Characteristic.On); on.onGet(() => this.isActivated) .onSet((newState) => this.setState(newState == true)); } onStateChange(activated) { let service = this.accessory.getService(this.platform.hap.Service.Switch); service === null || service === void 0 ? void 0 : service.getCharacteristic(this.platform.hap.Characteristic.On).updateValue(activated); } } exports.SwitchAccessory = SwitchAccessory;