Place value in specific order with the join function

Hoi

I have small issue, and i have no idea how to solve that
I bring some value's together via MQTT put them in a file.
I like to manipulate the order how they are placed in the file, but how to do this

This is the join output

debug value
/solo/threshold-clear : msg.payload : string[81]
string[81]
Heater. : 0 mySQM. : 0 SkyTemp. : -16.43 Temp. : 5.84 ClearThres.: -18
But like to have it for example like
ClearThres.: -18 SkyTemp. : -16.43 Temp. : 5.84 mySQM. : 0 Heater. : 0

Ore some other order

I hope some can help me

[
    {
        "id": "ebcb66b4.4be2f8",
        "type": "tab",
        "label": "Flow 1",
        "disabled": false,
        "info": ""
    },
    {
        "id": "c95c7286.767c58",
        "type": "rpi-gpio out",
        "z": "ebcb66b4.4be2f8",
        "name": "",
        "pin": "7",
        "set": false,
        "level": "0",
        "freq": "",
        "out": "out",
        "x": 330,
        "y": 460,
        "wires": []
    },
    {
        "id": "1a14e7de.51e",
        "type": "rpi-gpio out",
        "z": "ebcb66b4.4be2f8",
        "name": "",
        "pin": "11",
        "set": "",
        "level": "0",
        "freq": "",
        "out": "out",
        "x": 340,
        "y": 500,
        "wires": []
    },
    {
        "id": "149fcf6a.df28c9",
        "type": "rpi-gpio out",
        "z": "ebcb66b4.4be2f8",
        "name": "",
        "pin": "13",
        "set": "",
        "level": "0",
        "freq": "",
        "out": "out",
        "x": 340,
        "y": 420,
        "wires": []
    },
    {
        "id": "2a81398b.caa9c6",
        "type": "rpi-gpio out",
        "z": "ebcb66b4.4be2f8",
        "name": "",
        "pin": "15",
        "set": true,
        "level": "1",
        "freq": "",
        "out": "out",
        "x": 340,
        "y": 360,
        "wires": []
    },
    {
        "id": "d9c00408.36a7d",
        "type": "inject",
        "z": "ebcb66b4.4be2f8",
        "name": "0 = OFF",
        "repeat": "",
        "crontab": "",
        "once": false,
        "onceDelay": 0.1,
        "topic": "",
        "payload": "0",
        "payloadType": "num",
        "x": 120,
        "y": 380,
        "wires": [
            [
                "2a81398b.caa9c6"
            ]
        ]
    },
    {
        "id": "7b95b0f5.3391e8",
        "type": "inject",
        "z": "ebcb66b4.4be2f8",
        "name": "1 = ON",
        "repeat": "21600",
        "crontab": "",
        "once": false,
        "onceDelay": 0.1,
        "topic": "",
        "payload": "1",
        "payloadType": "num",
        "x": 120,
        "y": 420,
        "wires": [
            [
                "2a81398b.caa9c6"
            ]
        ]
    },
    {
        "id": "9d78f317.9862f8",
        "type": "comment",
        "z": "ebcb66b4.4be2f8",
        "name": "Verbeteringen ",
        "info": " - Heater act on MQTT\n    Humidity\n    Temperatuur\n    Dewpoint\n    Rain (Uur naar regen is koppel nog nat)",
        "x": 110,
        "y": 60,
        "wires": []
    },
    {
        "id": "66d9ca25.8a6904",
        "type": "eztimer",
        "z": "ebcb66b4.4be2f8",
        "name": "",
        "debug": false,
        "autoname": "00:01:00 - sunriseEnd",
        "tag": "eztimer",
        "topic": "",
        "suspended": false,
        "sendEventsOnSuspend": false,
        "latLongSource": "manual",
        "lat": "52.841202",
        "lon": "6.4395083",
        "timerType": "1",
        "startupMessage": true,
        "ontype": "2",
        "ontimesun": "sunrise",
        "ontimetod": "00:01:00",
        "onpropertytype": "msg",
        "onproperty": "payload",
        "onvaluetype": "num",
        "onvalue": 1,
        "onoffset": "0",
        "onrandomoffset": 0,
        "onsuppressrepeats": false,
        "offtype": "1",
        "offtimesun": "sunriseEnd",
        "offtimetod": "dusk",
        "offduration": "00:01:00",
        "offpropertytype": "msg",
        "offproperty": "payload",
        "offvaluetype": "num",
        "offvalue": 0,
        "offoffset": "60",
        "offrandomoffset": 0,
        "offsuppressrepeats": false,
        "resend": true,
        "resendInterval": "30s",
        "mon": true,
        "tue": true,
        "wed": true,
        "thu": true,
        "fri": true,
        "sat": true,
        "sun": true,
        "x": 140,
        "y": 300,
        "wires": [
            [
                "2a81398b.caa9c6",
                "a32acf64babc1d5a"
            ]
        ]
    },
    {
        "id": "4268c46a2fd83a21",
        "type": "comment",
        "z": "ebcb66b4.4be2f8",
        "name": "active Relay for heater",
        "info": "",
        "x": 540,
        "y": 360,
        "wires": []
    },
    {
        "id": "4c74b7fd3e4faf10",
        "type": "comment",
        "z": "ebcb66b4.4be2f8",
        "name": "Night terms explained",
        "info": "** Dawn**; the first appearance of light in the sky before sun rise\n**Twilight**; The soft glow of light from the sky whne the sun is below the horizon, caused by the refelection  of the suns rays from the atmosfeer\n**dusk**; the darker stage of twilight\n** night** is periode\n** sunrise ** is the start of the day - sun at horizon\n** sunset ** is the end of the day    - sun at horizon\nhttps://www.timeanddate.com/astronomy/civil-twilight.html\n",
        "x": 540,
        "y": 300,
        "wires": []
    },
    {
        "id": "f2848857c951cb5d",
        "type": "mqtt in",
        "z": "ebcb66b4.4be2f8",
        "name": "",
        "topic": "/solo/skytemp",
        "qos": "2",
        "datatype": "utf8",
        "broker": "f2ee8be3.4a5dc",
        "nl": false,
        "rap": false,
        "x": 110,
        "y": 160,
        "wires": [
            [
                "5089b34bdf35ebc3"
            ]
        ]
    },
    {
        "id": "f47bbf809e5e6657",
        "type": "file",
        "z": "ebcb66b4.4be2f8",
        "name": "temperature",
        "filename": "/home/pi/allsky/chris.txt",
        "appendNewline": false,
        "createDir": false,
        "overwriteFile": "true",
        "encoding": "utf8",
        "x": 690,
        "y": 220,
        "wires": [
            []
        ]
    },
    {
        "id": "5089b34bdf35ebc3",
        "type": "function",
        "z": "ebcb66b4.4be2f8",
        "name": "",
        "func": "var str = 'SkyTemp.  : ' + msg.payload ;\nmsg.payload = str;\nreturn msg;\n",
        "outputs": 1,
        "noerr": 0,
        "initialize": "",
        "finalize": "",
        "libs": [],
        "x": 340,
        "y": 160,
        "wires": [
            [
                "2f8578808f278c36"
            ]
        ]
    },
    {
        "id": "15abc48aefa026f3",
        "type": "mqtt in",
        "z": "ebcb66b4.4be2f8",
        "name": "",
        "topic": "/solo/threshold-clear",
        "qos": "2",
        "datatype": "utf8",
        "broker": "f2ee8be3.4a5dc",
        "nl": false,
        "rap": false,
        "x": 130,
        "y": 200,
        "wires": [
            [
                "6751e247aff27ab7"
            ]
        ]
    },
    {
        "id": "2f8578808f278c36",
        "type": "join",
        "z": "ebcb66b4.4be2f8",
        "name": "",
        "mode": "custom",
        "build": "string",
        "property": "payload",
        "propertyType": "msg",
        "key": "topic",
        "joiner": "\\n",
        "joinerType": "str",
        "accumulate": false,
        "timeout": "",
        "count": "5",
        "reduceRight": false,
        "reduceExp": "",
        "reduceInit": "",
        "reduceInitType": "",
        "reduceFixup": "",
        "x": 530,
        "y": 220,
        "wires": [
            [
                "f47bbf809e5e6657",
                "a990bcbbd5354e1d"
            ]
        ]
    },
    {
        "id": "a990bcbbd5354e1d",
        "type": "debug",
        "z": "ebcb66b4.4be2f8",
        "name": "join",
        "active": true,
        "tosidebar": true,
        "console": false,
        "tostatus": false,
        "complete": "payload",
        "targetType": "msg",
        "statusVal": "",
        "statusType": "auto",
        "x": 790,
        "y": 120,
        "wires": []
    },
    {
        "id": "6751e247aff27ab7",
        "type": "function",
        "z": "ebcb66b4.4be2f8",
        "name": "",
        "func": "var str = 'ClearThres.: ' + msg.payload;\nmsg.payload = str;\nreturn msg;\n",
        "outputs": 1,
        "noerr": 0,
        "initialize": "",
        "finalize": "",
        "libs": [],
        "x": 340,
        "y": 200,
        "wires": [
            [
                "2f8578808f278c36"
            ]
        ]
    },
    {
        "id": "a0cc5ceffc3cc114",
        "type": "inject",
        "z": "ebcb66b4.4be2f8",
        "name": "",
        "props": [
            {
                "p": "payload"
            },
            {
                "p": "topic",
                "vt": "str"
            }
        ],
        "repeat": "30",
        "crontab": "",
        "once": true,
        "onceDelay": 0.1,
        "topic": "",
        "payload": "0",
        "payloadType": "num",
        "x": 110,
        "y": 260,
        "wires": [
            [
                "b34027a2de0d9621"
            ]
        ]
    },
    {
        "id": "b34027a2de0d9621",
        "type": "function",
        "z": "ebcb66b4.4be2f8",
        "name": "",
        "func": "var str = 'mySQM.    : ' + msg.payload;\nmsg.payload = str;\nreturn msg;\n",
        "outputs": 1,
        "noerr": 0,
        "initialize": "",
        "finalize": "",
        "libs": [],
        "x": 340,
        "y": 260,
        "wires": [
            [
                "2f8578808f278c36"
            ]
        ]
    },
    {
        "id": "a32acf64babc1d5a",
        "type": "function",
        "z": "ebcb66b4.4be2f8",
        "name": "",
        "func": "var str = 'Heater.    : ' + msg.payload;\nmsg.payload = str;\nreturn msg;\n",
        "outputs": 1,
        "noerr": 0,
        "initialize": "",
        "finalize": "",
        "libs": [],
        "x": 340,
        "y": 300,
        "wires": [
            [
                "2f8578808f278c36"
            ]
        ]
    },
    {
        "id": "67abe6e1625918d8",
        "type": "mqtt in",
        "z": "ebcb66b4.4be2f8",
        "name": "",
        "topic": "/solo/temperature",
        "qos": "2",
        "datatype": "utf8",
        "broker": "f2ee8be3.4a5dc",
        "nl": false,
        "rap": false,
        "x": 130,
        "y": 100,
        "wires": [
            [
                "ef8a82ad3623ef62"
            ]
        ]
    },
    {
        "id": "ef8a82ad3623ef62",
        "type": "function",
        "z": "ebcb66b4.4be2f8",
        "name": "",
        "func": "var str = 'Temp.     : ' + msg.payload ;\nmsg.payload = str;\nreturn msg;\n",
        "outputs": 1,
        "noerr": 0,
        "initialize": "",
        "finalize": "",
        "libs": [],
        "x": 340,
        "y": 100,
        "wires": [
            [
                "2f8578808f278c36"
            ]
        ]
    },
    {
        "id": "f2ee8be3.4a5dc",
        "type": "mqtt-broker",
        "name": "SterrenwachtDak",
        "broker": "192.168.1.9",
        "port": "1883",
        "clientid": "",
        "usetls": false,
        "compatmode": false,
        "protocolVersion": "4",
        "keepalive": "60",
        "cleansession": true,
        "birthTopic": "",
        "birthQos": "0",
        "birthPayload": "",
        "birthMsg": {},
        "closeTopic": "",
        "closeQos": "0",
        "closePayload": "",
        "closeMsg": {},
        "willTopic": "",
        "willQos": "0",
        "willPayload": "",
        "willMsg": {},
        "sessionExpiry": ""
    }
]

