node-red-contrib-home-assistant-websocket
Version:
Node-RED integration with Home Assistant through websocket and REST API
40 lines (39 loc) • 1.69 kB
JavaScript
var __importDefault = (this && this.__importDefault) || function (mod) {
return (mod && mod.__esModule) ? mod : { "default": mod };
};
Object.defineProperty(exports, "__esModule", { value: true });
exports.default = Sensor;
const helpers_1 = require("../../common/controllers/helpers");
const InputService_1 = __importDefault(require("../../common/services/InputService"));
const Status_1 = __importDefault(require("../../common/status/Status"));
const globals_1 = require("../../globals");
const migrate_1 = require("../../helpers/migrate");
const node_1 = require("../../helpers/node");
const homeAssistant_1 = require("../../homeAssistant");
const binary_sensor_1 = require("../binary-sensor");
const SensorController_1 = __importDefault(require("./SensorController"));
function Sensor(config) {
globals_1.RED.nodes.createNode(this, config);
this.config = (0, migrate_1.migrate)(config);
const { entityConfigNode, serverConfigNode } = (0, node_1.getConfigNodes)(this);
const homeAssistant = (0, homeAssistant_1.getHomeAssistant)(serverConfigNode);
const status = new Status_1.default({
config: serverConfigNode.config,
node: this,
});
const controllerDeps = (0, helpers_1.createControllerDependencies)(this, homeAssistant);
const inputService = new InputService_1.default({
inputs: binary_sensor_1.inputs,
nodeConfig: this.config,
schema: binary_sensor_1.inputSchema,
});
// eslint-disable-next-line no-new
new SensorController_1.default({
inputService,
node: this,
status,
integration: entityConfigNode.integration,
...controllerDeps,
});
}
;