Properly reference flicIR.debug (#5)
This commit is contained in:
1 parent
bf4e69e2ce
commit
2935827f60
1 file changed
+20
-19
+20
-19
@@ -1,9 +1,10 @@
|
|||||||
import { ButtonControllerOpt, makeButtonController } from "./ButtonController";
|
import {ButtonControllerOpt, makeButtonController} from "./ButtonController";
|
||||||
import { HAmqttOptions, makeHAmqtt } from './HAmqtt';
|
import {HAmqttOptions, makeHAmqtt} from './HAmqtt';
|
||||||
import { IRControllerOpt, makeIRController } from "./IRController";
|
import {IRControllerOpt, makeIRController} from "./IRController";
|
||||||
import { makeLogger } from "./Logger";
|
import {makeLogger} from "./Logger";
|
||||||
import { ButtonModule, IRModule } from './flicTypes';
|
import {ButtonModule, IRModule} from './flicTypes';
|
||||||
import * as mqtt from './mqtt';
|
import * as mqtt from './mqtt';
|
||||||
|
|
||||||
export type MQTTOpt = {
|
export type MQTTOpt = {
|
||||||
host: string;
|
host: string;
|
||||||
port: number;
|
port: number;
|
||||||
@@ -27,18 +28,18 @@ export const start = (
|
|||||||
) => {
|
) => {
|
||||||
const mqttServer = mqtt.create(
|
const mqttServer = mqtt.create(
|
||||||
options.mqtt.host,
|
options.mqtt.host,
|
||||||
{ ...options.mqtt, keep_alive: true },
|
{...options.mqtt, keep_alive: true},
|
||||||
);
|
);
|
||||||
const logger = makeLogger('root', options.debug ?? false);
|
const logger = makeLogger('root', options.debug ?? false);
|
||||||
options.ha = options.ha ?? {}
|
options.ha = options.ha ?? {};
|
||||||
options.flicBtns = options.flicBtns ?? {}
|
options.flicBtns = options.flicBtns ?? {};
|
||||||
options.flicIR = options.flicIR ?? {}
|
options.flicIR = options.flicIR ?? {};
|
||||||
options.ha.debug = options.ha.debug ?? options.debug ?? false
|
options.ha.debug = options.ha.debug ?? options.debug ?? false;
|
||||||
options.flicBtns.debug = options.flicBtns.debug ?? options.debug ?? false
|
options.flicBtns.debug = options.flicBtns.debug ?? options.debug ?? false;
|
||||||
options.flicIR.debug = options.flicBtns.debug ?? options.debug ?? false
|
options.flicIR.debug = options.flicIR.debug ?? options.debug ?? false;
|
||||||
const ha = makeHAmqtt(mqttServer, options.ha);
|
const ha = makeHAmqtt(mqttServer, options.ha);
|
||||||
mqttServer.on('connected', () => {
|
mqttServer.on('connected', () => {
|
||||||
logger.info("connected to mqtt")
|
logger.info("connected to mqtt");
|
||||||
if (!options.flicBtns?.disabled) {
|
if (!options.flicBtns?.disabled) {
|
||||||
makeButtonController(
|
makeButtonController(
|
||||||
ha, buttonModule, options.flicBtns,
|
ha, buttonModule, options.flicBtns,
|
||||||
@@ -52,25 +53,25 @@ export const start = (
|
|||||||
options.flicIR,
|
options.flicIR,
|
||||||
).start();
|
).start();
|
||||||
}
|
}
|
||||||
logger.info("all services up!")
|
logger.info("all services up!");
|
||||||
});
|
});
|
||||||
mqttServer.on('error', function (err) {
|
mqttServer.on('error', function (err) {
|
||||||
logger.info("'Error' event", JSON.stringify(err));
|
logger.info("'Error' event", JSON.stringify(err));
|
||||||
setTimeout(function () {
|
setTimeout(function () {
|
||||||
throw new Error("Crashed")
|
throw new Error("Crashed");
|
||||||
}, 1000);
|
}, 1000);
|
||||||
});
|
});
|
||||||
mqttServer.on("disconnected", function (err) {
|
mqttServer.on("disconnected", function (err) {
|
||||||
logger.info("'Error' disconnected", JSON.stringify(err));
|
logger.info("'Error' disconnected", JSON.stringify(err));
|
||||||
setTimeout(function () {
|
setTimeout(function () {
|
||||||
throw new Error("Crashed")
|
throw new Error("Crashed");
|
||||||
}, 1000);
|
}, 1000);
|
||||||
});
|
});
|
||||||
mqttServer.on("close", function (err) {
|
mqttServer.on("close", function (err) {
|
||||||
logger.info("'Error' close", JSON.stringify(err));
|
logger.info("'Error' close", JSON.stringify(err));
|
||||||
setTimeout(function () {
|
setTimeout(function () {
|
||||||
throw new Error("Crashed")
|
throw new Error("Crashed");
|
||||||
}, 1000);
|
}, 1000);
|
||||||
});
|
});
|
||||||
mqttServer.connect()
|
mqttServer.connect();
|
||||||
}
|
};
|
||||||
Reference in new issue
Block a user