UNPKG

node-red-contrib-home-assistant-websocket

Version:
27 lines (26 loc) 1.25 kB
"use strict"; var __importDefault = (this && this.__importDefault) || function (mod) { return (mod && mod.__esModule) ? mod : { "default": mod }; }; Object.defineProperty(exports, "__esModule", { value: true }); const ExposeAsMixin_1 = __importDefault(require("../../common/controllers/ExposeAsMixin")); const OutputController_1 = __importDefault(require("../../common/controllers/OutputController")); const const_1 = require("../../const"); const ExposeAsController = (0, ExposeAsMixin_1.default)((OutputController_1.default)); class SentenceController extends ExposeAsController { async onReceivedMessage(data) { if (!this.isEnabled) return; const message = {}; await this.setCustomOutputs(this.node.config.outputProperties, message, { [const_1.TypedInputTypes.Config]: this.node.config, [const_1.TypedInputTypes.TriggerId]: data.sentence, [const_1.TypedInputTypes.Results]: data.result, [const_1.TypedInputTypes.DeviceId]: data.deviceId, }); message._sentence_response_id = data.responseId; this.status.setSuccess('home-assistant.status.triggered'); this.node.send(message); } } exports.default = SentenceController;