Learning to understand Node-red Flows

Topics (not sure which fora)
when not sure where to post, post here and mods will move it to right forum.

Moderators: leecollings, remb0

Post Reply
Derik
Posts: 1605
Joined: Friday 18 October 2013 23:33
Target OS: Raspberry Pi / ODroid
Domoticz version: BETA
Location: Arnhem/Nijmegen Nederland
Contact:

Learning to understand Node-red Flows

Post by Derik »

..Like the head says....

Hope there are some pro's that can help to learn domoticz with Node red.
Step by step make simple flows to understand how to use them.

For me myself is nr higher math..
And i use other flows to check some options and try then.

So i hope when i you post here a flow there are some people that can help:-)

My simple flow.
Try to get pressure and wifi from a device

Code: Select all

[{"id":"92af773.5fabe88","type":"tab","label":"Uitlees z2m","disabled":false,"info":""},{"id":"28f69e95.240e02","type":"mqtt in","z":"92af773.5fabe88","name":"","topic":"zigbee2mqtt/ZBXA: Woonkamer","qos":"2","datatype":"json","broker":"76a2f7d0.ff3b38","x":190,"y":180,"wires":[["2cffad2e.910f72","68547aa4.2b5c84"]]},{"id":"2cffad2e.910f72","type":"debug","z":"92af773.5fabe88","name":"","active":false,"tosidebar":true,"console":false,"tostatus":false,"complete":"false","x":270,"y":120,"wires":[]},{"id":"27e56c48.b0d674","type":"mqtt out","z":"92af773.5fabe88","name":"Domoticz In","topic":"domoticz/in","qos":"0","retain":"false","broker":"6ec8bbd8.1dc814","x":1130,"y":180,"wires":[]},{"id":"50eabbae.8004b4","type":"function","z":"92af773.5fabe88","name":"idx\":13592 druk and pressure","func":"msg.payload = {\"command\":\"udevice\",\"idx\":13592,\"nvalue\":0,\"svalue\":\"pressure\".toString()};\nreturn msg;","outputs":1,"noerr":0,"x":880,"y":180,"wires":[["27e56c48.b0d674","7391975b.b9fa78"]]},{"id":"7391975b.b9fa78","type":"debug","z":"92af773.5fabe88","name":"","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"false","x":810,"y":120,"wires":[]},{"id":"68547aa4.2b5c84","type":"function","z":"92af773.5fabe88","name":"add pressure","func":"msg.src = 'pressure';\n\nreturn msg;","outputs":1,"noerr":0,"x":490,"y":180,"wires":[["f7c57f5.e8f1f8","50eabbae.8004b4"]]},{"id":"f7c57f5.e8f1f8","type":"debug","z":"92af773.5fabe88","name":"","active":false,"tosidebar":true,"console":false,"tostatus":false,"complete":"false","x":510,"y":120,"wires":[]},{"id":"2eb3041f.2d2e5c","type":"mqtt in","z":"92af773.5fabe88","name":"","topic":"zigbee2mqtt/ZBXA: Woonkamer","qos":"2","datatype":"json","broker":"76a2f7d0.ff3b38","x":190,"y":420,"wires":[["5a397e50.105c6","7643e676.b13d78"]]},{"id":"5a397e50.105c6","type":"debug","z":"92af773.5fabe88","name":"","active":false,"tosidebar":true,"console":false,"tostatus":false,"complete":"false","x":230,"y":360,"wires":[]},{"id":"e155d52b.ddd478","type":"mqtt out","z":"92af773.5fabe88","name":"Domoticz In","topic":"domoticz/in","qos":"1","retain":"true","broker":"6ec8bbd8.1dc814","x":1110,"y":420,"wires":[]},{"id":"2c68e92e.dbd696","type":"function","z":"92af773.5fabe88","name":"idx\":13605 custom sensor","func":"msg.payload = {\"command\":\"udevice\",\"idx\":13605,\"nvalue\":0,\"svalue\":\"linkquality\".toString()};\nreturn msg;","outputs":1,"noerr":0,"x":870,"y":420,"wires":[["e155d52b.ddd478","6138e958.aa2ea8"]]},{"id":"6138e958.aa2ea8","type":"debug","z":"92af773.5fabe88","name":"","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"false","x":870,"y":360,"wires":[]},{"id":"7643e676.b13d78","type":"function","z":"92af773.5fabe88","name":"ad Link","func":"msg.src = 'linkquality';\nreturn msg;","outputs":1,"noerr":0,"x":520,"y":420,"wires":[["4cf428b7.d16448","2c68e92e.dbd696"]]},{"id":"4cf428b7.d16448","type":"debug","z":"92af773.5fabe88","name":"","active":false,"tosidebar":true,"console":false,"tostatus":false,"complete":"false","x":510,"y":360,"wires":[]},{"id":"76a2f7d0.ff3b38","type":"mqtt-broker","broker":"127.0.0.1","port":"1883","clientid":"","usetls":false,"verifyservercert":true,"compatmode":true,"keepalive":15,"cleansession":true,"birthQos":"0","willQos":"0"},{"id":"6ec8bbd8.1dc814","type":"mqtt-broker","z":"","name":"","broker":"127.0.0.1","port":"1883","clientid":"","usetls":false,"verifyservercert":true,"compatmode":true,"keepalive":"60","cleansession":true,"birthTopic":"","birthQos":"0","birthPayload":"","closeTopic":"","closePayload":"","willTopic":"","willQos":"0","willPayload":""}]
And the output.
ScreenShot303.png
Xu4: Beta Extreme antenna RFXcomE,WU Fi Ping ip P1 Gen5 PVOutput Harmony HUE SolarmanPv OTG Winddelen Alive ESP Buienradar MySensors WOL Winddelen counting RPi: Beta SMAspot RFlinkTest Domoticz ...Different backups
User avatar
FireWizard
Posts: 1968
Joined: Tuesday 25 December 2018 12:11
Target OS: Raspberry Pi / ODroid
Domoticz version: Beta
Location: Voorthuizen (NL)
Contact:

Re: Learning to understand Node-red Flows

Post by FireWizard »

Hello @Derik,

This flow is similar as the calculation of the DewPoint in a previous thread.

Look to the picture, you posted in that flow.

Screenshot_dewpoint6.png
Screenshot_dewpoint6.png (66.09 KiB) Viewed 593 times

You see at the left the topic in bold: ZBXA: Woonkamer followed by the payload.
The same msg.payload you see at the right.

And why again a Function node with:
msg.src = 'pressure';

return msg;
Useless and it has no function here.

Test the following flow:

Code: Select all

[{"id":"cb61fe19.f0cc4","type":"mqtt in","z":"d8edc6f8.4eedb8","name":"","topic":"zigbee2mqtt/ZBXA: Woonkamer","qos":"2","datatype":"json","broker":"224916c5.a10cd2","x":190,"y":180,"wires":[["23075d17.5f65c2","ca738ef6.fd37d"]]},{"id":"23075d17.5f65c2","type":"debug","z":"d8edc6f8.4eedb8","name":"","active":false,"tosidebar":true,"console":false,"tostatus":false,"complete":"false","x":230,"y":120,"wires":[]},{"id":"83427af8.113f98","type":"mqtt out","z":"d8edc6f8.4eedb8","name":"Domoticz In","topic":"domoticz/in","qos":"0","retain":"false","broker":"ce220aab.627fc8","x":770,"y":180,"wires":[]},{"id":"ca738ef6.fd37d","type":"function","z":"d8edc6f8.4eedb8","name":"idx\":13592 druk and pressure","func":"msg.payload = {\"command\":\"udevice\",\"idx\":13592,\"nvalue\":0,\"svalue\":msg.payload.pressure.toString()};\nreturn msg;","outputs":1,"noerr":0,"x":510,"y":180,"wires":[["83427af8.113f98","c1f963a9.6c3a48"]]},{"id":"c1f963a9.6c3a48","type":"debug","z":"d8edc6f8.4eedb8","name":"","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"false","x":550,"y":120,"wires":[]},{"id":"2e0f29c4.55673e","type":"mqtt in","z":"d8edc6f8.4eedb8","name":"","topic":"zigbee2mqtt/ZBXA: Woonkamer","qos":"2","datatype":"json","broker":"224916c5.a10cd2","x":190,"y":420,"wires":[["5da60a66.8c8ba4","608d39a9.13f5d8"]]},{"id":"5da60a66.8c8ba4","type":"debug","z":"d8edc6f8.4eedb8","name":"","active":false,"tosidebar":true,"console":false,"tostatus":false,"complete":"false","x":230,"y":360,"wires":[]},{"id":"9b6e38d.7d0d148","type":"mqtt out","z":"d8edc6f8.4eedb8","name":"Domoticz In","topic":"domoticz/in","qos":"1","retain":"true","broker":"ce220aab.627fc8","x":742,"y":420,"wires":[]},{"id":"608d39a9.13f5d8","type":"function","z":"d8edc6f8.4eedb8","name":"idx\":13605 custom sensor","func":"msg.payload = {\"command\":\"udevice\",\"idx\":13605,\"nvalue\":0,\"svalue\":msg.payload.linkquality.toString()};\nreturn msg;","outputs":1,"noerr":0,"x":502,"y":420,"wires":[["9b6e38d.7d0d148","8f5f5b6b.8194c8"]]},{"id":"8f5f5b6b.8194c8","type":"debug","z":"d8edc6f8.4eedb8","name":"","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"false","x":530,"y":360,"wires":[]},{"id":"224916c5.a10cd2","type":"mqtt-broker","broker":"127.0.0.1","port":"1883","clientid":"","usetls":false,"verifyservercert":true,"compatmode":true,"keepalive":15,"cleansession":true,"birthQos":"0","willQos":"0"},{"id":"ce220aab.627fc8","type":"mqtt-broker","z":"","name":"","broker":"127.0.0.1","port":"1883","clientid":"","usetls":false,"verifyservercert":true,"compatmode":true,"keepalive":"60","cleansession":true,"birthTopic":"","birthQos":"0","birthPayload":"","closeTopic":"","closePayload":"","willTopic":"","willQos":"0","willPayload":""}]
Regards
Post Reply

Who is online

Users browsing this forum: No registered users and 1 guest