Double message in join node

Good evening everyone
I noticed a strange behaviour with my join node, probably I misconfigured it.
The flow gets a message with GPS data, extract latitude and longitude in two different branches and then I join them together to make a single message
The problem is, I have no idea why but I'm getting 2 messages at the same time (with slightly different data). I tought about the flag of the 2 message parts but I think that's correct? I need both messages to get a full position
Probably I'm doing something stupid, any help is appreciated

[
    {
        "id": "bbaab412081cb0ee",
        "type": "function",
        "z": "3af70a9829406ec3",
        "name": "NMEA to human",
        "func": "let pos = msg.payload.indexOf(\".\")\nlet minutes = msg.payload.substring(pos-2)\nlet degrees = msg.payload.substring(0, pos-2)\nlet temp = Number(degrees) + (Number(minutes)/60)\nmsg.payload = temp\nreturn msg;",
        "outputs": 1,
        "noerr": 0,
        "initialize": "",
        "finalize": "",
        "libs": [],
        "x": 520,
        "y": 580,
        "wires": [
            [
                "2987fe00cd334ebd"
            ]
        ]
    },
    {
        "id": "5ad5ec586f14b9ed",
        "type": "function",
        "z": "3af70a9829406ec3",
        "name": "NMEA to human",
        "func": "let pos = msg.payload.indexOf(\".\")\nlet minutes = msg.payload.substring(pos-2)\nlet degrees = msg.payload.substring(0, pos-2)\nlet temp = Number(degrees) + (Number(minutes)/60)\nmsg.payload = temp\nreturn msg;",
        "outputs": 1,
        "noerr": 0,
        "initialize": "",
        "finalize": "",
        "libs": [],
        "x": 520,
        "y": 540,
        "wires": [
            [
                "bf24f301c2e25934"
            ]
        ]
    },
    {
        "id": "60010beafd8ae5b9",
        "type": "string",
        "z": "3af70a9829406ec3",
        "name": "filter E",
        "methods": [
            {
                "name": "between",
                "params": [
                    {
                        "type": "str",
                        "value": "N,"
                    },
                    {
                        "type": "str",
                        "value": ",E,"
                    }
                ]
            }
        ],
        "prop": "payload",
        "propout": "payload",
        "object": "msg",
        "objectout": "msg",
        "x": 350,
        "y": 580,
        "wires": [
            [
                "bbaab412081cb0ee"
            ]
        ]
    },
    {
        "id": "640a1bbc0b9213ac",
        "type": "string",
        "z": "3af70a9829406ec3",
        "name": "filter N",
        "methods": [
            {
                "name": "between",
                "params": [
                    {
                        "type": "str",
                        "value": "+CGPSINFO:"
                    },
                    {
                        "type": "str",
                        "value": ",N,"
                    }
                ]
            }
        ],
        "prop": "payload",
        "propout": "payload",
        "object": "msg",
        "objectout": "msg",
        "x": 350,
        "y": 540,
        "wires": [
            [
                "5ad5ec586f14b9ed"
            ]
        ]
    },
    {
        "id": "2987fe00cd334ebd",
        "type": "change",
        "z": "3af70a9829406ec3",
        "name": "set topic: E",
        "rules": [
            {
                "t": "set",
                "p": "topic",
                "pt": "msg",
                "to": "E",
                "tot": "str"
            }
        ],
        "action": "",
        "property": "",
        "from": "",
        "to": "",
        "reg": false,
        "x": 730,
        "y": 580,
        "wires": [
            [
                "5e6e5576958b3129"
            ]
        ]
    },
    {
        "id": "bf24f301c2e25934",
        "type": "change",
        "z": "3af70a9829406ec3",
        "name": "set topic: N",
        "rules": [
            {
                "t": "set",
                "p": "topic",
                "pt": "msg",
                "to": "N",
                "tot": "str"
            }
        ],
        "action": "",
        "property": "",
        "from": "",
        "to": "",
        "reg": false,
        "x": 730,
        "y": 540,
        "wires": [
            [
                "5e6e5576958b3129"
            ]
        ]
    },
    {
        "id": "5e6e5576958b3129",
        "type": "join",
        "z": "3af70a9829406ec3",
        "name": "Join topics",
        "mode": "custom",
        "build": "object",
        "property": "payload",
        "propertyType": "msg",
        "key": "topic",
        "joiner": "\\n",
        "joinerType": "str",
        "accumulate": true,
        "timeout": "",
        "count": "2",
        "reduceRight": false,
        "reduceExp": "",
        "reduceInit": "",
        "reduceInitType": "",
        "reduceFixup": "",
        "x": 910,
        "y": 560,
        "wires": [
            [
                "979d4f7a4b2d18f9"
            ]
        ]
    },
    {
        "id": "979d4f7a4b2d18f9",
        "type": "function",
        "z": "3af70a9829406ec3",
        "name": "Merge to string",
        "func": "let temp = \"{ \\\"type\\\":\\\"Point\\\",\\\"coordinates\\\": [\" + msg.payload.E + \", \" + msg.payload.N + \"]}\"\nmsg.payload = temp\nreturn msg;",
        "outputs": 1,
        "noerr": 0,
        "initialize": "",
        "finalize": "",
        "libs": [],
        "x": 1100,
        "y": 560,
        "wires": [
            [
                "225754e90cfb26c4",
                "d8efe248e1a37329"
            ]
        ]
    }
]

Thanks
P

You are getting two messages because you have told the join node to output every subsequent message.

Do you mean that you start off with one message, then split it and then join it together again, or do the lat and lon come in from the source in separate messages?

Oh, I tought that just meant "don't stop after 1 message but join the next 2 etc.

Correct, it comes in a single message with a lot of unnecessary stuff, so I split it to clean the message and convert it in a readable format, then join them again

Why bother splitting and joining? Just ignore the fields that are not relevant. You are just adding overheads by removing them.

I receive a string as input and I need two different parts of this string (latitude and longitude). Since I'm not too skilled on working with messages I extract the 2 parts with a "between", clean them up and rejoin them with the format I need.

So if I flag "output subsequent messages" it joins message 1 and 2, 2 with 3, 3 with 4 ecc?

You can extract parts do maths and create output in one function node. Not sure i got the correct maths and such but this example should give you some ideas.

[{"id":"ba525be4809fb0d1","type":"inject","z":"b9860b4b9de8c8da","name":"","props":[{"p":"payload"},{"p":"topic","vt":"str"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"","payload":"+CGPSINFO: 3113.393766,N,12121.176625,E,061108,075358.0,19.5,0","payloadType":"str","x":270,"y":1340,"wires":[["5ad5ec586f14b9ed"]]},{"id":"5ad5ec586f14b9ed","type":"function","z":"b9860b4b9de8c8da","name":"NMEA to human","func":"msg.payload = msg.payload.split(/[ ,\\.]/);\nlet north = msg.payload[1];\nlet east = msg.payload[4];\nnorth = Number(north.slice(0,-2)) + (Number(north.slice(-2)) / 60) \neast = Number(east.slice(0,-2)) + (Number(east.slice(-2)) / 60)\nmsg.payload = `{\"type\":\"Point\",\"coordinates\":[${north},${east}]}`;\nreturn msg;","outputs":1,"noerr":0,"initialize":"","finalize":"","libs":[],"x":440,"y":1340,"wires":[["1363d5edcc60e58a"]]},{"id":"1363d5edcc60e58a","type":"debug","z":"b9860b4b9de8c8da","name":"debug 289","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"false","statusVal":"","statusType":"auto","x":630,"y":1340,"wires":[]}]

Thank you very much!
I'll try to work on your node, much cleaner

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