homebridge-smartsystem
Version:
SmartServer (Proxy TCP sockets to the cloud, Smappee MQTT, Duotecno IP Nodes, Homekit interface)
42 lines • 1.32 kB
JavaScript
;
Object.defineProperty(exports, "__esModule", { value: true });
exports.Base = void 0;
const logger_1 = require("../duotecno/logger");
const config_1 = require("../duotecno/config");
///////////////
// Log Class //
///////////////
class Base {
constructor(type, config) {
this.type = type || "base";
if (config)
this.config = config;
else
this.readConfig();
if (this.debug)
logger_1.logSettings[this.type] = logger_1.LogLevel.debug;
else if (logger_1.logSettings[this.type] == logger_1.LogLevel.debug)
logger_1.logSettings[this.type] = logger_1.LogLevel.log;
(0, logger_1.debug)("system", "==== read config -> " + JSON.stringify(this.config));
}
//////////////////
// Config stuff //
//////////////////
readConfig() {
this.config = this.read(this.type);
this.debug = (!!this.config.debug) || false;
}
writeConfig() {
this.write(this.type, this.config);
}
read(type) {
return (0, config_1.getSubConfig)(type);
}
write(type, config) {
(0, config_1.setSubConfig)(type, config);
// but better to much than not enough
(0, config_1.setAPIConfig)();
}
}
exports.Base = Base;
//# sourceMappingURL=base.js.map