How to filter some data to separate

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
}
}

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

[{"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 ```)

``` 
   code goes here 
```

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

See this post for more details - How to share code or flow json

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

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

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

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

[{"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

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