场景
Node-RED简介与Windows上安装、启动和运行示例:
Node-RED简介与Windows上安装、启动和运行示例_霸道流氓气质的博客-CSDN博客
Node-RED的switch节点就是条件判断,可以依据条件来传递msg物件至不同的下一个节点。
例如:inject注入0和1,使用switch和change节点来分别输出成ON和OFF
注:
博客:
霸道流氓气质的博客_CSDN博客-C#,架构之路,SpringBoot领域博主
关注公众号
霸道的程序猿
获取编程相关电子书、教程推送与免费下载。
实现
1、switch节点编辑
2、change节点编辑
3、流程转换的json数据
[{"id":"6ef823fa.ff781c","type":"inject","z":"34d4d5aa.c0d0ea","name":"","repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"","payload":"0","payloadType":"str","x":170,"y":80,"wires":[["45345f77.71a5f"]]},{"id":"90976eb6.0bc82","type":"inject","z":"34d4d5aa.c0d0ea","name":"","repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"","payload":"1","payloadType":"str","x":170,"y":180,"wires":[["45345f77.71a5f"]]},{"id":"45345f77.71a5f","type":"switch","z":"34d4d5aa.c0d0ea","name":"On or OFF","property":"payload","propertyType":"msg","rules":[{"t":"eq","v":"0","vt":"str"},{"t":"eq","v":"1","vt":"str"}],"checkall":"true","repair":false,"outputs":2,"x":350,"y":140,"wires":[["60b9f22a.9acb4c"],["8e48a261.b465e"]]},{"id":"aa1452ff.c3ffa","type":"debug","z":"34d4d5aa.c0d0ea","name":"","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"false","x":730,"y":80,"wires":[]},{"id":"de505863.01f448","type":"debug","z":"34d4d5aa.c0d0ea","name":"","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"false","x":710,"y":200,"wires":[]},{"id":"60b9f22a.9acb4c","type":"change","z":"34d4d5aa.c0d0ea","name":"Set to ON","rules":[{"t":"set","p":"payload","pt":"msg","to":"ON","tot":"str"}],"action":"","property":"","from":"","to":"","reg":false,"x":520,"y":100,"wires":[["aa1452ff.c3ffa"]]},{"id":"8e48a261.b465e","type":"change","z":"34d4d5aa.c0d0ea","name":"Set to OFF","rules":[{"t":"set","p":"payload","pt":"msg","to":"OFF","tot":"str"}],"action":"","property":"","from":"","to":"","reg":false,"x":510,"y":200,"wires":[["de505863.01f448"]]}]
版权声明:本文内容由互联网用户自发贡献,该文观点仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 举报,一经查实,本站将立刻删除。
文章由极客之音整理,本文链接:https://www.bmabk.com/index.php/post/136004.html