Split sensor output

I currently have a sensor that outputs the following :- {"CurrentTemperature":32.8,"AirPressure":255} I want to split this into 2 messages of 32.8 and 255 can anyone give me some assistance please?

Not sure how you want to split them, so here are two examples

[{"id":"80f51f7.e550e6","type":"inject","z":"c74669a0.6a34f8","name":"button","props":[{"p":"payload"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"","payload":"{\"CurrentTemperature\":32.8,\"AirPressure\":255}","payloadType":"json","x":80,"y":3020,"wires":[["3e8fc37d.72ac0c","3b8973dd.e363dc"]]},{"id":"3e8fc37d.72ac0c","type":"change","z":"c74669a0.6a34f8","name":"","rules":[{"t":"set","p":"payload","pt":"msg","to":"payload.CurrentTemperature","tot":"msg"}],"action":"","property":"","from":"","to":"","reg":false,"x":310,"y":2980,"wires":[["eced12ca.e27228"]]},{"id":"3b8973dd.e363dc","type":"change","z":"c74669a0.6a34f8","name":"","rules":[{"t":"set","p":"payload","pt":"msg","to":"payload.AirPressure","tot":"msg"}],"action":"","property":"","from":"","to":"","reg":false,"x":310,"y":3060,"wires":[["c0a84d3d.bbac8"]]},{"id":"eced12ca.e27228","type":"debug","z":"c74669a0.6a34f8","name":"","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"false","statusVal":"","statusType":"auto","x":530,"y":2960,"wires":[]},{"id":"c0a84d3d.bbac8","type":"debug","z":"c74669a0.6a34f8","name":"","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"false","statusVal":"","statusType":"auto","x":550,"y":3040,"wires":[]},{"id":"dd75a682.36c55","type":"inject","z":"c74669a0.6a34f8","name":"button","props":[{"p":"payload"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"","payload":"{\"CurrentTemperature\":32.8,\"AirPressure\":255}","payloadType":"json","x":100,"y":2880,"wires":[["cf65bbff.663ab8"]]},{"id":"cf65bbff.663ab8","type":"split","z":"c74669a0.6a34f8","name":"","splt":"\\n","spltType":"str","arraySplt":1,"arraySpltType":"len","stream":false,"addname":"topic","x":260,"y":2880,"wires":[["808c0be9.aee96"]]},{"id":"808c0be9.aee96","type":"debug","z":"c74669a0.6a34f8","name":"","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"false","statusVal":"","statusType":"auto","x":480,"y":2880,"wires":[]}]
1 Like

If the output is a string, then send it through the json node. This formats a javascript object out of the string.
An then send the object through the split node.
With an attached debug node you can enjoy the result.
node-red is so cool.

1 Like

That's awesome many thanks!

Are you sure you need to split it? What are you going to do with the two messages?

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