Join the values manually as key value objects, then you can use a template node to format as you wish
e.g.

[{"id":"f6a080df.f56f4","type":"inject","z":"ebcb66b4.4be2f8","name":"temp","props":[{"p":"payload"},{"p":"topic","vt":"str"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"","payload":"20","payloadType":"num","x":110,"y":120,"wires":[["ef18b750.311d1"]]},{"id":"ef18b750.311d1","type":"change","z":"ebcb66b4.4be2f8","name":"","rules":[{"t":"set","p":"topic","pt":"msg","to":"Temp","tot":"str"}],"action":"","property":"","from":"","to":"","reg":false,"x":320,"y":120,"wires":[["2f8578808f278c36"]]},{"id":"2f8578808f278c36","type":"join","z":"ebcb66b4.4be2f8","name":"","mode":"custom","build":"object","property":"payload","propertyType":"msg","key":"topic","joiner":"\\n","joinerType":"str","accumulate":false,"timeout":"","count":"5","reduceRight":false,"reduceExp":"","reduceInit":"","reduceInitType":"","reduceFixup":"","x":530,"y":220,"wires":[["5b5120af.9c89a"]]},{"id":"6cffe993.b67a","type":"change","z":"ebcb66b4.4be2f8","name":"","rules":[{"t":"set","p":"topic","pt":"msg","to":"mySQM","tot":"str"}],"action":"","property":"","from":"","to":"","reg":false,"x":310,"y":200,"wires":[["2f8578808f278c36"]]},{"id":"55247c45.a94ba4","type":"change","z":"ebcb66b4.4be2f8","name":"","rules":[{"t":"set","p":"topic","pt":"msg","to":"SkyTemp","tot":"str"}],"action":"","property":"","from":"","to":"","reg":false,"x":310,"y":160,"wires":[["2f8578808f278c36"]]},{"id":"b73f42b9.02c0d8","type":"change","z":"ebcb66b4.4be2f8","name":"","rules":[{"t":"set","p":"topic","pt":"msg","to":"ClearThres","tot":"str"}],"action":"","property":"","from":"","to":"","reg":false,"x":310,"y":240,"wires":[["2f8578808f278c36"]]},{"id":"98fcc36b.26c5d","type":"change","z":"ebcb66b4.4be2f8","name":"","rules":[{"t":"set","p":"topic","pt":"msg","to":"Heater","tot":"str"}],"action":"","property":"","from":"","to":"","reg":false,"x":310,"y":300,"wires":[["2f8578808f278c36"]]},{"id":"5b5120af.9c89a","type":"template","z":"ebcb66b4.4be2f8","name":"","field":"payload","fieldType":"msg","format":"handlebars","syntax":"mustache","template":"ClearThres.: {{payload.ClearThres}} SkyTemp. : {{payload.SkyTemp}} Temp. : {{payload.Temp}} mySQM. : {{payload.mySQM}} Heater. : {{payload.Heater}}","output":"str","x":580,"y":280,"wires":[["a990bcbbd5354e1d"]]},{"id":"755436e2.c99708","type":"inject","z":"ebcb66b4.4be2f8","name":"sqm","props":[{"p":"payload"},{"p":"topic","vt":"str"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"","payload":"20","payloadType":"num","x":110,"y":200,"wires":[["6cffe993.b67a"]]},{"id":"1f1a54e9.ef37eb","type":"inject","z":"ebcb66b4.4be2f8","name":"sky","props":[{"p":"payload"},{"p":"topic","vt":"str"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"","payload":"20","payloadType":"num","x":110,"y":160,"wires":[["55247c45.a94ba4"]]},{"id":"a0cc5ceffc3cc114","type":"inject","z":"ebcb66b4.4be2f8","name":"","props":[{"p":"payload"},{"p":"topic","vt":"str"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"","payload":"0","payloadType":"num","x":110,"y":240,"wires":[["b73f42b9.02c0d8"]]},{"id":"6fabd4f9.addee4","type":"inject","z":"ebcb66b4.4be2f8","name":"heater","props":[{"p":"payload"},{"p":"topic","vt":"str"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"","payload":"0","payloadType":"num","x":120,"y":300,"wires":[["98fcc36b.26c5d"]]},{"id":"a990bcbbd5354e1d","type":"debug","z":"ebcb66b4.4be2f8","name":"join","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"payload","targetType":"msg","statusVal":"","statusType":"auto","x":790,"y":180,"wires":[]}]

Thank

It did the job, the information is displayed now right in my allsky camera, Unfortanly Cloudy

Chris

1 Like

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