Separate topics

I have tried a split node, switch node probably wrong. And there is probably a simple way to do it.

object

topic: "Dining/dht1"

payload: object

temperature: 23.4

humidity: 59.6

qos: 0

retain: false

Is there a simple way to separate the values based on the name temperature & humidity then remove the name so only the value remains on two different debug nodes?

I'm guessing that you want an output something like this?

Try this flow

[{"id":"2b1db6cff0ff0516","type":"inject","z":"cd7e020b78297f7a","name":"","props":[{"p":"payload"},{"p":"topic","vt":"str"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"dining/dht1","payload":"{\"temperature\": 42, \"humidity\": 90}","payloadType":"json","x":305,"y":120,"wires":[["02e17b25343f8689"]]},{"id":"eed0e334329a42d4","type":"debug","z":"cd7e020b78297f7a","name":"Temperature","active":true,"tosidebar":true,"console":false,"tostatus":true,"complete":"Temperature","targetType":"msg","statusVal":"Temperature","statusType":"auto","x":655,"y":90,"wires":[]},{"id":"02e17b25343f8689","type":"change","z":"cd7e020b78297f7a","name":"","rules":[{"t":"delete","p":"topic","pt":"msg"},{"t":"move","p":"payload.temperature","pt":"msg","to":"Temperature","tot":"msg"},{"t":"move","p":"payload.humidity","pt":"msg","to":"Humidity","tot":"msg"}],"action":"","property":"","from":"","to":"","reg":false,"x":460,"y":120,"wires":[["eed0e334329a42d4","e3d2e85561651a6a"]]},{"id":"e3d2e85561651a6a","type":"debug","z":"cd7e020b78297f7a","name":"Humidity","active":true,"tosidebar":true,"console":false,"tostatus":true,"complete":"Humidity","targetType":"msg","statusVal":"Humidity","statusType":"auto","x":645,"y":150,"wires":[]}]

Or if you want two separate message payloads on different wires

[{"id":"2b1db6cff0ff0516","type":"inject","z":"613df62afc8a16bf","name":"","props":[{"p":"payload"},{"p":"topic","vt":"str"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"dining/dht1","payload":"{\"temperature\": 42, \"humidity\": 90}","payloadType":"json","x":250,"y":120,"wires":[["ed1d294022b465ed"]]},{"id":"ed1d294022b465ed","type":"split","z":"613df62afc8a16bf","name":"","splt":"\\n","spltType":"str","arraySplt":1,"arraySpltType":"len","stream":false,"addname":"","property":"payload","x":370,"y":120,"wires":[["20d40bc84d811fdd"]]},{"id":"20d40bc84d811fdd","type":"switch","z":"613df62afc8a16bf","name":"","property":"parts.key","propertyType":"msg","rules":[{"t":"eq","v":"humidity","vt":"str"},{"t":"eq","v":"temperature","vt":"str"}],"checkall":"true","repair":false,"outputs":2,"x":510,"y":120,"wires":[["e3d2e85561651a6a"],["eed0e334329a42d4"]]},{"id":"e3d2e85561651a6a","type":"debug","z":"613df62afc8a16bf","name":"humidity","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"payload","targetType":"msg","statusVal":"","statusType":"auto","x":660,"y":100,"wires":[]},{"id":"eed0e334329a42d4","type":"debug","z":"613df62afc8a16bf","name":"temperature","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"payload","targetType":"msg","statusVal":"","statusType":"auto","x":670,"y":140,"wires":[]}]

You can also copy the keys to msg.topic (or any other property) in the split node if required.

Worked awesome thank you so much.

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