UNPKG

node-red-contrib-home-assistant-websocket

Version:
26 lines (25 loc) 1.1 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 ExposeAsController = (0, ExposeAsMixin_1.default)((OutputController_1.default)); class TimeEntityController extends ExposeAsController { // Triggers when a entity value changes in Home Assistant async onValueChange(value, previousValue) { if (!this.isEnabled) return; const message = {}; await this.setCustomOutputs(this.node.config.outputProperties, message, { config: this.node.config, value, previousValue, }); // inject value so colons are not removed this.status.setSuccess(['__value__', { value }]); this.node.send(message); } } exports.default = TimeEntityController;