Need help combining flows

Hi I just start with node red. What I want is basically to combie the result of two flows in one string.
My Flow is here. Joined val does not output anything

[{"id":"6642db4d.a294f4","type":"tab","label":"Flow 2","disabled":false,"info":""},{"id":"58c50cd5.3a2584","type":"html","z":"6642db4d.a294f4","name":"Lra ffb covid zahlen","property":"payload","outproperty":"payload","tag":".contenttable li","ret":"text","as":"multi","x":190,"y":320,"wires":[["38468fac.0db4e","2f30e56e.1c5c2a"]]},{"id":"5b418e99.f9c01","type":"http request","z":"6642db4d.a294f4","name":"","method":"GET","ret":"txt","paytoqs":"ignore","url":"https://www.lra-ffb.de/aktuelles/corona-informationen/corona-statistik-infizierte-genesene-verstorbene-und-geimpfte-im-landkreis","tls":"","persist":false,"proxy":"","authType":"","x":150,"y":240,"wires":[["58c50cd5.3a2584"]]},{"id":"c2d4e182.ddef5","type":"inject","z":"6642db4d.a294f4","name":"","props":[{"p":"payload"},{"p":"topic","vt":"str"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"","payload":"","payloadType":"date","x":100,"y":160,"wires":[["5b418e99.f9c01"]]},{"id":"2f30e56e.1c5c2a","type":"change","z":"6642db4d.a294f4","name":"cov val","rules":[{"t":"set","p":"cov_val","pt":"msg","to":"$split(payload,\": \")[1]","tot":"jsonata"}],"action":"","property":"","from":"","to":"","reg":false,"x":420,"y":380,"wires":[["a12ef084.f558e"]]},{"id":"38468fac.0db4e","type":"change","z":"6642db4d.a294f4","name":"cov date","rules":[{"t":"set","p":"topic","pt":"msg","to":"$split(payload,\": \")[0]","tot":"jsonata"}],"action":"","property":"","from":"","to":"","reg":false,"x":420,"y":300,"wires":[["4a3d55b6.fbce2c"]]},{"id":"a958977c.b49378","type":"join","z":"6642db4d.a294f4","name":"joined date","mode":"custom","build":"string","property":"cov_date","propertyType":"msg","key":"topic","joiner":",","joinerType":"str","accumulate":false,"timeout":"","count":"","reduceRight":false,"reduceExp":"","reduceInit":"","reduceInitType":"","reduceFixup":"","x":830,"y":300,"wires":[["d1f1ec75.f287d"]]},{"id":"4a3d55b6.fbce2c","type":"change","z":"6642db4d.a294f4","name":"","rules":[{"t":"set","p":"cov_date","pt":"msg","to":"\"'\"&topic&\"'\"","tot":"jsonata"}],"action":"","property":"","from":"","to":"","reg":false,"x":620,"y":300,"wires":[["a958977c.b49378"]]},{"id":"a12ef084.f558e","type":"change","z":"6642db4d.a294f4","name":"","rules":[{"t":"change","p":"cov_val","pt":"msg","from":",","fromt":"str","to":".","tot":"str"}],"action":"","property":"","from":"","to":"","reg":false,"x":620,"y":380,"wires":[["31714c84.2b5f04"]]},{"id":"d1f1ec75.f287d","type":"change","z":"6642db4d.a294f4","name":"","rules":[{"t":"set","p":"payload","pt":"msg","to":"\"https://quickchart.io/chart?c={type:'bar',data:{labels:[\"&cov_date&\"}}}], datasets:[{label:'Covid',data:[\"&cov_val&\"]}]}}\"","tot":"jsonata"}],"action":"","property":"","from":"","to":"","reg":false,"x":1030,"y":300,"wires":[["bcee2d94.c9c4"]]},{"id":"31714c84.2b5f04","type":"join","z":"6642db4d.a294f4","name":"joined val","mode":"custom","build":"string","property":"cov_val","propertyType":"msg","key":"topic","joiner":",","joinerType":"str","accumulate":false,"timeout":"","count":"","reduceRight":false,"reduceExp":"","reduceInit":"","reduceInitType":"","reduceFixup":"","x":820,"y":380,"wires":[["bcee2d94.c9c4","47dc034f.71cbdc"]]},{"id":"47dc034f.71cbdc","type":"debug","z":"6642db4d.a294f4","name":"","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"cov_val","targetType":"msg","statusVal":"","statusType":"auto","x":1260,"y":440,"wires":[]},{"id":"bcee2d94.c9c4","type":"change","z":"6642db4d.a294f4","name":"","rules":[{"t":"set","p":"payload","pt":"msg","to":"\"blabla?c={type:'bar',data:{labels:[\"&cov_date&\"}}}], datasets:[{label:'Covid',data:[\"&cov_val&\"]}]}}\"","tot":"jsonata"}],"action":"","property":"","from":"","to":"","reg":false,"x":1250,"y":360,"wires":[[]]}]

I suspect you do not understand a few concepts.

  1. Join node is used to join 2 or more flows of messages
    see this: https://www.youtube.com/results?search_query=node-red+join+two+payloads

  2. In your case, the only reason to join is because you split (branched off) the flow
    image

the better solution is just do this all in series e.g...

I recommend watching this playlist: Node-RED Essentials. The videos are done by the developers of node-red. They're nice & short and to the point. You will understand a whole lot more in about 1 hour. A small investment for a lot of gain.

But the html extraction leads to a sequence. I have to combine the sequence at some point in the flow

what sequence?

The flow you posted is 100% possible to do without splitting and joining.

You need to watch the videos - especially the first link - you will see how you wrongly placed the join node.

