# Splitting data advice

**URL:** <https://discourse.nodered.org/t/splitting-data-advice/54426>\
**Category:** General\
**Created:** [29 November 2021 00:10 UTC](https://discourse.nodered.org/t/splitting-data-advice/54426 "2021-11-29T00:10:53Z")\
**Posts on this page:** 9\
**Page:** 1

<div class="post-metadata">

**Author:** ![gregoinc](https://avatars.discourse-cdn.com/v4/letter/g/bbce88/32.png) [@gregoinc](https://discourse.nodered.org/u/gregoinc)\
**Post date:** [29 November 2021 00:10 UTC](https://discourse.nodered.org/t/splitting-data-advice/54426/1 "2021-11-29T00:10:53Z")

</div>

Hello,

I am receiving some data from an aqara temperature sensor and I really want to extract just the temperature data to send to my blynk app. Here's what I have setup...

 ![tempflow](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/3X/7/f/7f586e64cb73bbcec266d5c36f5298b1aeb029f7.jpeg)

Here's the code from the json node... kindly supplied by a person on another forum.

```auto
[{"id":"f91c0961d1a8d7db","type":"inject","z":"14ca354715bc92f3","name":"","props":[{"p":"payload"},{"p":"topic","vt":"str"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"","payload":"{\"battery\":100,\"humidity\":56.09,\"linkquality\":111,\"pressure\":1040,\"temperature\":21.35,\"voltage\":3065}","payloadType":"str","x":230,"y":640,"wires":[["b1664fd5d8d9d187"]]},{"id":"ed0a70bcd258ea58","type":"debug","z":"14ca354715bc92f3","name":"","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"true","targetType":"full","statusVal":"","statusType":"auto","x":550,"y":640,"wires":[]},{"id":"b1664fd5d8d9d187","type":"json","z":"14ca354715bc92f3","name":"","property":"payload","action":"","pretty":false,"x":400,"y":640,"wires":[["ed0a70bcd258ea58"]]}]

```

And here's the output from the json code...

![jsonoutput](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/3X/f/7/f7acdcf24059a4bdb60daf50ff193848f1fc8cb3.jpeg)

So all I need to do now is extract the **temperature:** value so I can send it to my blynk app.

Any advice appreciated.

---

<div class="post-metadata">

**Author:** ![E1cid](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/e1cid/32/77971_2.png) [@E1cid](https://discourse.nodered.org/u/E1cid)\
**Post date:** [29 November 2021 00:58 UTC](https://discourse.nodered.org/t/splitting-data-advice/54426/2 "2021-11-29T00:58:05Z")

</div>

You do not need the json node. You can set the mqtt node to output a json object.  
The documentation has information on how you can move and set message properties using change, function and template nodes here.  
[https://nodered.org/docs/user-guide/messages](https://nodered.org/docs/user-guide/messages)

---

<div class="post-metadata">

**Author:** ![gregoinc](https://avatars.discourse-cdn.com/v4/letter/g/bbce88/32.png) [@gregoinc](https://discourse.nodered.org/u/gregoinc)\
**Post date:** [29 November 2021 03:22 UTC](https://discourse.nodered.org/t/splitting-data-advice/54426/3 "2021-11-29T03:22:18Z")

</div>

Hi E1cid, thanks for guiding me to that info, much appreciated. I will watch the videos and read the info. I figure all I need to do is add a switch, and then redirect the temperature data.

I've added a switch, see below...

 ![PayloadSwitch](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/3X/4/5/450ff0dadd3a605f31269b8678ebac1726e6bf64.jpeg)

And configured it this way...  
 ![PayloadSwitchConfig](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/3X/2/c/2cfa1a61efad01d416e1c6b7acf1ea0af2ea4b74.jpeg)

Will see if that sends any data, but so far haven't seen anything.

---

<div class="post-metadata">

**Author:** ![bakman2](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/bakman2/32/6207_2.png) [@bakman2](https://discourse.nodered.org/u/bakman2)\
**Post date:** [29 November 2021 08:24 UTC](https://discourse.nodered.org/t/splitting-data-advice/54426/4 "2021-11-29T08:24:48Z")

</div>

How are you sending messages to the "blynk app", i assume you use a specific node for this ?

The switch node is used to "route" messages to different paths depending on their properties. This is different from your needs: you want to extract a value, you can use a change node for this.

 ![Screenshot 2021-11-29 at 09.23.03](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/3X/2/8/28984c9d3ab73ef1244ad4d533f06f063d2e2bc8.jpeg)

This depends on the output destination (your blynk node) - read the documentation for that node about the input it accepts.

---

<div class="post-metadata">

**Author:** ![E1cid](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/e1cid/32/77971_2.png) [@E1cid](https://discourse.nodered.org/u/E1cid)\
**Post date:** [29 November 2021 09:49 UTC](https://discourse.nodered.org/t/splitting-data-advice/54426/5 "2021-11-29T09:49:46Z")

</div>

As said the json node is not required.  
the switch will direct/filter messages down different routes  
the change node moves/sets and changes msg properties

have a look at this example

```auto
[{"id":"cf17e5bc.7a6888","type":"inject","z":"c791cbc0.84f648","name":"simulate data","props":[{"p":"payload"},{"p":"topic","vt":"str"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"","payload":"{\"humidity\":70,\"temerature\":19}","payloadType":"json","x":170,"y":660,"wires":[["84e13593.cc088"]]},{"id":"84e13593.cc088","type":"switch","z":"c791cbc0.84f648","name":"","property":"payload.temperature","propertyType":"msg","rules":[{"t":"btwn","v":"0","vt":"num","v2":"25","v2t":"num"},{"t":"else"}],"checkall":"true","repair":false,"outputs":2,"x":360,"y":660,"wires":[["aac72a22.0b5218"],["f775d2e6.87572"]]},{"id":"aac72a22.0b5218","type":"change","z":"c791cbc0.84f648","name":"","rules":[{"t":"move","p":"payload.temperaure","pt":"msg","to":"payload","tot":"msg"}],"action":"","property":"","from":"","to":"","reg":false,"x":610,"y":640,"wires":[["ff12e9c2.911248"]]},{"id":"f775d2e6.87572","type":"debug","z":"c791cbc0.84f648","name":"other stoff with data","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"payload","targetType":"msg","statusVal":"","statusType":"auto","x":690,"y":700,"wires":[]},{"id":"2e754cab.2110b4","type":"mqtt in","z":"c791cbc0.84f648","name":"set to output object","topic":"a/topic","qos":"0","datatype":"json","broker":"d675b749.04b9c8","x":200,"y":720,"wires":[["84e13593.cc088"]]},{"id":"ff12e9c2.911248","type":"debug","z":"c791cbc0.84f648","name":"temp","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"payload","targetType":"msg","statusVal":"","statusType":"auto","x":870,"y":620,"wires":[]},{"id":"d675b749.04b9c8","type":"mqtt-broker","name":"Localhost","broker":"localhost","port":"1883","clientid":"","usetls":false,"keepalive":"60","cleansession":true,"birthTopic":"","birthQos":"0","birthPayload":"","closeTopic":"","closeQos":"0","closePayload":"","willTopic":"","willQos":"0","willPayload":""}]

```

Press ctrl I , paste code and click import.

---

<div class="post-metadata">

**Author:** ![Colin](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/colin/32/17040_2.png) [@Colin](https://discourse.nodered.org/u/Colin)\
**Post date:** [29 November 2021 11:32 UTC](https://discourse.nodered.org/t/splitting-data-advice/54426/6 "2021-11-29T11:32:16Z")

</div>

@bakman2 I think you meant Move msg.payload.temperature To msg.payload, or Set msg.payload To the value msg.payload.temperature.

---

<div class="post-metadata">

**Author:** ![bakman2](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/bakman2/32/6207_2.png) [@bakman2](https://discourse.nodered.org/u/bakman2)\
**Post date:** [29 November 2021 11:38 UTC](https://discourse.nodered.org/t/splitting-data-advice/54426/7 "2021-11-29T11:38:15Z")

</div>

Yes you are correct it was early and still mix it up.

---

<div class="post-metadata">

**Author:** ![gregoinc](https://avatars.discourse-cdn.com/v4/letter/g/bbce88/32.png) [@gregoinc](https://discourse.nodered.org/u/gregoinc)\
**Post date:** [30 November 2021 01:32 UTC](https://discourse.nodered.org/t/splitting-data-advice/54426/8 "2021-11-30T01:32:08Z")

</div>

Hi E1cid, that worked really well, thank you so much for your help. I really appreciate the guidance as I am not that up to speed with json code. Thanks again.

@bakman2 thank you for your help, all of this assistance really makes this forum such a great place.

---

<div class="post-metadata">

**Author:** ![system](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/1X/d073cd938eafa2e558d7c2cd59003b3ef4963033.png) [@system](https://discourse.nodered.org/u/system)\
**Post date:** [14 December 2021 01:33 UTC](https://discourse.nodered.org/t/splitting-data-advice/54426/9 "2021-12-14T01:33:04Z")

</div>

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