#閾値によって判断する
- センサーからの値など、ある値を超えた際にだけ後続の処理を行わせたい場合があります。
- Node-REDのフローをコピーする方法を参照して、下記のフローをコピペします。
閾値によって判断する
[{"id":"d682710d.e25118","type":"function","z":"ad2e7b14.5fbf","name":"閾値判断","func":"if ( Math.abs(msg.payload) < 3 ) {\n msg = \"\";\n}\nreturn msg;","outputs":1,"noerr":0,"x":340,"y":440,"wires":[["8788bb2e.f1407"]]},{"id":"9cc53fe5.5cf4","type":"debug","z":"ad2e7b14.5fbf","name":"","active":true,"console":"false","complete":"false","x":710,"y":460,"wires":[]},{"id":"2e2bbd21.d66d52","type":"inject","z":"ad2e7b14.5fbf","name":"","topic":"","payload":"1","payloadType":"num","repeat":"","crontab":"","once":false,"x":110,"y":460,"wires":[["d682710d.e25118"]]},{"id":"434d8c3c.dafe2c","type":"inject","z":"ad2e7b14.5fbf","name":"","topic":"","payload":"5","payloadType":"num","repeat":"","crontab":"","once":false,"x":110,"y":500,"wires":[["d682710d.e25118"]]},{"id":"87af1c05.3fd9c8","type":"debug","z":"ad2e7b14.5fbf","name":"","active":true,"console":"false","complete":"true","x":690,"y":400,"wires":[]},{"id":"284a0266.3214ae","type":"inject","z":"ad2e7b14.5fbf","name":"","topic":"","payload":"-1","payloadType":"num","repeat":"","crontab":"","once":false,"x":110,"y":420,"wires":[["d682710d.e25118"]]},{"id":"9e930281.5088f8","type":"inject","z":"ad2e7b14.5fbf","name":"","topic":"","payload":"-5","payloadType":"num","repeat":"","crontab":"","once":false,"x":110,"y":380,"wires":[["d682710d.e25118"]]},{"id":"8788bb2e.f1407","type":"template","z":"ad2e7b14.5fbf","name":"後続のノード","field":"payload","fieldType":"msg","format":"handlebars","syntax":"mustache","template":"後続のノードは実行されました。","x":520,"y":440,"wires":[["9cc53fe5.5cf4","87af1c05.3fd9c8"]]}]
閾値によって判断する
if ( Math.abs(msg.payload) < 3 ) {
msg = "";
}
return msg;