1
0
mirror of https://github.com/node-red/node-red-nodes.git synced 2023-10-10 13:36:58 +02:00

Fix timeswitch status to show time in timezone set in the properties

and bump library
This commit is contained in:
Dave Conway-Jones 2023-01-19 09:34:28 +00:00
parent 8553dc30f2
commit f7f313c197
No known key found for this signature in database
GPG Key ID: 88BA2B8A411BE9FF
2 changed files with 11 additions and 8 deletions

View File

@ -1,9 +1,9 @@
{
"name" : "node-red-node-timeswitch",
"version" : "0.2.2",
"version" : "1.0.0",
"description" : "A Node-RED node to provide a simple timeswitch to schedule daily on/off events.",
"dependencies" : {
"spacetime": "^6.16.3",
"spacetime": "^7.4.0",
"suncalc": "^1.8.0"
},
"repository" : {

View File

@ -23,7 +23,7 @@ module.exports = function (RED) {
this.thu = n.thu;
this.fri = n.fri;
this.sat = n.sat;
this.jan = n.jan;
this.feb = n.feb;
this.mar = n.mar;
@ -123,17 +123,20 @@ module.exports = function (RED) {
// handler function for the node payload, called below
let sendPayload = (payload, nextTime) => {
// var o = nextTime.goto(selectedTimeZone.name).offset()/60;
// if (o > 0) { o = "+" + o; }
// else {o = "-" + o; }
if (payload == 1) {
node.status({
fill: "yellow",
shape: "dot",
text: `on until ${nextTime.format("time")}`
text: `on until ${nextTime.goto(selectedTimeZone.name).format("time-24")}`
});
} else {
node.status({
fill: "blue",
shape: "dot",
text: `off until ${nextTime.format("time")}`
text: `off until ${nextTime.goto(selectedTimeZone.name).format("time-24")}`
});
}
var msg = {};
@ -157,9 +160,9 @@ module.exports = function (RED) {
case 6 : { if (!node.sat) { proceed &= false; } break; }
}
if (!proceed) {
sendPayload(0, selectedOnTime);
return;
if (!proceed) {
sendPayload(0, selectedOnTime);
return;
}
// if this month is not among the selected months, stop here