我已经多次修改了文档,并按照我的理解进行了修改,但它仍然没有配置我的Schedex节点。Schedex文档提到了两种将配置发送到Schedex节点的方法,第一种方法是在mgs.payload中设置msg.palyload.variable或将所有配置作为一个字符串发送。我将在下面发布两个版本的函数代码。如果您想阅读Schedex的文档,可以在https://www.npmjs.com/package/node-red-contrib-schedex下面找到
msgTemp = msg.payload;
time = msgTemp / 1000;
// calculates hour from seconds input
h = Math.floor(time / 3600);
// calculates minutes from remainder
m = Math.floor(time % 3600 / 60);
// ontime formatted for Schedex standards
ontime = ('0' + h).slice(-2) + ":" + ('0' + m).slice(-2);
//setting ontime
msg.payload.ontime = ontime;
//setting onpayload
msg.payload.onpayload = "1";
//enabling schedule for every time of the week
msg.payload.mon = true;
msg.payload.tue = true;
msg.payload.wed = true;
msg.payload.thu = true;
msg.payload.fri = true;
msg.payload.sat = true;
msg.payload.sun = true;
//the documentations mentions that to set the variables from the ui
//it has to be in programmatic control, I have put this in the
//payload and it's not working.
//i think my issue is with the line below but i can't figure it out
msg.payload = "'## Programmatic Control";
return msg;下面是另一个版本,其中所有配置都以一个字符串的形式存储在msg.payload上
msgTemp = msg.payload;
time = msgTemp / 1000;
// calculates hour from seconds input
h = Math.floor(time / 3600);
// calculates minutes from remainder
m = Math.floor(time % 3600 / 60);
ontime = "onetime " + ('0' + h).slice(-2) + ":" + ('0' + m).slice(-2)
+ " ";
onpayload = "onpayload 1 ";
mon = "mon true ";
tue = "tue true ";
wed = "wed true ";
thu = "thu true ";
fri = "fri true ";
sat = "sat true ";
sun = "sun true ";
msg.payload = ontime + onpayload + mon + tue + wed + thu + fri + sat
+ sun;
return msg;非常感谢您的帮助
发布于 2018-11-27 20:52:39
在第一个示例中,return之前的最后一行通过将msg.payload对象替换为字符串"'## Programmatic Control"来清除您对该对象所做的所有更改
https://stackoverflow.com/questions/53486632
复制相似问题