homebridge-texecom-connect
Version:
A Homebridge plugin to integrate with Texecom Connect SmartCom.
50 lines • 1.92 kB
JavaScript
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.TexecomAccessory = void 0;
/**
* Texecom Accessory
*/
class TexecomAccessory {
accessory;
config;
platform;
service;
serviceCharacteristic;
serviceType;
state;
get characteristic() {
return this.service.getCharacteristic(this.serviceCharacteristic);
}
constructor(platform, accessory, serviceType, serviceCharacteristic, state) {
this.accessory = accessory;
this.config = this.accessory.context.config;
this.platform = platform;
this.serviceCharacteristic = serviceCharacteristic;
this.serviceType = serviceType;
this.state = state;
const serviceInformation = this.accessory
.getService(this.platform.service.AccessoryInformation);
if (serviceInformation !== undefined) {
serviceInformation.setCharacteristic(this.platform.characteristic.Manufacturer, "Texecom")
.setCharacteristic(this.platform.characteristic.Model, "Texecom Accessory")
.setCharacteristic(this.platform.characteristic.SerialNumber, "Unknown");
}
this.service =
this.accessory.getService(this.serviceType)
?? this.accessory.addService(this.serviceType); // Type hack
this.service.setCharacteristic(this.platform.characteristic.Name, this.config.name);
this.platform.accessoryEvent
.addListener(this.platform.getAccessoryId(this.config), this.listener.bind(this));
this.characteristic
.onGet(this.getCharacteristic.bind(this))
.onSet(this.setCharacteristic.bind(this));
}
getCharacteristic() {
return this.state;
}
setCharacteristic(value) {
this.state = value;
}
}
exports.TexecomAccessory = TexecomAccessory;
//# sourceMappingURL=texecom-accessory.js.map