Modifying MQTT Messages

Hi!

Trying to communicate similar data on one MQTT topic. This topic receives messages with the payloads "Percentage [two-digit value]/Gallons [variable digit value]". I want to route the message to the appropriate dashboard utilities, and to do that I need to split the message (figured that part out) and remove anything that isn't a number. Currently, my dashboard nodes are receiving almost exactly what I want them to get but they need to only receive the number portion of the payloads. How can I do this?
image
Thanks!

Convert the incoming data to an Object rather than throwing away the text part. How you need to do that depends on the exact data which you've not shared.

If you want to extract integers you can use JSONATA $parseInteger - if there are floats you can use a change node with a regex expression.

This is an example of the data being received-
image

In real world, gallons will be any number from 0 on up to thousands of gallons. No negative numbers, and no real need for decimal places, but our test environment requires it as it's just a tube of PVC.

I'm very new to JSON- only experience I have was when I had to parse API responses from openweather. Hell I'm new to all of this with no coding education since high school, just learning it all as I go because it's interesting to me. Business degree isn't helping much here!

Another, maybe more helpful way of phrasing my question is I'm wanting to transmit the status of multiple things on one topic. E.G. we have a few valves in use- makes sense to send them all on a single topic like valvestatus, then split them up and route them later, as I only have so many topics I can transmit on with this device. I can only send so much information, and can only send certain things.
image
This message setup for examples sends five things, like "ON/OFF/ON/ON/OFF" with no identifiers embedded. Hopefully this provides a little more context :slight_smile:

In a function node, you can

const out = {} // create an empty object
const splitpay = msg.payload.split('/')
splitpay.forEach( line => {
    const splitLine = line.split(' ')
    out[ splitLine[0] ] = splitLine[1]
})

msg.payload = out
return msg

Now you have a nice object you can work with easily.

As I am not a friend of function nodes - to avoid coding as much as possible - here an alternative solution. Either directly with a change or a csv node.

[
    {
        "id": "0ddc259a86b19f90",
        "type": "inject",
        "z": "289f539dcc33814e",
        "name": "",
        "props": [
            {
                "p": "payload"
            }
        ],
        "repeat": "",
        "crontab": "",
        "once": false,
        "onceDelay": 0.1,
        "topic": "",
        "payload": "ON/OFF/ON/ON/OFF",
        "payloadType": "str",
        "x": 520,
        "y": 300,
        "wires": [
            [
                "77b21784be15071c",
                "1f2d710413ee8e9a"
            ]
        ]
    },
    {
        "id": "77b21784be15071c",
        "type": "change",
        "z": "289f539dcc33814e",
        "name": "",
        "rules": [
            {
                "t": "set",
                "p": "payload",
                "pt": "msg",
                "to": "$split(payload,'/')\t",
                "tot": "jsonata"
            },
            {
                "t": "set",
                "p": "payload",
                "pt": "msg",
                "to": "{\t   \"Y005\":payload[0],\t   \"Y006\":payload[1],\t   \"Y007\":payload[2],\t   \"Y008\":payload[3],\t   \"Y009\":payload[4]\t}",
                "tot": "jsonata"
            }
        ],
        "action": "",
        "property": "",
        "from": "",
        "to": "",
        "reg": false,
        "x": 750,
        "y": 300,
        "wires": [
            [
                "b6ecd209072e9aa5"
            ]
        ]
    },
    {
        "id": "b6ecd209072e9aa5",
        "type": "debug",
        "z": "289f539dcc33814e",
        "name": "",
        "active": false,
        "tosidebar": true,
        "console": false,
        "tostatus": false,
        "complete": "false",
        "statusVal": "",
        "statusType": "auto",
        "x": 950,
        "y": 300,
        "wires": []
    },
    {
        "id": "1f2d710413ee8e9a",
        "type": "csv",
        "z": "289f539dcc33814e",
        "name": "",
        "sep": "/",
        "hdrin": "",
        "hdrout": "all",
        "multi": "one",
        "ret": "\\n",
        "temp": "Y005,Y006,Y007,Y008,Y009",
        "skip": "0",
        "strings": true,
        "include_empty_strings": "",
        "include_null_values": "",
        "x": 730,
        "y": 360,
        "wires": [
            [
                "2f77ccf216c5eefd"
            ]
        ]
    },
    {
        "id": "2f77ccf216c5eefd",
        "type": "debug",
        "z": "289f539dcc33814e",
        "name": "",
        "active": true,
        "tosidebar": true,
        "console": false,
        "tostatus": false,
        "complete": "false",
        "statusVal": "",
        "statusType": "auto",
        "x": 890,
        "y": 360,
        "wires": []
    }
]

