From 3aedb009ff9f1b7d16112d9c4b557678f0b13e30 Mon Sep 17 00:00:00 2001 From: vvzvlad Date: Tue, 3 Oct 2023 00:55:42 +0300 Subject: [PATCH] Bump version to 0.1.2 --- package.json | 2 +- thermostat.html | 2 +- thermostat.js | 23 +++++++++++++++-------- 3 files changed, 17 insertions(+), 10 deletions(-) diff --git a/package.json b/package.json index f506309..c722fbd 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "@vvzvlad/node-red-contrib-rn-combined-nodes", - "version": "0.1.1", + "version": "0.1.2", "description": "", "main": "index.js", "keywords": [ diff --git a/thermostat.html b/thermostat.html index 9847afe..2bc6dbb 100644 --- a/thermostat.html +++ b/thermostat.html @@ -7,7 +7,7 @@ name: {value:""} }, inputs: 1, - outputs: 1, + outputs: 2, icon: "file.svg", label: function() { return this.name||"C-Thermostat"; diff --git a/thermostat.js b/thermostat.js index d1117b6..666243f 100644 --- a/thermostat.js +++ b/thermostat.js @@ -6,19 +6,19 @@ module.exports = function(RED) { const HEAT_ON_THRESHOLD = 0.2 const HEAT_OFF_THRESHOLD = 0.2 - - let control_mode = context.get("control_mode") || "auto" //auto, on, off - let current_temp = context.get("current_temp") - let target_temp = context.get("target_temp") || 19 - let window_state = context.get("window_state") || "close" //open, close - let window_mode = context.get("window_mode") || "cool" //heat, cool, off - let heater_status = null let debug = "" + + function debug_text(text) { - if (text === "return_debug") return debug + if (text === "return_debug") { + let debug_tmp = debug + debug = "" + return debug + } debug = debug ? `${debug}, ${text}` : text + } function predict_temp_change(current_temp, time_interval) { @@ -114,6 +114,13 @@ module.exports = function(RED) { let topic = msg.topic let payload = msg.payload + let control_mode = context.get("control_mode") || "auto" //auto, on, off + let current_temp = context.get("current_temp") + let target_temp = context.get("target_temp") || 19 + let window_state = context.get("window_state") || "close" //open, close + let window_mode = context.get("window_mode") || "cool" //heat, cool, off + let heater_status = null + debug_text(`W-mode: ${window_mode}`) if (topic === "window_mode_control" && (payload === "cool" || payload === "heat" || payload === "off")) { window_mode = payload