# How to filter some data to separate

**URL:** https://discourse.nodered.org/t/how-to-filter-some-data-to-separate/87010
**Category:** General
**Created:** [4 April 2024 15:05 UTC](https://discourse.nodered.org/t/how-to-filter-some-data-to-separate/87010 "2024-04-04T15:05:50Z")
**Posts on this page:** 6
**Page:** 1

<div class="post-metadata">

### Author: ![spike318](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/spike318/32/79235_2.png) [@spike318](https://discourse.nodered.org/u/spike318)
#### Post date: [4 April 2024 15:05 UTC](https://discourse.nodered.org/t/how-to-filter-some-data-to-separate/87010/1 "2024-04-04T15:05:50Z")

</div>

I have this data but i want to sent them seperatly back to mqtt to use in domoticz  
for example this value to an IDX for Domoticz "cell\_hVt": 2.75,

{  
"Device": {  
"Name": "Daly2MQTT",  
"IP": "192.168.1.48",  
"ESP\_VCC": 3.375,  
"Wifi\_RSSI": -69,  
"Relais\_Active": false,  
"Relais\_Manual": false,  
"sw\_version": "2.13.0",  
"Flash\_Size": 4194304,  
"Sketch\_Size": 448544,  
"Free\_Sketch\_Space": 3723264  
},  
"Pack": {  
"Voltage": 26.8,  
"Current": 0,  
"Power": 0,  
"SOC": 96.7,  
"Remaining\_Ah": 58,  
"Cycles": 114,  
"BMS\_Temp": 13,  
"Cell\_Temp": 13,  
"cell\_hVt": 2.75,  
"cell\_lVt": 1.8,  
"cell\_hVt2": 2.66,  
"cell\_lVt2": 1.9,  
"pack\_hVt": 30.3,  
"pack\_lVt": 19.8,  
"pack\_hVt2": 28.8,  
"pack\_lVt2": 19,  
"High\_CellNr": 8,  
"High\_CellV": 2.445,  
"Low\_CellNr": 11,  
"Low\_CellV": 2.442,  
"Cell\_Diff": 3,  
"DischargeFET": true,  
"ChargeFET": true,  
"Status": "Stationary",  
"Cells": 11,  
"Heartbeat": 191,  
"Balance\_Active": false,  
"Fail\_Codes": ""  
},  
"CellV": {  
"CellV\_1": 2.443,  
"CellV\_2": 2.444,  
"CellV\_3": 2.444,  
"CellV\_4": 2.444,  
"CellV\_5": 2.444,  
"CellV\_6": 2.444,  
"CellV\_7": 2.444,  
"CellV\_8": 2.445,  
"CellV\_9": 2.445,  
"CellV\_10": 2.445,  
"CellV\_11": 2.442  
},  
"CellTemp": {  
"Cell\_Temp\_1": 13  
}  
}

---

<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: [4 April 2024 20:58 UTC](https://discourse.nodered.org/t/how-to-filter-some-data-to-separate/87010/2 "2024-04-04T20:58:52Z")

</div>

If you want just the one value you can use a change node to set payload to that value.

Or

If you want several different ones you can use a split and switch node to filter them out.

e.g

```auto
[{"id":"172551ac1ab40d8a","type":"inject","z":"d1395164b4eec73e","name":"","props":[{"p":"payload"},{"p":"topic","vt":"str"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"","payload":"{ \"Device\": { \"Name\": \"Daly2MQTT\", \"IP\": \"192.168.1.48\", \"ESP_VCC\": 3.375, \"Wifi_RSSI\": -69, \"Relais_Active\": false, \"Relais_Manual\": false, \"sw_version\": \"2.13.0\", \"Flash_Size\": 4194304, \"Sketch_Size\": 448544, \"Free_Sketch_Space\": 3723264 }, \"Pack\": { \"Voltage\": 26.8, \"Current\": 0, \"Power\": 0, \"SOC\": 96.7, \"Remaining_Ah\": 58, \"Cycles\": 114, \"BMS_Temp\": 13, \"Cell_Temp\": 13, \"cell_hVt\": 2.75, \"cell_lVt\": 1.8, \"cell_hVt2\": 2.66, \"cell_lVt2\": 1.9, \"pack_hVt\": 30.3, \"pack_lVt\": 19.8, \"pack_hVt2\": 28.8, \"pack_lVt2\": 19, \"High_CellNr\": 8, \"High_CellV\": 2.445, \"Low_CellNr\": 11, \"Low_CellV\": 2.442, \"Cell_Diff\": 3, \"DischargeFET\": true, \"ChargeFET\": true, \"Status\": \"Stationary\", \"Cells\": 11, \"Heartbeat\": 191, \"Balance_Active\": false, \"Fail_Codes\": \"\" }, \"CellV\": { \"CellV_1\": 2.443, \"CellV_2\": 2.444, \"CellV_3\": 2.444, \"CellV_4\": 2.444, \"CellV_5\": 2.444, \"CellV_6\": 2.444, \"CellV_7\": 2.444, \"CellV_8\": 2.445, \"CellV_9\": 2.445, \"CellV_10\": 2.445, \"CellV_11\": 2.442 }, \"CellTemp\": { \"Cell_Temp_1\": 13 } }","payloadType":"json","x":490,"y":6480,"wires":[["7b405ffd604b6d5d","4fb763d1a8be3fc4"]]},{"id":"7b405ffd604b6d5d","type":"change","z":"d1395164b4eec73e","name":"","rules":[{"t":"set","p":"payload","pt":"msg","to":"payload.Pack","tot":"msg"}],"action":"","property":"","from":"","to":"","reg":false,"x":640,"y":6480,"wires":[["c0987e33ce90b79f"]]},{"id":"4fb763d1a8be3fc4","type":"change","z":"d1395164b4eec73e","name":"","rules":[{"t":"set","p":"payload","pt":"msg","to":"payload.Pack.cell_hVt","tot":"msg"}],"action":"","property":"","from":"","to":"","reg":false,"x":640,"y":6560,"wires":[["faedbd4890a278aa"]]},{"id":"c0987e33ce90b79f","type":"split","z":"d1395164b4eec73e","name":"","splt":"\\n","spltType":"str","arraySplt":1,"arraySpltType":"len","stream":false,"addname":"","x":790,"y":6480,"wires":[["07eb262f81bec0cc"]]},{"id":"faedbd4890a278aa","type":"debug","z":"d1395164b4eec73e","name":"debug 2489","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"false","statusVal":"","statusType":"auto","x":810,"y":6560,"wires":[]},{"id":"07eb262f81bec0cc","type":"switch","z":"d1395164b4eec73e","name":"","property":"parts.key","propertyType":"msg","rules":[{"t":"eq","v":"cell_hVt","vt":"str"},{"t":"eq","v":"ESP_VCC","vt":"str"}],"checkall":"true","repair":false,"outputs":2,"x":910,"y":6480,"wires":[["e6abb1e4cfa61499"],[]]},{"id":"e6abb1e4cfa61499","type":"debug","z":"d1395164b4eec73e","name":"debug 2488","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"true","targetType":"full","statusVal":"","statusType":"auto","x":1070,"y":6480,"wires":[]}]

```

If this is not what you mean, you may want to explain with more detail.

p.s. When posting data/code etc please use the correct format, as it makes copying easier. more info about this below.

In order to make code readable and usable it is necessary to surround your code with three backticks (also known as a left quote or backquote `````)

````auto
``` 
   code goes here 
```

````

You can edit and correct your post by clicking the pencil ✏ icon.

See this post for more details - [How to share code or flow json](https://discourse.nodered.org/t/how-to-share-code-or-flow-json/506)

---

<div class="post-metadata">

### Author: ![spike318](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/spike318/32/79235_2.png) [@spike318](https://discourse.nodered.org/u/spike318)
#### Post date: [6 April 2024 09:12 UTC](https://discourse.nodered.org/t/how-to-filter-some-data-to-separate/87010/3 "2024-04-06T09:12:59Z")

</div>

i want seperate value's, but i found something input = Jonas\_MQTT\_Server  
Then i've created a Strind node with filter between example " between "CellV\_1": ,  
This gave me a singe value and then with filter i made an IDX to domoticz

msg.payload4 = msg.payload;  
msg.payload = {"idx":481,"nvalue":0,"svalue":msg.payload4};  
return msg;

and then sent it to domoticz in

Thankz for the help

---

<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: [6 April 2024 09:35 UTC](https://discourse.nodered.org/t/how-to-filter-some-data-to-separate/87010/4 "2024-04-06T09:35:17Z")

</div>

> [@spike318](#):
>
> msg.payload4 = msg.payload;  
> msg.payload = {"idx":481,"nvalue":0,"svalue":msg.payload4};  
> return msg;

In javascript you don't need the quotes round property names, unless they include special characters (you do need them in a JSON string though). Also you don't normally need the semi-colons. You can simplify your code to

```auto
msg.payload = {idx: 481, nvalue: 0, svalue: msg.payload}
return msg

```

---

<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: [6 April 2024 09:53 UTC](https://discourse.nodered.org/t/how-to-filter-some-data-to-separate/87010/5 "2024-04-06T09:53:51Z")

</div>

> [@spike318](#):
>
> Then i've created a Strind node with filter between example " between "CellV\_1": ,

Ok now I see that payload is a JSON (string), you can use a json node to convert to JS object, then there would be no need for the string node and you would have all the properties at hand.

Saying that, if you are using a mqtt in node it should recognise a JSON and parse it. What version of node-red are you using. Maybe post a export of your flow for clarification.

example

```auto
[{"id":"c0a4103fc6bdf1d0","type":"inject","z":"d1395164b4eec73e","name":"json (string)","props":[{"p":"payload"},{"p":"topic","vt":"str"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"","payload":"{ \"Device\": { \"Name\": \"Daly2MQTT\", \"IP\": \"192.168.1.48\", \"ESP_VCC\": 3.375, \"Wifi_RSSI\": -69, \"Relais_Active\": false, \"Relais_Manual\": false, \"sw_version\": \"2.13.0\", \"Flash_Size\": 4194304, \"Sketch_Size\": 448544, \"Free_Sketch_Space\": 3723264 }, \"Pack\": { \"Voltage\": 26.8, \"Current\": 0, \"Power\": 0, \"SOC\": 96.7, \"Remaining_Ah\": 58, \"Cycles\": 114, \"BMS_Temp\": 13, \"Cell_Temp\": 13, \"cell_hVt\": 2.75, \"cell_lVt\": 1.8, \"cell_hVt2\": 2.66, \"cell_lVt2\": 1.9, \"pack_hVt\": 30.3, \"pack_lVt\": 19.8, \"pack_hVt2\": 28.8, \"pack_lVt2\": 19, \"High_CellNr\": 8, \"High_CellV\": 2.445, \"Low_CellNr\": 11, \"Low_CellV\": 2.442, \"Cell_Diff\": 3, \"DischargeFET\": true, \"ChargeFET\": true, \"Status\": \"Stationary\", \"Cells\": 11, \"Heartbeat\": 191, \"Balance_Active\": false, \"Fail_Codes\": \"\" }, \"CellV\": { \"CellV_1\": 2.443, \"CellV_2\": 2.444, \"CellV_3\": 2.444, \"CellV_4\": 2.444, \"CellV_5\": 2.444, \"CellV_6\": 2.444, \"CellV_7\": 2.444, \"CellV_8\": 2.445, \"CellV_9\": 2.445, \"CellV_10\": 2.445, \"CellV_11\": 2.442 }, \"CellTemp\": { \"Cell_Temp_1\": 13 } }","payloadType":"str","x":210,"y":5540,"wires":[["66fe1da7dd414ea1"]]},{"id":"66fe1da7dd414ea1","type":"json","z":"d1395164b4eec73e","name":"","property":"payload","action":"","pretty":false,"x":450,"y":5540,"wires":[["90d82b0a110b1408"]]},{"id":"90d82b0a110b1408","type":"function","z":"d1395164b4eec73e","name":"function 156","func":"msg.payload = {idx: 481, nvalue: 0, svalue: msg.payload.cell_hVt};\nreturn msg;","outputs":1,"timeout":0,"noerr":0,"initialize":"","finalize":"","libs":[],"x":510,"y":5620,"wires":[["67488a1ff093273b"]]},{"id":"1e8f7c71650943cc","type":"inject","z":"d1395164b4eec73e","name":"javascript object","props":[{"p":"payload"},{"p":"topic","vt":"str"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"","payload":"{ \"Device\": { \"Name\": \"Daly2MQTT\", \"IP\": \"192.168.1.48\", \"ESP_VCC\": 3.375, \"Wifi_RSSI\": -69, \"Relais_Active\": false, \"Relais_Manual\": false, \"sw_version\": \"2.13.0\", \"Flash_Size\": 4194304, \"Sketch_Size\": 448544, \"Free_Sketch_Space\": 3723264 }, \"Pack\": { \"Voltage\": 26.8, \"Current\": 0, \"Power\": 0, \"SOC\": 96.7, \"Remaining_Ah\": 58, \"Cycles\": 114, \"BMS_Temp\": 13, \"Cell_Temp\": 13, \"cell_hVt\": 2.75, \"cell_lVt\": 1.8, \"cell_hVt2\": 2.66, \"cell_lVt2\": 1.9, \"pack_hVt\": 30.3, \"pack_lVt\": 19.8, \"pack_hVt2\": 28.8, \"pack_lVt2\": 19, \"High_CellNr\": 8, \"High_CellV\": 2.445, \"Low_CellNr\": 11, \"Low_CellV\": 2.442, \"Cell_Diff\": 3, \"DischargeFET\": true, \"ChargeFET\": true, \"Status\": \"Stationary\", \"Cells\": 11, \"Heartbeat\": 191, \"Balance_Active\": false, \"Fail_Codes\": \"\" }, \"CellV\": { \"CellV_1\": 2.443, \"CellV_2\": 2.444, \"CellV_3\": 2.444, \"CellV_4\": 2.444, \"CellV_5\": 2.444, \"CellV_6\": 2.444, \"CellV_7\": 2.444, \"CellV_8\": 2.445, \"CellV_9\": 2.445, \"CellV_10\": 2.445, \"CellV_11\": 2.442 }, \"CellTemp\": { \"Cell_Temp_1\": 13 } }","payloadType":"json","x":220,"y":5600,"wires":[["90d82b0a110b1408"]]},{"id":"67488a1ff093273b","type":"debug","z":"d1395164b4eec73e","name":"debug 2488","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"false","statusVal":"","statusType":"auto","x":590,"y":5660,"wires":[]}]

```

[How to import/export a flow](https://nodered.org/docs/user-guide/editor/workspace/import-export)

---

<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: [5 July 2024 09:54 UTC](https://discourse.nodered.org/t/how-to-filter-some-data-to-separate/87010/6 "2024-07-05T09:54:04Z")

</div>

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