To get out the numeric part - I will send you in the next post

The next one is - how to get the numeric values out of the string with a regular expression:

`[
    {
        "id": "847c90e95cfde9ee",
        "type": "inject",
        "z": "289f539dcc33814e",
        "name": "",
        "props": [
            {
                "p": "payload"
            }
        ],
        "repeat": "",
        "crontab": "",
        "once": false,
        "onceDelay": 0.1,
        "topic": "",
        "payload": "Percentage 80/Gallons 0.98",
        "payloadType": "str",
        "x": 550,
        "y": 100,
        "wires": [
            [
                "6c40a1aaba466120"
            ]
        ]
    },
    {
        "id": "6c40a1aaba466120",
        "type": "change",
        "z": "289f539dcc33814e",
        "name": "",
        "rules": [
            {
                "t": "set",
                "p": "payload",
                "pt": "msg",
                "to": "$split(payload,'/')\t",
                "tot": "jsonata"
            },
            {
                "t": "set",
                "p": "payload",
                "pt": "msg",
                "to": "{\t   \"Percentage\": $number(\t       $replace(payload[0],/.*\\s(\\d+\\.?\\d?)/,'$1')\t   ),\t   \"Gallons\": $number(\t       $replace(payload[1],/.*\\s(\\d+\\.?\\d?)/,'$1')\t   )\t}\t",
                "tot": "jsonata"
            }
        ],
        "action": "",
        "property": "",
        "from": "",
        "to": "",
        "reg": false,
        "x": 730,
        "y": 100,
        "wires": [
            [
                "f61d6b62a478633b",
                "f341233749a10fa8",
                "151fa75ccf35bc61"
            ]
        ]
    },
    {
        "id": "f61d6b62a478633b",
        "type": "debug",
        "z": "289f539dcc33814e",
        "name": "",
        "active": true,
        "tosidebar": true,
        "console": false,
        "tostatus": false,
        "complete": "false",
        "statusVal": "",
        "statusType": "auto",
        "x": 990,
        "y": 100,
        "wires": []
    },
    {
        "id": "f341233749a10fa8",
        "type": "debug",
        "z": "289f539dcc33814e",
        "name": "",
        "active": true,
        "tosidebar": true,
        "console": false,
        "tostatus": false,
        "complete": "payload.Percentage",
        "targetType": "msg",
        "statusVal": "",
        "statusType": "auto",
        "x": 1030,
        "y": 140,
        "wires": []
    },
    {
        "id": "151fa75ccf35bc61",
        "type": "debug",
        "z": "289f539dcc33814e",
        "name": "",
        "active": true,
        "tosidebar": true,
        "console": false,
        "tostatus": false,
        "complete": "payload.Gallons",
        "targetType": "msg",
        "statusVal": "",
        "statusType": "auto",
        "x": 1020,
        "y": 180,
        "wires": []
    }
]`

