首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >节点-红色Schedex节点

节点-红色Schedex节点
EN

Stack Overflow用户
提问于 2018-11-27 01:59:36
回答 1查看 484关注 0票数 0

我已经多次修改了文档,并按照我的理解进行了修改,但它仍然没有配置我的Schedex节点。Schedex文档提到了两种将配置发送到Schedex节点的方法,第一种方法是在mgs.payload中设置msg.palyload.variable或将所有配置作为一个字符串发送。我将在下面发布两个版本的函数代码。如果您想阅读Schedex的文档,可以在https://www.npmjs.com/package/node-red-contrib-schedex下面找到

代码语言:javascript
复制
    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上

代码语言:javascript
复制
    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;

非常感谢您的帮助

EN

回答 1

Stack Overflow用户

发布于 2018-11-27 20:52:39

在第一个示例中,return之前的最后一行通过将msg.payload对象替换为字符串"'## Programmatic Control"来清除您对该对象所做的所有更改

票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/53486632

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档