UNPKG

homebridge-deconz-converter

Version:

Homebridge plugin for converting Deconz roller shutters interpreted as light into Homekit Window Covering type.

39 lines 1.9 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.NodonMultifonctionsAccessory = void 0; class NodonMultifonctionsAccessory { constructor(platform, accessory) { this.platform = platform; this.accessory = accessory; this.service = this.accessory.getService(this.platform.Service.Switch) || this.accessory.addService(this.platform.Service.Switch); this.service.setCharacteristic(this.platform.Characteristic.Name, accessory.context.device.displayName); this.service.getCharacteristic(this.platform.Characteristic.On) .on("get" /* GET */, this.getIsOn.bind(this)) .on("set" /* SET */, this.setIsOn.bind(this)); } async setAccessoryInformations() { const response = await this.platform.client.getLightByUniqueId(this.accessory.context.device.uniqueId); const device = response.data; const serialNumber = device.uniqueid.slice(0, device.uniqueid.length - 3).replaceAll(':', '').toUpperCase(); this.accessory.getService(this.platform.Service.AccessoryInformation) .setCharacteristic(this.platform.Characteristic.Manufacturer, device.manufacturername) .setCharacteristic(this.platform.Characteristic.Model, device.modelid) .setCharacteristic(this.platform.Characteristic.SerialNumber, serialNumber); } async getIsOn(callback) { callback(null, false); } async setIsOn(value, callback) { this.platform.log.info(`Set ${this.accessory.context.device.displayName} on`); try { await this.platform.client.setLightOn(this.accessory.context.device.uniqueId); callback(); } catch (err) { callback(err); } } } exports.NodonMultifonctionsAccessory = NodonMultifonctionsAccessory; //# sourceMappingURL=nodonMultifonctions.js.map