Thanks Micky! A Java expert I am not, so I did get confused with the function code (no fault of yours, TotallyInformation, I appreciate the help you've given me on a few things now) and sought out another route as I don't know how to work with the outputs.

I ended up doing this- when I revisited and saw your suggestion I was pleasantly surprised to see I wasn't too far off from your idea. While the backend is bulky, it will allow me to show a functional and clean iteration for a meeting I have in 17 minutes with higher ups! Now I just need to figure out how to change the order of the dashboard elements.

[
    {
        "id": "d7584b9aa54104a5",
        "type": "mqtt in",
        "z": "3346a6d4cdae435b",
        "name": "",
        "topic": "Valve Status",
        "qos": "2",
        "datatype": "auto",
        "broker": "de3df31c4a66b745",
        "nl": false,
        "rap": true,
        "rh": 0,
        "inputs": 0,
        "x": 170,
        "y": 640,
        "wires": [
            [
                "11d74977c1615f88",
                "85c0ac576a78ec41"
            ]
        ]
    },
    {
        "id": "11d74977c1615f88",
        "type": "debug",
        "z": "3346a6d4cdae435b",
        "name": "",
        "active": false,
        "tosidebar": true,
        "console": false,
        "tostatus": false,
        "complete": "false",
        "statusVal": "",
        "statusType": "auto",
        "x": 350,
        "y": 720,
        "wires": []
    },
    {
        "id": "8e57e6bf0767e24b",
        "type": "ui_text",
        "z": "3346a6d4cdae435b",
        "group": "f987d5aa965097c5",
        "order": 2,
        "width": 0,
        "height": 0,
        "name": "",
        "label": "Municipal Valve is",
        "format": "{{msg.payload}}",
        "layout": "row-center",
        "className": "",
        "x": 990,
        "y": 580,
        "wires": []
    },
    {
        "id": "48bb2962a3f0b9e4",
        "type": "link out",
        "z": "3346a6d4cdae435b",
        "name": "",
        "mode": "link",
        "links": [
            "13537af4a3f6ee3c"
        ],
        "x": 975,
        "y": 500,
        "wires": []
    },
    {
        "id": "85c0ac576a78ec41",
        "type": "split",
        "z": "3346a6d4cdae435b",
        "name": "",
        "splt": "/",
        "spltType": "str",
        "arraySplt": 1,
        "arraySpltType": "len",
        "stream": false,
        "addname": "",
        "x": 370,
        "y": 640,
        "wires": [
            [
                "c716ca04366c2555",
                "46661a5491cd5622"
            ]
        ]
    },
    {
        "id": "c716ca04366c2555",
        "type": "switch",
        "z": "3346a6d4cdae435b",
        "name": "",
        "property": "payload",
        "propertyType": "msg",
        "rules": [
            {
                "t": "cont",
                "v": "Municipal",
                "vt": "str"
            },
            {
                "t": "cont",
                "v": "Feed",
                "vt": "str"
            },
            {
                "t": "cont",
                "v": "Drain",
                "vt": "str"
            },
            {
                "t": "cont",
                "v": "Transfer",
                "vt": "str"
            },
            {
                "t": "cont",
                "v": "Rinse",
                "vt": "str"
            }
        ],
        "checkall": "true",
        "repair": false,
        "outputs": 5,
        "x": 550,
        "y": 640,
        "wires": [
            [
                "efbe98f752def4d9",
                "b7f91f14dac1d47a"
            ],
            [
                "fd1d08618b13fb1e"
            ],
            [
                "f6bf78efd8527c12"
            ],
            [
                "3c28bc4b6d8bb2d2"
            ],
            [
                "961aa7409f8ab9aa"
            ]
        ]
    },
    {
        "id": "7ec3c9d4dad71848",
        "type": "ui_text",
        "z": "3346a6d4cdae435b",
        "group": "f987d5aa965097c5",
        "order": 11,
        "width": 0,
        "height": 0,
        "name": "",
        "label": "Feed Valve is",
        "format": "{{msg.payload}}",
        "layout": "row-spread",
        "className": "",
        "x": 980,
        "y": 620,
        "wires": []
    },
    {
        "id": "d9c642600e7fdd6a",
        "type": "ui_text",
        "z": "3346a6d4cdae435b",
        "group": "f987d5aa965097c5",
        "order": 12,
        "width": 0,
        "height": 0,
        "name": "",
        "label": "Drain Valve is",
        "format": "{{msg.payload}}",
        "layout": "row-spread",
        "className": "",
        "x": 980,
        "y": 660,
        "wires": []
    },
    {
        "id": "ed932e42e5023963",
        "type": "ui_text",
        "z": "3346a6d4cdae435b",
        "group": "f987d5aa965097c5",
        "order": 13,
        "width": 0,
        "height": 0,
        "name": "",
        "label": "Transfer Valve is",
        "format": "{{msg.payload}}",
        "layout": "row-spread",
        "className": "",
        "x": 980,
        "y": 700,
        "wires": []
    },
    {
        "id": "4efd4064c343398f",
        "type": "ui_text",
        "z": "3346a6d4cdae435b",
        "group": "f987d5aa965097c5",
        "order": 14,
        "width": 0,
        "height": 0,
        "name": "",
        "label": "Rinse Valve is",
        "format": "{{msg.payload}}",
        "layout": "row-spread",
        "className": "",
        "x": 980,
        "y": 740,
        "wires": []
    },
    {
        "id": "46661a5491cd5622",
        "type": "debug",
        "z": "3346a6d4cdae435b",
        "name": "",
        "active": false,
        "tosidebar": true,
        "console": false,
        "tostatus": false,
        "complete": "false",
        "statusVal": "",
        "statusType": "auto",
        "x": 550,
        "y": 720,
        "wires": []
    },
    {
        "id": "efbe98f752def4d9",
        "type": "change",
        "z": "3346a6d4cdae435b",
        "name": "",
        "rules": [
            {
                "t": "change",
                "p": "payload",
                "pt": "msg",
                "from": "MunicipalON",
                "fromt": "str",
                "to": "ON",
                "tot": "str"
            },
            {
                "t": "change",
                "p": "payload",
                "pt": "msg",
                "from": "MunicipalOFF",
                "fromt": "str",
                "to": "OFF",
                "tot": "str"
            }
        ],
        "action": "",
        "property": "",
        "from": "",
        "to": "",
        "reg": false,
        "x": 780,
        "y": 580,
        "wires": [
            [
                "8e57e6bf0767e24b",
                "48bb2962a3f0b9e4",
                "5872c83f42fabfbe"
            ]
        ]
    },
    {
        "id": "fd1d08618b13fb1e",
        "type": "change",
        "z": "3346a6d4cdae435b",
        "name": "",
        "rules": [
            {
                "t": "change",
                "p": "payload",
                "pt": "msg",
                "from": "FeedON",
                "fromt": "str",
                "to": "ON",
                "tot": "str"
            },
            {
                "t": "change",
                "p": "payload",
                "pt": "msg",
                "from": "FeedOFF",
                "fromt": "str",
                "to": "OFF",
                "tot": "str"
            }
        ],
        "action": "",
        "property": "",
        "from": "",
        "to": "",
        "reg": false,
        "x": 780,
        "y": 620,
        "wires": [
            [
                "7ec3c9d4dad71848"
            ]
        ]
    },
    {
        "id": "f6bf78efd8527c12",
        "type": "change",
        "z": "3346a6d4cdae435b",
        "name": "",
        "rules": [
            {
                "t": "change",
                "p": "payload",
                "pt": "msg",
                "from": "DrainON",
                "fromt": "str",
                "to": "ON",
                "tot": "str"
            },
            {
                "t": "change",
                "p": "payload",
                "pt": "msg",
                "from": "DrainOFF",
                "fromt": "str",
                "to": "OFF",
                "tot": "str"
            }
        ],
        "action": "",
        "property": "",
        "from": "",
        "to": "",
        "reg": false,
        "x": 780,
        "y": 660,
        "wires": [
            [
                "d9c642600e7fdd6a"
            ]
        ]
    },
    {
        "id": "961aa7409f8ab9aa",
        "type": "change",
        "z": "3346a6d4cdae435b",
        "name": "",
        "rules": [
            {
                "t": "change",
                "p": "payload",
                "pt": "msg",
                "from": "RinseON",
                "fromt": "str",
                "to": "ON",
                "tot": "str"
            },
            {
                "t": "change",
                "p": "payload",
                "pt": "msg",
                "from": "RinseOFF",
                "fromt": "str",
                "to": "OFF",
                "tot": "str"
            }
        ],
        "action": "",
        "property": "",
        "from": "",
        "to": "",
        "reg": false,
        "x": 780,
        "y": 740,
        "wires": [
            [
                "4efd4064c343398f"
            ]
        ]
    },
    {
        "id": "3c28bc4b6d8bb2d2",
        "type": "change",
        "z": "3346a6d4cdae435b",
        "name": "",
        "rules": [
            {
                "t": "change",
                "p": "payload",
                "pt": "msg",
                "from": "TransferON",
                "fromt": "str",
                "to": "ON",
                "tot": "str"
            },
            {
                "t": "change",
                "p": "payload",
                "pt": "msg",
                "from": "TransferOFF",
                "fromt": "str",
                "to": "OFF",
                "tot": "str"
            }
        ],
        "action": "",
        "property": "",
        "from": "",
        "to": "",
        "reg": false,
        "x": 780,
        "y": 700,
        "wires": [
            [
                "ed932e42e5023963"
            ]
        ]
    },
    {
        "id": "b7f91f14dac1d47a",
        "type": "debug",
        "z": "3346a6d4cdae435b",
        "name": "",
        "active": false,
        "tosidebar": true,
        "console": false,
        "tostatus": false,
        "complete": "false",
        "statusVal": "",
        "statusType": "auto",
        "x": 770,
        "y": 540,
        "wires": []
    },
    {
        "id": "5872c83f42fabfbe",
        "type": "debug",
        "z": "3346a6d4cdae435b",
        "name": "",
        "active": false,
        "tosidebar": true,
        "console": false,
        "tostatus": false,
        "complete": "false",
        "statusVal": "",
        "statusType": "auto",
        "x": 1030,
        "y": 540,
        "wires": []
    },
    {
        "id": "de3df31c4a66b745",
        "type": "mqtt-broker",
        "name": "",
        "broker": "localhost",
        "port": "1883",
        "clientid": "Node-RED",
        "autoConnect": true,
        "usetls": false,
        "protocolVersion": "5",
        "keepalive": "60",
        "cleansession": true,
        "birthTopic": "Import",
        "birthQos": "0",
        "birthRetain": "true",
        "birthPayload": "Testing Node-RED",
        "birthMsg": {},
        "closeTopic": "Import",
        "closeQos": "0",
        "closeRetain": "true",
        "closePayload": "Leaving Node-RED scheduled",
        "closeMsg": {},
        "willTopic": "Import",
        "willQos": "0",
        "willRetain": "true",
        "willPayload": "Disconnected unexpectedly",
        "willMsg": {},
        "sessionExpiry": ""
    },
    {
        "id": "f987d5aa965097c5",
        "type": "ui_group",
        "name": "ClickPlus PLC Test",
        "tab": "20b3095113f94d70",
        "order": 1,
        "disp": true,
        "width": "6",
        "collapse": false,
        "className": ""
    },
    {
        "id": "20b3095113f94d70",
        "type": "ui_tab",
        "name": "Home",
        "icon": "dashboard",
        "disabled": false,
        "hidden": false
    }
]
1 Like

In my opinion you did nothing wrong - as you have to split the values anyway - as you have a text nodes for 5 different states. So it makes no sense to keep it in one object.

Keeping the values of the states in one object or array makes only sense, if you want to compare the states or if you use a template node and want to iterate for a table or something like that.

Back to your original question then - and that you can use your existing flow - just use one change node - to get the numeric part out.

I will give you an example - without using JSONATA - just a regex - expression only for converting into a number I will give you the change node in 2 steps - but for sure you can use one JSONATA expression as well - as I posted it the previous example. For you Gauge Node - even this is not necessary as this node implicitly interprets a numeric string correctly.

So here are the different steps to get the numeric part out of your string. You do not need to create a topic - but I did it for demonstration:

[
    {
        "id": "88fe65d84831eba2",
        "type": "inject",
        "z": "289f539dcc33814e",
        "name": "",
        "props": [
            {
                "p": "payload"
            }
        ],
        "repeat": "",
        "crontab": "",
        "once": false,
        "onceDelay": 0.1,
        "topic": "",
        "payload": "Percentage 80/Gallons 0.98",
        "payloadType": "str",
        "x": 230,
        "y": 120,
        "wires": [
            [
                "18f0b074693cf7ed"
            ]
        ]
    },
    {
        "id": "2e9f8212e2b043b0",
        "type": "change",
        "z": "289f539dcc33814e",
        "name": "extract topic and payload",
        "rules": [
            {
                "t": "set",
                "p": "topic",
                "pt": "msg",
                "to": "payload",
                "tot": "msg",
                "dc": true
            },
            {
                "t": "change",
                "p": "payload",
                "pt": "msg",
                "from": ".*\\s(\\d+\\.?\\d?)",
                "fromt": "re",
                "to": "$1",
                "tot": "str"
            },
            {
                "t": "change",
                "p": "topic",
                "pt": "msg",
                "from": "(.*)\\s.*",
                "fromt": "re",
                "to": "$1",
                "tot": "str"
            }
        ],
        "action": "",
        "property": "",
        "from": "",
        "to": "",
        "reg": false,
        "x": 610,
        "y": 120,
        "wires": [
            [
                "c67d98c0555b6858",
                "012930c1c30f2970"
            ]
        ]
    },
    {
        "id": "18f0b074693cf7ed",
        "type": "split",
        "z": "289f539dcc33814e",
        "name": "",
        "splt": "/",
        "spltType": "str",
        "arraySplt": 1,
        "arraySpltType": "len",
        "stream": false,
        "addname": "",
        "x": 390,
        "y": 120,
        "wires": [
            [
                "99433f4e031d2a16",
                "2e9f8212e2b043b0"
            ]
        ]
    },
    {
        "id": "99433f4e031d2a16",
        "type": "debug",
        "z": "289f539dcc33814e",
        "name": "Split by separator",
        "active": true,
        "tosidebar": true,
        "console": false,
        "tostatus": false,
        "complete": "payload",
        "targetType": "msg",
        "statusVal": "",
        "statusType": "auto",
        "x": 610,
        "y": 60,
        "wires": []
    },
    {
        "id": "c67d98c0555b6858",
        "type": "debug",
        "z": "289f539dcc33814e",
        "name": "extract numeric part",
        "active": true,
        "tosidebar": true,
        "console": false,
        "tostatus": false,
        "complete": "payload",
        "targetType": "msg",
        "statusVal": "",
        "statusType": "auto",
        "x": 880,
        "y": 60,
        "wires": []
    },
    {
        "id": "012930c1c30f2970",
        "type": "change",
        "z": "289f539dcc33814e",
        "name": "",
        "rules": [
            {
                "t": "set",
                "p": "payload",
                "pt": "msg",
                "to": "$number(payload)\t",
                "tot": "jsonata"
            }
        ],
        "action": "",
        "property": "",
        "from": "",
        "to": "",
        "reg": false,
        "x": 870,
        "y": 120,
        "wires": [
            [
                "5673910b284fe352"
            ]
        ]
    },
    {
        "id": "5673910b284fe352",
        "type": "debug",
        "z": "289f539dcc33814e",
        "name": "Change type to number",
        "active": true,
        "tosidebar": true,
        "console": false,
        "tostatus": false,
        "complete": "payload",
        "targetType": "msg",
        "statusVal": "",
        "statusType": "auto",
        "x": 1110,
        "y": 120,
        "wires": []
    }
]

For the Gauge - dashboard node - I guess you need not to convert in to a type number - it can do this implicitly - so it should be sufficient if you take the numeric part out of the string - even if this is still a string. I hope you understand. :wink:

image

[
    {
        "id": "88fe65d84831eba2",
        "type": "inject",
        "z": "289f539dcc33814e",
        "name": "",
        "props": [
            {
                "p": "payload"
            }
        ],
        "repeat": "",
        "crontab": "",
        "once": false,
        "onceDelay": 0.1,
        "topic": "",
        "payload": "Percentage 80/Gallons 0.98",
        "payloadType": "str",
        "x": 230,
        "y": 120,
        "wires": [
            [
                "18f0b074693cf7ed"
            ]
        ]
    },
    {
        "id": "2e9f8212e2b043b0",
        "type": "change",
        "z": "289f539dcc33814e",
        "name": "extract topic and payload",
        "rules": [
            {
                "t": "set",
                "p": "topic",
                "pt": "msg",
                "to": "payload",
                "tot": "msg"
            },
            {
                "t": "change",
                "p": "payload",
                "pt": "msg",
                "from": ".*\\s(\\d+\\.?\\d?)",
                "fromt": "re",
                "to": "$1",
                "tot": "str"
            },
            {
                "t": "change",
                "p": "topic",
                "pt": "msg",
                "from": "(.*)\\s.*",
                "fromt": "re",
                "to": "$1",
                "tot": "str"
            }
        ],
        "action": "",
        "property": "",
        "from": "",
        "to": "",
        "reg": false,
        "x": 610,
        "y": 120,
        "wires": [
            [
                "c67d98c0555b6858",
                "012930c1c30f2970",
                "0af36594432d92f9"
            ]
        ]
    },
    {
        "id": "18f0b074693cf7ed",
        "type": "split",
        "z": "289f539dcc33814e",
        "name": "",
        "splt": "/",
        "spltType": "str",
        "arraySplt": 1,
        "arraySpltType": "len",
        "stream": false,
        "addname": "",
        "x": 390,
        "y": 120,
        "wires": [
            [
                "99433f4e031d2a16",
                "2e9f8212e2b043b0"
            ]
        ]
    },
    {
        "id": "99433f4e031d2a16",
        "type": "debug",
        "z": "289f539dcc33814e",
        "name": "Split by separator",
        "active": true,
        "tosidebar": true,
        "console": false,
        "tostatus": false,
        "complete": "payload",
        "targetType": "msg",
        "statusVal": "",
        "statusType": "auto",
        "x": 610,
        "y": 60,
        "wires": []
    },
    {
        "id": "c67d98c0555b6858",
        "type": "debug",
        "z": "289f539dcc33814e",
        "name": "extract numeric part",
        "active": true,
        "tosidebar": true,
        "console": false,
        "tostatus": false,
        "complete": "payload",
        "targetType": "msg",
        "statusVal": "",
        "statusType": "auto",
        "x": 880,
        "y": 60,
        "wires": []
    },
    {
        "id": "012930c1c30f2970",
        "type": "change",
        "z": "289f539dcc33814e",
        "d": true,
        "name": "",
        "rules": [
            {
                "t": "set",
                "p": "payload",
                "pt": "msg",
                "to": "$number(payload)\t",
                "tot": "jsonata"
            }
        ],
        "action": "",
        "property": "",
        "from": "",
        "to": "",
        "reg": false,
        "x": 870,
        "y": 120,
        "wires": [
            [
                "5673910b284fe352"
            ]
        ]
    },
    {
        "id": "5673910b284fe352",
        "type": "debug",
        "z": "289f539dcc33814e",
        "d": true,
        "name": "Change type to number",
        "active": true,
        "tosidebar": true,
        "console": false,
        "tostatus": false,
        "complete": "payload",
        "targetType": "msg",
        "statusVal": "",
        "statusType": "auto",
        "x": 1110,
        "y": 120,
        "wires": []
    },
    {
        "id": "0af36594432d92f9",
        "type": "switch",
        "z": "289f539dcc33814e",
        "name": "",
        "property": "topic",
        "propertyType": "msg",
        "rules": [
            {
                "t": "eq",
                "v": "Percentage",
                "vt": "str"
            }
        ],
        "checkall": "true",
        "repair": false,
        "outputs": 1,
        "x": 830,
        "y": 180,
        "wires": [
            [
                "6415cfe091538c2d"
            ]
        ]
    }
]

Thanks! This helped to streamline the data flow a lot. The gauge was fine with me leaving the % in there so I just did that.

I had to modify the approach a touch to display valve status but overall have that working decently. Next challenge will be valve control, which is really confusing. The device can only subscribe to 10 topics so I'm trying to control all of the valves using one topic. Getting that to work correctly is proving difficult!

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