2020年12月4日 星期五

Using the rbe (report by exception) node & Scaling input with the range node

Using the rbe (report by exception) node & Scaling input with the range node

To test the flow, deploy this flow and then return to the HiveMQ page and send a series of messages. Firstly, you’ll need to set the analyze value to true so that the switch node sends through a message on output 1. If you use the original message value of 6, this will fail to pass the rbe node. If you then send a second message of value 10, the  rbe node  will evaluate the difference between 6 and 10, see it is greater than 20%, and send on a message to the final debug node


{"analyze": true , "value": 10 }

{"analyze": true , "value":  5 }

5 , 10  greater than 20%,







Let’s assume you want to scale your value (originally in the range 0-10) to a range (0-255) when you aren’t doing any analysis. This means we are dealing with the lower part of the flow fired when the switch node evaluates the Analyze property as false.

Then return to the HiveMQ test page and post {“analyze”:false, “value”:10} as a new MQTT message to the same topic.


{"analyze": false , "value": 10 }

{"analyze": false , "value":  5 }








[{"id":"995c991a.566ba8","type":"mqtt in","z":"2b3214e5.a3a7cc","name":"","topic":"alex9ufo/sensor1/outTopic","qos":"2","datatype":"auto","broker":"e4d9b72d.d14398","x":330,"y":320,"wires":[["ba25f21f.ffa71","d25fff9a.fa3ac"]]},{"id":"ba25f21f.ffa71","type":"json","z":"2b3214e5.a3a7cc","name":"","property":"payload","action":"","pretty":false,"x":530,"y":160,"wires":[["9660236a.9c53d","1d645c6b.ebe424","aecc5427.7bfa98"]]},{"id":"9660236a.9c53d","type":"debug","z":"2b3214e5.a3a7cc","name":"","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"payload","targetType":"msg","statusVal":"","statusType":"auto","x":730,"y":100,"wires":[]},{"id":"f55b4a38.72baf8","type":"mqtt out","z":"2b3214e5.a3a7cc","name":"","topic":"alex9ufo/sensor2/inTopic","qos":"1","retain":"","broker":"e4d9b72d.d14398","x":790,"y":640,"wires":[]},{"id":"1175a0c6.d4ca9f","type":"function","z":"2b3214e5.a3a7cc","name":"","func":"var outstr={\"analyze\": true ,\"value\":50};\nmsg.payload= outstr;\nreturn msg;","outputs":1,"noerr":0,"initialize":"","finalize":"","x":470,"y":640,"wires":[["4582efd.f2bb31"]]},{"id":"4582efd.f2bb31","type":"json","z":"2b3214e5.a3a7cc","name":"","property":"payload","action":"","pretty":false,"x":590,"y":640,"wires":[["f55b4a38.72baf8","3fb07ae9.09b6b6"]]},{"id":"19c954a9.3f835b","type":"inject","z":"2b3214e5.a3a7cc","name":"","props":[{"p":"payload"},{"p":"topic","vt":"str"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"","payload":"","payloadType":"date","x":330,"y":640,"wires":[["1175a0c6.d4ca9f"]]},{"id":"3fb07ae9.09b6b6","type":"debug","z":"2b3214e5.a3a7cc","name":"","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"false","statusVal":"","statusType":"auto","x":750,"y":700,"wires":[]},{"id":"fc8bf9ea.d0bde8","type":"switch","z":"2b3214e5.a3a7cc","name":"","property":"payload","propertyType":"msg","rules":[{"t":"true"},{"t":"false"}],"checkall":"true","repair":false,"outputs":2,"x":690,"y":220,"wires":[["7ae78527.7c838c","9a089abc.740618"],["3f794d9.0b3f8b2","70c4abed.4d5cd4"]]},{"id":"7ae78527.7c838c","type":"debug","z":"2b3214e5.a3a7cc","name":"","active":true,"console":"false","complete":"false","x":990,"y":200,"wires":[]},{"id":"3f794d9.0b3f8b2","type":"debug","z":"2b3214e5.a3a7cc","name":"","active":true,"tosidebar":true,"console":false,"complete":"false","statusVal":"","statusType":"auto","x":990,"y":240,"wires":[]},{"id":"9a089abc.740618","type":"ui_led","z":"2b3214e5.a3a7cc","group":"57fb2f24.9f1f1","order":11,"width":"0","height":"0","label":"LED1","labelPlacement":"left","labelAlignment":"right","colorForValue":[{"color":"red","value":"false","valueType":"bool"},{"color":"green","value":"true","valueType":"bool"}],"allowColorForValueInMessage":false,"name":"","x":850,"y":180,"wires":[]},{"id":"70c4abed.4d5cd4","type":"ui_led","z":"2b3214e5.a3a7cc","group":"57fb2f24.9f1f1","order":12,"width":"0","height":"0","label":"LED2","labelPlacement":"left","labelAlignment":"right","colorForValue":[{"color":"red","value":"false","valueType":"bool"},{"color":"green","value":"true","valueType":"bool"}],"allowColorForValueInMessage":false,"name":"","x":850,"y":260,"wires":[]},{"id":"fee116dd.9f9388","type":"ui_gauge","z":"2b3214e5.a3a7cc","name":"","group":"57fb2f24.9f1f1","order":13,"width":0,"height":0,"gtype":"gage","title":"gauge","label":"units","format":"{{value}}","min":0,"max":"100","colors":["#00b500","#e6e600","#ca3838"],"seg1":"35","seg2":"75","x":830,"y":140,"wires":[]},{"id":"1d645c6b.ebe424","type":"function","z":"2b3214e5.a3a7cc","name":"","func":"msg.payload=msg.payload.value;\nreturn msg;","outputs":1,"noerr":0,"initialize":"","finalize":"","x":710,"y":140,"wires":[["fee116dd.9f9388"]]},{"id":"aecc5427.7bfa98","type":"function","z":"2b3214e5.a3a7cc","name":"","func":"msg.payload=msg.payload.analyze;\nreturn msg;\n","outputs":1,"noerr":0,"initialize":"","finalize":"","x":570,"y":220,"wires":[["fc8bf9ea.d0bde8"]]},{"id":"6b427479.ba4efc","type":"debug","z":"2b3214e5.a3a7cc","name":"","active":true,"console":"false","complete":"payload","x":970,"y":380,"wires":[]},{"id":"747bc901.5c0a18","type":"switch","z":"2b3214e5.a3a7cc","name":"","property":"payload.analyze","rules":[{"t":"true"},{"t":"false"}],"checkall":"true","outputs":2,"x":490,"y":380,"wires":[["48c37be1.39b3a4"],["b70e8a30.940338","59a38158.dba48"]]},{"id":"d25fff9a.fa3ac","type":"json","z":"2b3214e5.a3a7cc","name":"","x":370,"y":380,"wires":[["747bc901.5c0a18"]]},{"id":"dc82faf5.70bb98","type":"comment","z":"2b3214e5.a3a7cc","name":"Analyze = true","info":"","x":630,"y":320,"wires":[]},{"id":"6b1cc2cc.18652c","type":"comment","z":"2b3214e5.a3a7cc","name":"Analyze = false","info":"","x":660,"y":540,"wires":[]},{"id":"d39edec8.2ddb6","type":"rbe","z":"2b3214e5.a3a7cc","name":"rbe","func":"deadband","gap":"20%","start":"","inout":"out","property":"payload","x":830,"y":380,"wires":[["6b427479.ba4efc"]]},{"id":"48c37be1.39b3a4","type":"change","z":"2b3214e5.a3a7cc","name":"","rules":[{"t":"set","p":"payload","to":"payload.value","tot":"msg"}],"action":"","property":"","from":"","to":"","reg":false,"x":670,"y":380,"wires":[["d39edec8.2ddb6"]]},{"id":"bd7a244c.921f88","type":"range","z":"2b3214e5.a3a7cc","minin":"0","maxin":"10","minout":"0","maxout":"255","action":"clamp","round":false,"property":"payload","name":"","x":840,"y":500,"wires":[["f688d424.ab7db8"]]},{"id":"59a38158.dba48","type":"change","z":"2b3214e5.a3a7cc","name":"","rules":[{"t":"set","p":"payload","to":"payload.value","tot":"msg"}],"action":"","property":"","from":"","to":"","reg":false,"x":670,"y":500,"wires":[["bd7a244c.921f88"]]},{"id":"f688d424.ab7db8","type":"debug","z":"2b3214e5.a3a7cc","name":"","active":true,"console":"false","complete":"false","x":990,"y":500,"wires":[]},{"id":"b70e8a30.940338","type":"change","z":"2b3214e5.a3a7cc","name":"","rules":[{"t":"set","p":"payload.note","to":"this is not being analysed"}],"action":"","property":"","from":"","to":"","reg":false,"x":680,"y":440,"wires":[["a635a98.bfe5758"]]},{"id":"a635a98.bfe5758","type":"debug","z":"2b3214e5.a3a7cc","name":"","active":true,"console":"false","complete":"false","x":870,"y":440,"wires":[]},{"id":"e4d9b72d.d14398","type":"mqtt-broker","z":"","name":"","broker":"broker.mqtt-dashboard.com","port":"1883","clientid":"","usetls":false,"compatmode":true,"keepalive":"15","cleansession":true,"birthTopic":"","birthQos":"0","birthPayload":"","closeTopic":"","closePayload":"","willTopic":"","willQos":"0","willPayload":""},{"id":"57fb2f24.9f1f1","type":"ui_group","z":"","name":"ON OFF 1","tab":"6f605bb4.60a174","order":1,"disp":true,"width":"6","collapse":false},{"id":"6f605bb4.60a174","type":"ui_tab","z":"","name":"Home","icon":"dashboard"}]

沒有留言:

張貼留言

2024_09 作業3 以Node-Red 為主

 2024_09 作業3  (以Node-Red 為主  Arduino 可能需要配合修改 ) Arduino 可能需要修改的部分 1)mqtt broker  2) 主題Topic (發行 接收) 3) WIFI ssid , password const char br...