watched the video and putted all one after the other. But the problem remains: I get single values and need to concatenate them to one string. But for two cases. I did it again, but same problem

[{"id":"6642db4d.a294f4","type":"tab","label":"Flow 2","disabled":false,"info":""},{"id":"58c50cd5.3a2584","type":"html","z":"6642db4d.a294f4","name":"Lra ffb covid zahlen","property":"payload","outproperty":"payload","tag":".contenttable li","ret":"text","as":"multi","x":190,"y":320,"wires":[["38468fac.0db4e"]]},{"id":"5b418e99.f9c01","type":"http request","z":"6642db4d.a294f4","name":"","method":"GET","ret":"txt","paytoqs":"ignore","url":"https://www.lra-ffb.de/aktuelles/corona-informationen/corona-statistik-infizierte-genesene-verstorbene-und-geimpfte-im-landkreis","tls":"","persist":false,"proxy":"","authType":"","x":150,"y":240,"wires":[["58c50cd5.3a2584"]]},{"id":"c2d4e182.ddef5","type":"inject","z":"6642db4d.a294f4","name":"","props":[{"p":"payload"},{"p":"topic","vt":"str"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"","payload":"","payloadType":"date","x":100,"y":160,"wires":[["5b418e99.f9c01"]]},{"id":"2f30e56e.1c5c2a","type":"change","z":"6642db4d.a294f4","name":"cov val","rules":[{"t":"set","p":"cov_val","pt":"msg","to":"$replace($split(payload,\": \")[1], \",\",\".\")","tot":"jsonata"}],"action":"","property":"","from":"","to":"","reg":false,"x":180,"y":500,"wires":[["df2496db.96ff38"]]},{"id":"38468fac.0db4e","type":"change","z":"6642db4d.a294f4","name":"cov date","rules":[{"t":"set","p":"cov_date","pt":"msg","to":"\"'\"&$split(payload,\": \")[0]&\"'\"","tot":"jsonata"}],"action":"","property":"","from":"","to":"","reg":false,"x":180,"y":400,"wires":[["2f30e56e.1c5c2a"]]},{"id":"df2496db.96ff38","type":"join","z":"6642db4d.a294f4","name":"","mode":"custom","build":"string","property":"cov_date","propertyType":"msg","key":"topic","joiner":",","joinerType":"str","accumulate":false,"timeout":"","count":"","reduceRight":false,"reduceExp":"","reduceInit":"","reduceInitType":"","reduceFixup":"","x":170,"y":600,"wires":[["4755be7e.d119e"]]},{"id":"4755be7e.d119e","type":"join","z":"6642db4d.a294f4","name":"","mode":"custom","build":"string","property":"cov_val","propertyType":"msg","key":"topic","joiner":"\\n","joinerType":"str","accumulate":false,"timeout":"","count":"","reduceRight":false,"reduceExp":"","reduceInit":"","reduceInitType":"","reduceFixup":"","x":170,"y":660,"wires":[["308754b1.56877c"]]},{"id":"308754b1.56877c","type":"debug","z":"6642db4d.a294f4","name":"","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"cov_val","targetType":"msg","statusVal":"","statusType":"auto","x":330,"y":720,"wires":[]}]

I get this with a simple python script in minutes. In nodered I spend one day.

it comes with experience.

First things first...


↑ you need to re-watch this: https://www.youtube.com/results?search_query=node-red+join+two+payloads

On to your issues...

So it looks like you are going about this the very hard way - trying to parse a JSON payload with JSONata.

Lets look at this from another way.

I assume you want the time and value split from the table in that page. something like this...

So instead of spitting out a single text item per li we chose to set the HTML node to sent a single array with all values in the loop it and extract the data from the JS array...

image

[{"id":"44d40b20.3fd414","type":"html","z":"2680e2cc.e6dace","name":"Lra ffb covid zahlen","property":"payload","outproperty":"payload","tag":".contenttable li","ret":"text","as":"single","x":930,"y":200,"wires":[["afa2412a.6551b"]]},{"id":"58e5da76.091f54","type":"http request","z":"2680e2cc.e6dace","name":"","method":"GET","ret":"txt","paytoqs":"ignore","url":"https://www.lra-ffb.de/aktuelles/corona-informationen/corona-statistik-infizierte-genesene-verstorbene-und-geimpfte-im-landkreis","tls":"","persist":false,"proxy":"","authType":"","x":1070,"y":140,"wires":[["44d40b20.3fd414"]]},{"id":"c85ceba9.120ca8","type":"inject","z":"2680e2cc.e6dace","name":"","props":[{"p":"payload"},{"p":"topic","vt":"str"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"","payload":"","payloadType":"date","x":900,"y":140,"wires":[["58e5da76.091f54"]]},{"id":"98cdd4f5.a9c408","type":"debug","z":"2680e2cc.e6dace","name":"","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"payload","targetType":"msg","statusVal":"","statusType":"auto","x":1150,"y":260,"wires":[]},{"id":"afa2412a.6551b","type":"function","z":"2680e2cc.e6dace","name":"process array of li","func":"var results = [];\nfor(let i = 0; i < msg.payload.length; i++) {\n    let item = msg.payload[i];\n    var parts = item.split(\":\");\n    if(parts.length != 2 ) continue;\n    results.push({\n        date: parts[0].trim(),\n        val: parts[1].trim(),\n    })\n}\nmsg.payload = results;\nreturn msg;","outputs":1,"noerr":0,"initialize":"","finalize":"","x":1150,"y":200,"wires":[["98cdd4f5.a9c408"]]}]

PS, that took me about 4 & 1/2 minutes. :smiley: :smiley: :smiley:

PS2, it is untested (but should be close)

1 Like

This topic was automatically closed 60 days after the last reply. New replies are no longer allowed.