From 74f15fe9c36a44e6f5ee73840db568990659a371 Mon Sep 17 00:00:00 2001 From: vvzvlad Date: Thu, 5 Oct 2023 23:29:05 +0300 Subject: [PATCH] Bump version to 0.2.12 --- package.json | 2 +- thermostat.js | 13 +++++++------ 2 files changed, 8 insertions(+), 7 deletions(-) diff --git a/package.json b/package.json index ac9f552..8e96d73 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "@vvzvlad/node-red-contrib-rn-combined-nodes", - "version": "0.2.11", + "version": "0.2.12", "description": "", "main": "index.js", "keywords": [ diff --git a/thermostat.js b/thermostat.js index 7da1a24..d7bd146 100644 --- a/thermostat.js +++ b/thermostat.js @@ -11,15 +11,15 @@ module.exports = function(RED) { const HEAT_OFF_THRESHOLD = 0.2 let debug = "" - let pwm_timer = null - context.set("pwm_period", 10000) //30*60*1000) - context.set("pwm_tick", 1000) + let pwm_timer = null; + context.set("pwm_period", 10000); // 10 секунд + context.set("pwm_tick", 1000); // 1 секунда function manage_pwm(duty_cycle_percent) { if (duty_cycle_percent === -1) { if (pwm_timer !== null) { - clearInterval(pwm_timer) - pwm_timer = null + clearInterval(pwm_timer); + pwm_timer = null; } return; } @@ -34,7 +34,7 @@ module.exports = function(RED) { pwm_timer = setInterval(() => { const pwm_period = context.get("pwm_period"); const elapsed_time = Date.now() - cycle_start_time; - const on_time = pwm_period * pwm_duty_cycle; + const on_time = pwm_period * context.get("pwm_duty_cycle"); if (elapsed_time >= pwm_period) { cycle_start_time = Date.now(); @@ -50,6 +50,7 @@ module.exports = function(RED) { } } + function debug_text(text) { if (text === "return_debug") { let debug_tmp = debug