这篇文章介绍一下Inject节点除了手动触发之外的其他方式。
以容器方式启动Node-RED服务,启动命令如下所示:
启动命令:docker run -it -p 1880:1880 -v $PWD/data:/data -e TZ=Asia/Shanghai --name nodered -d nodered/node-red:1.0.4
[{"id":"347308fb.329ec8","type":"inject","z":"73554227.4474dc","name":"Deploy时触发","topic":"Deploy时会被触发","payload":"","payloadType":"date","repeat":"","crontab":"","once":true,"onceDelay":0.1,"x":160,"y":120,"wires":[["bae1bac5.1ad7a8"]]},{"id":"bae1bac5.1ad7a8","type":"debug","z":"73554227.4474dc","name":"显示topic信息","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"topic","targetType":"msg","x":400,"y":120,"wires":[]}]
[{"id":"347308fb.329ec8","type":"inject","z":"73554227.4474dc","name":"每三秒钟触发","topic":"每三秒触发","payload":"","payloadType":"date","repeat":"3","crontab":"","once":false,"onceDelay":0.1,"x":160,"y":120,"wires":[["bae1bac5.1ad7a8"]]},{"id":"bae1bac5.1ad7a8","type":"debug","z":"73554227.4474dc","name":"显示topic信息","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"topic","targetType":"msg","x":400,"y":120,"wires":[]}]
[{"id":"347308fb.329ec8","type":"inject","z":"73554227.4474dc","name":"周日20:02触发","topic":"指定周日20:02触发","payload":"","payloadType":"date","repeat":"","crontab":"02 20 * * 0","once":false,"onceDelay":0.1,"x":160,"y":120,"wires":[["bae1bac5.1ad7a8"]]},{"id":"bae1bac5.1ad7a8","type":"debug","z":"73554227.4474dc","name":"显示topic信息","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"topic","targetType":"msg","x":400,"y":120,"wires":[]}]