javascript - 基于节点红色温度的灯或风扇
问题描述
我正在将传感器中的温度值检索到一个函数中。如何通过拨动开关打开或关闭连接到覆盆子引脚的东西。尝试 if else in function 但它不会返回布尔值。
解决方案
也许这个流程可以帮助你...... :)
[{"id":"b91e3004.20d918","type":"inject","z":"96584deb.e06cd8","name":"temperature = 5","topic":"","payload":"5","payloadType":"num","repeat":"","crontab":"","once":false,"onceDelay":0.1,"x":240,"y":480,"wires":[["8ed1e022.82aef8","90a9aef0.51dda"]]},{"id":"8ed1e022.82aef8","type":"function","z":"96584deb.e06cd8","name":"temp >= 10","func":"\nmsg.payload = (msg.payload >= 10);\n\nreturn msg;","outputs":1,"noerr":0,"x":490,"y":460,"wires":[["b639cd87.885478","e13b38f4.0af918"]]},{"id":"b639cd87.885478","type":"debug","z":"96584deb.e06cd8","name":"","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"false","x":670,"y":440,"wires":[]},{"id":"c44cdc90.fc2388","type":"inject","z":"96584deb.e06cd8","name":"temperature = 20","topic":"","payload":"20","payloadType":"num","repeat":"","crontab":"","once":false,"onceDelay":0.1,"x":240,"y":540,"wires":[["8ed1e022.82aef8","90a9aef0.51dda"]]},{"id":"e13b38f4.0af918","type":"rpi-gpio out","z":"96584deb.e06cd8","name":"","pin":"7","set":"","level":"0","freq":"","out":"out","x":650,"y":480,"wires":[]},{"id":"90a9aef0.51dda","type":"switch","z":"96584deb.e06cd8","name":"temp >= 10","property":"payload","propertyType":"msg","rules":[{"t":"gte","v":"10","vt":"str"},{"t":"lt","v":"10","vt":"str"}],"checkall":"true","repair":false,"outputs":2,"x":490,"y":560,"wires":[["72eff73c.7845b"],["268e12dd.9e100e"]]},{"id":"72eff73c.7845b","type":"template","z":"96584deb.e06cd8","name":"true","field":"payload","fieldType":"msg","format":"handlebars","syntax":"mustache","template":"true","output":"str","x":650,"y":540,"wires":[["28a0b8f8.67062"]]},{"id":"28a0b8f8.67062","type":"rpi-gpio out","z":"96584deb.e06cd8","name":"","pin":"7","set":"","level":"0","freq":"","out":"out","x":790,"y":560,"wires":[]},{"id":"268e12dd.9e100e","type":"template","z":"96584deb.e06cd8","name":"false","field":"payload","fieldType":"msg","format":"handlebars","syntax":"mustache","template":"false","output":"str","x":650,"y":580,"wires":[["28a0b8f8.67062"]]}]
推荐阅读
- protocol-buffers - 为什么 Protobuf.js 不使用 DataView API?
- javascript - 使用 D3.js 更新数据并创建新的图形元素仅在数据数组缩短时才有效
- powershell - Powershell函数返回标准输出?(旧标题:Powershell 追加到数组数组追加标准输出?)
- javascript - 单击按钮浏览后重新加载预览图像
- mysql - 无法解决errno:150“外键约束格式不正确”
- r - 匹配具有多个匹配项的数据帧
- django - Django模型只允许一次
- flutter - 如何启用“constructor-tearoffs”功能?
- javascript - Javascript 导入,它们是否重复?
- javascript - Joining JS array with HTML table