homebridge-cozytouch-platform
Version:
Homebridge Cozytouch platform
87 lines (86 loc) • 4.07 kB
JavaScript
;
var __extends = (this && this.__extends) || (function () {
var extendStatics = function (d, b) {
extendStatics = Object.setPrototypeOf ||
({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
function (d, b) { for (var p in b) if (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p]; };
return extendStatics(d, b);
};
return function (d, b) {
if (typeof b !== "function" && b !== null)
throw new TypeError("Class extends value " + String(b) + " is not a constructor or null");
extendStatics(d, b);
function __() { this.constructor = d; }
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
};
})();
Object.defineProperty(exports, "__esModule", { value: true });
exports.CozytouchAccessoryWrapper = exports.CozytouchState = void 0;
var homebridge_base_platform_1 = require("homebridge-base-platform");
var CozytouchState;
(function (CozytouchState) {
CozytouchState["model"] = "core:ModelState";
CozytouchState["version"] = "core:VersionState";
CozytouchState["manufacturer"] = "core:ManufacturerNameState";
})(CozytouchState = exports.CozytouchState || (exports.CozytouchState = {}));
var CozytouchAccessoryWrapper = /** @class */ (function (_super) {
__extends(CozytouchAccessoryWrapper, _super);
function CozytouchAccessoryWrapper(context, accessory, device) {
var _this = _super.call(this, context, accessory, device) || this;
_this.informationService = _this.initInformationService();
_this.log("Found device [".concat(_this.getDisplayName(), "]"));
return _this;
}
Object.defineProperty(CozytouchAccessoryWrapper.prototype, "object", {
get: function () {
return this.device.object;
},
enumerable: false,
configurable: true
});
CozytouchAccessoryWrapper.prototype.initInformationService = function () {
var informationService = this.accessory.getService(this.Service.AccessoryInformation);
informationService
.setCharacteristic(this.Characteristic.Name, this.getDisplayName())
.setCharacteristic(this.Characteristic.Model, this.getModel());
var serial = this.getSerial();
if (serial !== undefined) {
informationService.setCharacteristic(this.Characteristic.SerialNumber, serial);
}
var manufacturer = this.getManufacturer();
if (manufacturer !== undefined) {
informationService.setCharacteristic(this.Characteristic.Manufacturer, manufacturer);
}
var version = this.getSoftwareVersion();
if (version !== undefined) {
informationService.setCharacteristic(this.Characteristic.FirmwareRevision, version);
}
version = this.getHardwareVersion();
if (version !== undefined) {
informationService.setCharacteristic(this.Characteristic.HardwareRevision, version);
}
return informationService;
};
CozytouchAccessoryWrapper.prototype.getModel = function () {
var model = this.object.getStateValue(CozytouchState.model);
return model !== undefined ? model : this.object.model;
};
CozytouchAccessoryWrapper.prototype.getSerial = function () {
var res = this.object.URL.split('/');
if (res.length > 0) {
return res[res.length - 1];
}
return undefined;
};
CozytouchAccessoryWrapper.prototype.getHardwareVersion = function () {
return this.object.getStateValue(CozytouchState.version);
};
CozytouchAccessoryWrapper.prototype.getSoftwareVersion = function () {
return undefined;
};
CozytouchAccessoryWrapper.prototype.getManufacturer = function () {
return this.object.getStateValue(CozytouchState.manufacturer);
};
return CozytouchAccessoryWrapper;
}(homebridge_base_platform_1.HomebridgeAccessoryWrapper));
exports.CozytouchAccessoryWrapper = CozytouchAccessoryWrapper;