node-red-contrib-home-assistant-websocket
Version:
Node-RED integration with Home Assistant through websocket and REST API
20 lines (19 loc) • 809 B
JavaScript
Object.defineProperty(exports, "__esModule", { value: true });
exports.default = configServerNode;
const Events_1 = require("../../common/events/Events");
const globals_1 = require("../../globals");
const migrate_1 = require("../../helpers/migrate");
const homeAssistant_1 = require("../../homeAssistant");
function configServerNode(config) {
globals_1.RED.nodes.createNode(this, config);
this.config = (0, migrate_1.migrate)(config);
this.exposedNodes = {};
(0, homeAssistant_1.createHomeAssistantClient)(this);
this.on(Events_1.NodeEvent.Close, (_removed, done) => {
(0, homeAssistant_1.closeHomeAssistant)(this.id);
// @ts-expect-error - set context second argument is optional
this.context().global.set('homeassistant');
done();
});
}
;