diff --git a/time/timeswitch/package.json b/time/timeswitch/package.json index 6c86697c..5bc07d1d 100644 --- a/time/timeswitch/package.json +++ b/time/timeswitch/package.json @@ -1,6 +1,6 @@ { "name" : "node-red-node-timeswitch", - "version" : "0.2.0", + "version" : "0.2.1", "description" : "A Node-RED node to provide a simple timeswitch to schedule daily on/off events.", "dependencies" : { "spacetime": "^6.16.3", diff --git a/time/timeswitch/timeswitch.js b/time/timeswitch/timeswitch.js index 87802a8e..28adb4f6 100644 --- a/time/timeswitch/timeswitch.js +++ b/time/timeswitch/timeswitch.js @@ -51,6 +51,7 @@ module.exports = function(RED) { var today = Math.round((nowMillis - midnightMillis) / 60000) % 1440; var starttime = Number(node.startt); var endtime = Number(node.endt); + var tzOff = (new Date()).getTimezoneOffset(); if ((starttime >= 5000) || (endtime == 5000) || (endtime == 6000)) { var times = SunCalc.getTimes(now, node.lat, node.lon); @@ -109,13 +110,11 @@ module.exports = function(RED) { } if (proceed >= 2) { - var duration = newendtime - today; - if (today > newendtime) { duration += 1440; } - //node.status({fill:"yellow",shape:"dot",text:"on for " + duration + " mins"}); - node.status({fill:"yellow", shape:"dot", text:"on until " + parseInt(newendtime / 60) + ":" + ("0" + newendtime % 60).substr(-2)}); + node.status({fill:"yellow", shape:"dot", text:"on until " + parseInt((newendtime -tzOff) / 60) + ":" + ("0" + (newendtime - tzOff) % 60).substr(-2)}); + } + else { + node.status({fill:"blue", shape:"dot", text:"off until " + parseInt((starttime - tzOff) / 60) + ":" + ("0" + (starttime - tzOff) % 60).substr(-2)}); } - //else { node.status({fill:"blue",shape:"dot",text:"off"}); } - else { node.status({fill:"blue", shape:"dot", text:"off until " + parseInt(starttime / 60) + ":" + ("0" + starttime % 60).substr(-2)}); } var msg = {}; if (node.mytopic) { msg.topic = node.mytopic; }