homebridge-connect-my-pool-home-automation
Version:
HomeKit integration for Astral Viron Gateway via Home Automation
73 lines • 2.81 kB
JavaScript
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.Accessory = void 0;
const settings_1 = require("../settings");
/**
* Connect My Pool Base Accessory
* An instance of this class is created for each accessory your platform registers
* Each accessory may expose multiple services of different service types.
*/
class Accessory {
constructor(platform, accessory, device, status) {
this.platform = platform;
this.accessory = accessory;
this.services = [];
this.service = this.platform.Service;
this.log = this.platform.log;
this.accessory.context.device = device;
this.accessory.context.status = status;
this.setConfigStatus(status);
this.Characteristic = this.platform.api.hap.Characteristic;
// set accessory information
this.accessory.getService(this.service.AccessoryInformation)
.setCharacteristic(this.Characteristic.Name, device.deviceName)
.setCharacteristic(this.Characteristic.Manufacturer, settings_1.MANUFACTURER)
.setCharacteristic(this.Characteristic.Model, device.deviceType)
.setCharacteristic(this.Characteristic.SerialNumber, this.SerialNumber);
this.setUpServices();
}
get device() {
return this.accessory.context.device;
}
get poolStatus() {
return this.accessory.context.status;
}
get deviceName() {
return this.device.deviceName;
}
get deviceType() {
return this.device.deviceType;
}
get homekitAccessory() {
return this.accessory;
}
get SerialNumber() {
return '0000.0000.000' + this.device.deviceTypeNumber.toString();
}
// eslint-disable-next-line @typescript-eslint/no-explicit-any
debugLog(message, ...parameters) {
this.log.debug('[%s] %s', this.deviceName, message, ...parameters);
}
setUpServices() {
this.log.debug('Creating %s services', this.deviceName);
}
updatePlatform() {
//this.platform.api.publishExternalAccessories(PLUGIN_NAME, [this.accessory]);
// Refresh the accessory cache with these values.
this.platform.api.updatePlatformAccessories([this.accessory]);
}
// eslint-disable-next-line @typescript-eslint/no-unused-vars
setConfigStatus(status) {
// to be implemented in children classes
}
// eslint-disable-next-line no-unused-vars
async updateStatus(status) {
if (status) {
this.accessory.context.status = status;
this.setConfigStatus(status);
}
// to be implemented in children classes
}
}
exports.Accessory = Accessory;
//# sourceMappingURL=accessory.js.map