Json Parsing how to extract the values, using best possible shortest code

2023-01-09 01_32_51-Node-RED _ careafox.com

Need Some Guidance in how to parse the requested Data
Need to extract temperature and humidity of all mac address

How do you want the output to be formatted?
Do you want a separate msg for each item, or combined as objects in a single msg?

Data is to be inserted into influxdb .

Whichever is the fastest path please suggest

The data you posted is a JavaScript object, not JSON.

This post should help to clarify the difference between Javascript objects and JSON.

Why do you want the shortest code? I always start with the simplest way of doing it, that is more important than the length of the code.

How often are you getting data? If it is not coming in at a rapid rate then I suggest that you use a Split node to split the array into separate messages which will make it easier to add to influx.

Next, do you know what fields and tags you want in the database? If not then you need to decide that. Then read the help text for the influxdb node and work out what message you must pass to the influx node.

If you are new to node red then I recommend watching this playlist: Node-RED Essentials. The videos are done by the developers of node-red. They're nice & short and to the point. You will understand a whole lot more in about 1 hour. A small investment for a lot of gain.

@Colin I have to say that post did nothing to clarify the difference for me!
Particularly confusing were the code snippets which look like this for me, regardless of browser.

But Stackexchange tells me that the OP's screenshot can't be JSON because the keys are not in quotes.

1 Like

I think the contents of that page may have changed (and the format messed up) since I wrote that canned reply, I will have to change it I think. Perhaps I will just write my own text. The key thing though is the phrase "JSON format is text only". JSON is always a string. Therefore the thing that shows that the data is a javascript object is

image

which says that it is an object. If it were JSON it would say String not Object. For example

image

Can someone help in extracting all values from this reference

{"msg":"advData","gmac":"94A408B0482C","obj":[{"type":1,"dmac":"BC572900A04B","time":"2023-01-09 15:21:57.560","rssi":-29,"ver":1,"vbatt":3576,"temp":-18.79,"humidty":75.84,"x0":15,"y0":-31,"z0":1046},{"type":1,"dmac":"BC572900A04B","time":"2023-01-09 15:21:57.764","rssi":-36,"ver":1,"vbatt":3576,"temp":-18.79,"humidty":75.84,"x0":0,"y0":-31,"z0":1031},{"type":1,"dmac":"BC572900A04B","time":"2023-01-09 15:21:57.764","rssi":-36,"ver":1,"vbatt":3576,"temp":-18.79,"humidty":75.84,"x0":15,"y0":-62,"z0":1046},{"type":1,"dmac":"BC572900A04B","time":"2023-01-09 15:21:57.961","rssi":-65,"ver":1,"vbatt":3576,"temp":-18.79,"humidty":75.84,"x0":15,"y0":-31,"z0":1031},{"type":1,"dmac":"BC572900A04B","time":"2023-01-09 15:21:57.961","rssi":-59,"ver":1,"vbatt":3576,"temp":-18.77,"humidty":75.77,"x0":0,"y0":-31,"z0":1046},{"type":1,"dmac":"BC572900A04B","time":"2023-01-09 15:21:58.161","rssi":-29,"ver":1,"vbatt":3576,"temp":-18.77,"humidty":75.77,"x0":15,"y0":-31,"z0":1031},{"type":1,"dmac":"BC572900A04B","time":"2023-01-09 15:21:58.161","rssi":-30,"ver":1,"vbatt":3576,"temp":-18.77,"humidty":75.77,"x0":31,"y0":-46,"z0":1046},{"type":1,"dmac":"BC572900A04B","time":"2023-01-09 15:21:58.367","rssi":-37,"ver":1,"vbatt":3576,"temp":-18.77,"humidty":75.77,"x0":15,"y0":-46,"z0":1031},{"type":1,"dmac":"BC572900A04B","time":"2023-01-09 15:21:58.367","rssi":-36,"ver":1,"vbatt":3576,"temp":-18.77,"humidty":75.77,"x0":31,"y0":-46,"z0":1046},{"type":1,"dmac":"BC572900A04B","time":"2023-01-09 15:21:58.563","rssi":-67,"ver":1,"vbatt":3576,"temp":-18.77,"humidty":75.77,"x0":31,"y0":-31,"z0":1031},{"type":1,"dmac":"BC572900A04B","time":"2023-01-09 15:21:58.563","rssi":-60,"ver":1,"vbatt":3576,"temp":-18.77,"humidty":75.77,"x0":15,"y0":-46,"z0":1046},{"type":1,"dmac":"BC572900A04B","time":"2023-01-09 15:21:58.764","rssi":-29,"ver":1,"vbatt":3576,"temp":-18.77,"humidty":75.77,"x0":15,"y0":-31,"z0":1031},{"type":1,"dmac":"BC572900A04B","time":"2023-01-09 15:21:58.764","rssi":-29,"ver":1,"vbatt":3576,"temp":-18.77,"humidty":75.77,"x0":15,"y0":-46,"z0":1031},{"type":1,"dmac":"BC572900A04B","time":"2023-01-09 15:21:58.965","rssi":-38,"ver":1,"vbatt":3576,"temp":-18.77,"humidty":75.77,"x0":15,"y0":-31,"z0":1031},{"type":1,"dmac":"BC572900A04B","time":"2023-01-09 15:21:58.965","rssi":-37,"ver":1,"vbatt":3576,"temp":-18.77,"humidty":75.77,"x0":0,"y0":-31,"z0":1046},{"type":1,"dmac":"BC572900A04B","time":"2023-01-09 15:21:59.273","rssi":-60,"ver":1,"vbatt":3576,"temp":-18.77,"humidty":75.77,"x0":15,"y0":-31,"z0":1046},{"type":1,"dmac":"BC572900A04B","time":"2023-01-09 15:21:59.273","rssi":-29,"ver":1,"vbatt":3576,"temp":-18.77,"humidty":75.77,"x0":15,"y0":-46,"z0":1046},{"type":1,"dmac":"BC572900A04B","time":"2023-01-09 15:21:59.465","rssi":-29,"ver":1,"vbatt":3576,"temp":-18.77,"humidty":75.77,"x0":15,"y0":-46,"z0":1046},{"type":1,"dmac":"BC572900A04B","time":"2023-01-09 15:21:59.465","rssi":-36,"ver":1,"vbatt":3576,"temp":-18.77,"humidty":75.77,"x0":31,"y0":-31,"z0":1031},{"type":1,"dmac":"BC572900A04B","time":"2023-01-09 15:21:59.670","rssi":-37,"ver":1,"vbatt":3576,"temp":-18.77,"humidty":75.77,"x0":15,"y0":-31,"z0":1031},{"type":1,"dmac":"BC572900A04B","time":"2023-01-09 15:21:59.670","rssi":-59,"ver":1,"vbatt":3576,"temp":-18.77,"humidty":75.77,"x0":15,"y0":-31,"z0":1015},{"type":1,"dmac":"BC572900A04B","time":"2023-01-09 15:21:59.873","rssi":-64,"ver":1,"vbatt":3576,"temp":-18.77,"humidty":75.77,"x0":15,"y0":-31,"z0":1062},{"type":1,"dmac":"BC572900A04B","time":"2023-01-09 15:21:59.873","rssi":-30,"ver":1,"vbatt":3576,"temp":-18.77,"humidty":75.77,"x0":15,"y0":-31,"z0":1031},{"type":1,"dmac":"BC572900A04B","time":"2023-01-09 15:22:00.067","rssi":-29,"ver":1,"vbatt":3576,"temp":-18.77,"humidty":75.77,"x0":15,"y0":-31,"z0":1031},{"type":1,"dmac":"BC572900A04B","time":"2023-01-09 15:22:00.067","rssi":-29,"ver":1,"vbatt":3576,"temp":-18.77,"humidty":75.77,"x0":15,"y0":-31,"z0":1031},{"type":1,"dmac":"BC572900A04B","time":"2023-01-09 15:22:00.273","rssi":-36,"ver":1,"vbatt":3576,"temp":-18.77,"humidty":75.77,"x0":15,"y0":-31,"z0":1046},{"type":1,"dmac":"BC572900A04B","time":"2023-01-09 15:22:00.273","rssi":-37,"ver":1,"vbatt":3576,"temp":-18.77,"humidty":75.77,"x0":15,"y0":-31,"z0":1046},{"type":1,"dmac":"BC572900A04B","time":"2023-01-09 15:22:00.470","rssi":-60,"ver":1,"vbatt":3576,"temp":-18.77,"humidty":75.77,"x0":15,"y0":-46,"z0":1046},{"type":1,"dmac":"BC572900A04B","time":"2023-01-09 15:22:00.470","rssi":-30,"ver":1,"vbatt":3576,"temp":-18.77,"humidty":75.77,"x0":31,"y0":-46,"z0":1046},{"type":1,"dmac":"BC5729009F06","time":"2023-01-09 15:21:58.367","rssi":-30,"ver":1,"vbatt":3594,"temp":4.58,"humidty":31.47},{"type":1,"dmac":"BC5729009F06","time":"2023-01-09 15:21:59.465","rssi":-33,"ver":1,"vbatt":3594,"temp":4.57,"humidty":31.45},{"type":1,"dmac":"BC5729009F06","time":"2023-01-09 15:22:00.470","rssi":-57,"ver":1,"vbatt":3594,"temp":4.56,"humidty":31.41},{"type":1,"dmac":"BC5729009FE2","time":"2023-01-09 15:22:00.067","rssi":-81,"ver":1,"vbatt":3675,"temp":28.39,"humidty":51.85,"x0":-281,"y0":203,"z0":968}]}

Extract all dmac from the data and save to a file with temp

The raw data is mentioned below

{"msg":"advData","gmac":"94A408B0482C","obj":[{"type":1,"dmac":"BC572900A04B","time":"2023-01-09 15:25:01.907","rssi":-29,"ver":1,"vbatt":3576,"temp":-19.21,"humidty":71.8,"x0":31,"y0":-46,"z0":1046},{"type":1,"dmac":"BC572900A04B","time":"2023-01-09 15:25:01.907","rssi":-29,"ver":1,"vbatt":3576,"temp":-19.21,"humidty":71.8,"x0":15,"y0":-31,"z0":1031},{"type":1,"dmac":"BC572900A04B","time":"2023-01-09 15:25:02.087","rssi":-36,"ver":1,"vbatt":3576,"temp":-19.21,"humidty":71.8,"x0":0,"y0":-15,"z0":1046},{"type":1,"dmac":"BC572900A04B","time":"2023-01-09 15:25:02.087","rssi":-37,"ver":1,"vbatt":3576,"temp":-19.21,"humidty":71.8,"x0":31,"y0":-15,"z0":1031},{"type":1,"dmac":"BC572900A04B","time":"2023-01-09 15:25:02.292","rssi":-60,"ver":1,"vbatt":3576,"temp":-19.21,"humidty":71.8,"x0":0,"y0":-31,"z0":1046},{"type":1,"dmac":"BC572900A04B","time":"2023-01-09 15:25:02.292","rssi":-57,"ver":1,"vbatt":3576,"temp":-19.21,"humidty":71.8,"x0":15,"y0":-46,"z0":1046},{"type":1,"dmac":"BC572900A04B","time":"2023-01-09 15:25:02.488","rssi":-29,"ver":1,"vbatt":3576,"temp":-19.21,"humidty":71.8,"x0":15,"y0":-31,"z0":1031},{"type":1,"dmac":"BC572900A04B","time":"2023-01-09 15:25:02.488","rssi":-29,"ver":1,"vbatt":3576,"temp":-19.21,"humidty":71.8,"x0":31,"y0":-46,"z0":1031},{"type":1,"dmac":"BC572900A04B","time":"2023-01-09 15:25:02.648","rssi":-29,"ver":1,"vbatt":3576,"temp":-19.21,"humidty":71.8,"x0":15,"y0":-31,"z0":1031},{"type":1,"dmac":"BC572900A04B","time":"2023-01-09 15:25:02.648","rssi":-36,"ver":1,"vbatt":3576,"temp":-19.21,"humidty":71.8,"x0":0,"y0":-46,"z0":1046},{"type":1,"dmac":"BC572900A04B","time":"2023-01-09 15:25:02.890","rssi":-55,"ver":1,"vbatt":3576,"temp":-19.21,"humidty":71.8,"x0":15,"y0":-15,"z0":1031},{"type":1,"dmac":"BC572900A04B","time":"2023-01-09 15:25:02.890","rssi":-55,"ver":1,"vbatt":3576,"temp":-19.21,"humidty":71.8,"x0":15,"y0":-62,"z0":1046},{"type":1,"dmac":"BC572900A04B","time":"2023-01-09 15:25:03.096","rssi":-57,"ver":1,"vbatt":3576,"temp":-19.21,"humidty":71.8,"x0":15,"y0":-31,"z0":1031},{"type":1,"dmac":"BC572900A04B","time":"2023-01-09 15:25:03.096","rssi":-30,"ver":1,"vbatt":3576,"temp":-19.21,"humidty":71.8,"x0":0,"y0":-31,"z0":1046},{"type":1,"dmac":"BC572900A04B","time":"2023-01-09 15:25:03.290","rssi":-36,"ver":1,"vbatt":3576,"temp":-19.21,"humidty":71.8,"x0":15,"y0":-31,"z0":1031},{"type":1,"dmac":"BC572900A04B","time":"2023-01-09 15:25:03.290","rssi":-36,"ver":1,"vbatt":3576,"temp":-19.21,"humidty":71.8,"x0":0,"y0":-46,"z0":1046},{"type":1,"dmac":"BC572900A04B","time":"2023-01-09 15:25:03.490","rssi":-56,"ver":1,"vbatt":3576,"temp":-19.21,"humidty":71.8,"x0":15,"y0":-31,"z0":1031},{"type":1,"dmac":"BC572900A04B","time":"2023-01-09 15:25:03.490","rssi":-56,"ver":1,"vbatt":3576,"temp":-19.21,"humidty":71.8,"x0":15,"y0":-46,"z0":1046},{"type":1,"dmac":"BC572900A04B","time":"2023-01-09 15:25:03.690","rssi":-30,"ver":1,"vbatt":3576,"temp":-19.21,"humidty":71.8,"x0":15,"y0":-46,"z0":1031},{"type":1,"dmac":"BC572900A04B","time":"2023-01-09 15:25:03.690","rssi":-30,"ver":1,"vbatt":3576,"temp":-19.21,"humidty":71.8,"x0":0,"y0":-31,"z0":1046},{"type":1,"dmac":"BC572900A04B","time":"2023-01-09 15:25:03.996","rssi":-36,"ver":1,"vbatt":3576,"temp":-19.21,"humidty":71.8,"x0":0,"y0":-62,"z0":1062},{"type":1,"dmac":"BC572900A04B","time":"2023-01-09 15:25:03.996","rssi":-56,"ver":1,"vbatt":3576,"temp":-19.21,"humidty":71.8,"x0":31,"y0":-31,"z0":1031},{"type":1,"dmac":"BC572900A04B","time":"2023-01-09 15:25:03.996","rssi":-37,"ver":1,"vbatt":3576,"temp":-19.21,"humidty":71.8,"x0":31,"y0":-31,"z0":1031},{"type":1,"dmac":"BC572900A04B","time":"2023-01-09 15:25:04.301","rssi":-57,"ver":1,"vbatt":3576,"temp":-19.22,"humidty":71.74,"x0":31,"y0":-31,"z0":1031},{"type":1,"dmac":"BC572900A04B","time":"2023-01-09 15:25:04.301","rssi":-30,"ver":1,"vbatt":3576,"temp":-19.22,"humidty":71.74,"x0":0,"y0":-31,"z0":1046},{"type":1,"dmac":"BC572900A04B","time":"2023-01-09 15:25:04.498","rssi":-30,"ver":1,"vbatt":3576,"temp":-19.22,"humidty":71.74,"x0":15,"y0":-31,"z0":1046},{"type":1,"dmac":"BC572900A04B","time":"2023-01-09 15:25:04.498","rssi":-38,"ver":1,"vbatt":3576,"temp":-19.22,"humidty":71.74,"x0":15,"y0":-46,"z0":1046},{"type":1,"dmac":"BC572900A04B","time":"2023-01-09 15:25:04.654","rssi":-37,"ver":1,"vbatt":3576,"temp":-19.22,"humidty":71.74,"x0":31,"y0":-46,"z0":1031},{"type":1,"dmac":"BC572900A04B","time":"2023-01-09 15:25:04.654","rssi":-58,"ver":1,"vbatt":3576,"temp":-19.22,"humidty":71.74,"x0":15,"y0":-46,"z0":1046},{"type":1,"dmac":"BC5729009F06","time":"2023-01-09 15:25:02.648","rssi":-33,"ver":1,"vbatt":3594,"temp":4.55,"humidty":28.38},{"type":1,"dmac":"BC5729009F06","time":"2023-01-09 15:25:04.654","rssi":-33,"ver":1,"vbatt":3594,"temp":4.56,"humidty":28.41},{"type":1,"dmac":"BC5729009415","time":"2023-01-09 15:25:03.096","rssi":-86,"ver":1,"vbatt":3617,"temp":27.55,"humidty":-1}]}

Here is a simple example hope it helps.

[{"id":"42e349d0f425b1d4","type":"inject","z":"da8a6ef0b3c9a5c8","name":"","props":[{"p":"payload"},{"p":"topic","vt":"str"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"","payload":"{\"msg\":\"advData\",\"gmac\":\"94A408B0482C\",\"obj\":[{\"type\":1,\"dmac\":\"BC572900A04B\",\"time\":\"2023-01-09 15:25:01.907\",\"rssi\":-29,\"ver\":1,\"vbatt\":3576,\"temp\":-19.21,\"humidty\":71.8,\"x0\":31,\"y0\":-46,\"z0\":1046},{\"type\":1,\"dmac\":\"BC572900A04B\",\"time\":\"2023-01-09 15:25:01.907\",\"rssi\":-29,\"ver\":1,\"vbatt\":3576,\"temp\":-19.21,\"humidty\":71.8,\"x0\":15,\"y0\":-31,\"z0\":1031},{\"type\":1,\"dmac\":\"BC572900A04B\",\"time\":\"2023-01-09 15:25:02.087\",\"rssi\":-36,\"ver\":1,\"vbatt\":3576,\"temp\":-19.21,\"humidty\":71.8,\"x0\":0,\"y0\":-15,\"z0\":1046},{\"type\":1,\"dmac\":\"BC572900A04B\",\"time\":\"2023-01-09 15:25:02.087\",\"rssi\":-37,\"ver\":1,\"vbatt\":3576,\"temp\":-19.21,\"humidty\":71.8,\"x0\":31,\"y0\":-15,\"z0\":1031},{\"type\":1,\"dmac\":\"BC572900A04B\",\"time\":\"2023-01-09 15:25:02.292\",\"rssi\":-60,\"ver\":1,\"vbatt\":3576,\"temp\":-19.21,\"humidty\":71.8,\"x0\":0,\"y0\":-31,\"z0\":1046},{\"type\":1,\"dmac\":\"BC572900A04B\",\"time\":\"2023-01-09 15:25:02.292\",\"rssi\":-57,\"ver\":1,\"vbatt\":3576,\"temp\":-19.21,\"humidty\":71.8,\"x0\":15,\"y0\":-46,\"z0\":1046},{\"type\":1,\"dmac\":\"BC572900A04B\",\"time\":\"2023-01-09 15:25:02.488\",\"rssi\":-29,\"ver\":1,\"vbatt\":3576,\"temp\":-19.21,\"humidty\":71.8,\"x0\":15,\"y0\":-31,\"z0\":1031},{\"type\":1,\"dmac\":\"BC572900A04B\",\"time\":\"2023-01-09 15:25:02.488\",\"rssi\":-29,\"ver\":1,\"vbatt\":3576,\"temp\":-19.21,\"humidty\":71.8,\"x0\":31,\"y0\":-46,\"z0\":1031},{\"type\":1,\"dmac\":\"BC572900A04B\",\"time\":\"2023-01-09 15:25:02.648\",\"rssi\":-29,\"ver\":1,\"vbatt\":3576,\"temp\":-19.21,\"humidty\":71.8,\"x0\":15,\"y0\":-31,\"z0\":1031},{\"type\":1,\"dmac\":\"BC572900A04B\",\"time\":\"2023-01-09 15:25:02.648\",\"rssi\":-36,\"ver\":1,\"vbatt\":3576,\"temp\":-19.21,\"humidty\":71.8,\"x0\":0,\"y0\":-46,\"z0\":1046},{\"type\":1,\"dmac\":\"BC572900A04B\",\"time\":\"2023-01-09 15:25:02.890\",\"rssi\":-55,\"ver\":1,\"vbatt\":3576,\"temp\":-19.21,\"humidty\":71.8,\"x0\":15,\"y0\":-15,\"z0\":1031},{\"type\":1,\"dmac\":\"BC572900A04B\",\"time\":\"2023-01-09 15:25:02.890\",\"rssi\":-55,\"ver\":1,\"vbatt\":3576,\"temp\":-19.21,\"humidty\":71.8,\"x0\":15,\"y0\":-62,\"z0\":1046},{\"type\":1,\"dmac\":\"BC572900A04B\",\"time\":\"2023-01-09 15:25:03.096\",\"rssi\":-57,\"ver\":1,\"vbatt\":3576,\"temp\":-19.21,\"humidty\":71.8,\"x0\":15,\"y0\":-31,\"z0\":1031},{\"type\":1,\"dmac\":\"BC572900A04B\",\"time\":\"2023-01-09 15:25:03.096\",\"rssi\":-30,\"ver\":1,\"vbatt\":3576,\"temp\":-19.21,\"humidty\":71.8,\"x0\":0,\"y0\":-31,\"z0\":1046},{\"type\":1,\"dmac\":\"BC572900A04B\",\"time\":\"2023-01-09 15:25:03.290\",\"rssi\":-36,\"ver\":1,\"vbatt\":3576,\"temp\":-19.21,\"humidty\":71.8,\"x0\":15,\"y0\":-31,\"z0\":1031},{\"type\":1,\"dmac\":\"BC572900A04B\",\"time\":\"2023-01-09 15:25:03.290\",\"rssi\":-36,\"ver\":1,\"vbatt\":3576,\"temp\":-19.21,\"humidty\":71.8,\"x0\":0,\"y0\":-46,\"z0\":1046},{\"type\":1,\"dmac\":\"BC572900A04B\",\"time\":\"2023-01-09 15:25:03.490\",\"rssi\":-56,\"ver\":1,\"vbatt\":3576,\"temp\":-19.21,\"humidty\":71.8,\"x0\":15,\"y0\":-31,\"z0\":1031},{\"type\":1,\"dmac\":\"BC572900A04B\",\"time\":\"2023-01-09 15:25:03.490\",\"rssi\":-56,\"ver\":1,\"vbatt\":3576,\"temp\":-19.21,\"humidty\":71.8,\"x0\":15,\"y0\":-46,\"z0\":1046},{\"type\":1,\"dmac\":\"BC572900A04B\",\"time\":\"2023-01-09 15:25:03.690\",\"rssi\":-30,\"ver\":1,\"vbatt\":3576,\"temp\":-19.21,\"humidty\":71.8,\"x0\":15,\"y0\":-46,\"z0\":1031},{\"type\":1,\"dmac\":\"BC572900A04B\",\"time\":\"2023-01-09 15:25:03.690\",\"rssi\":-30,\"ver\":1,\"vbatt\":3576,\"temp\":-19.21,\"humidty\":71.8,\"x0\":0,\"y0\":-31,\"z0\":1046},{\"type\":1,\"dmac\":\"BC572900A04B\",\"time\":\"2023-01-09 15:25:03.996\",\"rssi\":-36,\"ver\":1,\"vbatt\":3576,\"temp\":-19.21,\"humidty\":71.8,\"x0\":0,\"y0\":-62,\"z0\":1062},{\"type\":1,\"dmac\":\"BC572900A04B\",\"time\":\"2023-01-09 15:25:03.996\",\"rssi\":-56,\"ver\":1,\"vbatt\":3576,\"temp\":-19.21,\"humidty\":71.8,\"x0\":31,\"y0\":-31,\"z0\":1031},{\"type\":1,\"dmac\":\"BC572900A04B\",\"time\":\"2023-01-09 15:25:03.996\",\"rssi\":-37,\"ver\":1,\"vbatt\":3576,\"temp\":-19.21,\"humidty\":71.8,\"x0\":31,\"y0\":-31,\"z0\":1031},{\"type\":1,\"dmac\":\"BC572900A04B\",\"time\":\"2023-01-09 15:25:04.301\",\"rssi\":-57,\"ver\":1,\"vbatt\":3576,\"temp\":-19.22,\"humidty\":71.74,\"x0\":31,\"y0\":-31,\"z0\":1031},{\"type\":1,\"dmac\":\"BC572900A04B\",\"time\":\"2023-01-09 15:25:04.301\",\"rssi\":-30,\"ver\":1,\"vbatt\":3576,\"temp\":-19.22,\"humidty\":71.74,\"x0\":0,\"y0\":-31,\"z0\":1046},{\"type\":1,\"dmac\":\"BC572900A04B\",\"time\":\"2023-01-09 15:25:04.498\",\"rssi\":-30,\"ver\":1,\"vbatt\":3576,\"temp\":-19.22,\"humidty\":71.74,\"x0\":15,\"y0\":-31,\"z0\":1046},{\"type\":1,\"dmac\":\"BC572900A04B\",\"time\":\"2023-01-09 15:25:04.498\",\"rssi\":-38,\"ver\":1,\"vbatt\":3576,\"temp\":-19.22,\"humidty\":71.74,\"x0\":15,\"y0\":-46,\"z0\":1046},{\"type\":1,\"dmac\":\"BC572900A04B\",\"time\":\"2023-01-09 15:25:04.654\",\"rssi\":-37,\"ver\":1,\"vbatt\":3576,\"temp\":-19.22,\"humidty\":71.74,\"x0\":31,\"y0\":-46,\"z0\":1031},{\"type\":1,\"dmac\":\"BC572900A04B\",\"time\":\"2023-01-09 15:25:04.654\",\"rssi\":-58,\"ver\":1,\"vbatt\":3576,\"temp\":-19.22,\"humidty\":71.74,\"x0\":15,\"y0\":-46,\"z0\":1046},{\"type\":1,\"dmac\":\"BC5729009F06\",\"time\":\"2023-01-09 15:25:02.648\",\"rssi\":-33,\"ver\":1,\"vbatt\":3594,\"temp\":4.55,\"humidty\":28.38},{\"type\":1,\"dmac\":\"BC5729009F06\",\"time\":\"2023-01-09 15:25:04.654\",\"rssi\":-33,\"ver\":1,\"vbatt\":3594,\"temp\":4.56,\"humidty\":28.41},{\"type\":1,\"dmac\":\"BC5729009415\",\"time\":\"2023-01-09 15:25:03.096\",\"rssi\":-86,\"ver\":1,\"vbatt\":3617,\"temp\":27.55,\"humidty\":-1}]}","payloadType":"json","x":90,"y":3100,"wires":[["7ef12bbc7f26a602"]]},{"id":"7ef12bbc7f26a602","type":"change","z":"da8a6ef0b3c9a5c8","name":"","rules":[{"t":"move","p":"payload.obj","pt":"msg","to":"payload","tot":"msg"}],"action":"","property":"","from":"","to":"","reg":false,"x":180,"y":3140,"wires":[["bf91320d6abf801a"]]},{"id":"bf91320d6abf801a","type":"csv","z":"da8a6ef0b3c9a5c8","name":"","sep":",","hdrin":"","hdrout":"none","multi":"one","ret":"\\n","temp":"dmac,temp","skip":"0","strings":true,"include_empty_strings":"","include_null_values":"","x":350,"y":3140,"wires":[["9dd2e82a49f9ccd4"]]},{"id":"9dd2e82a49f9ccd4","type":"file","z":"da8a6ef0b3c9a5c8","name":"","filename":"/path /tofile.csv","filenameType":"str","appendNewline":true,"createDir":false,"overwriteFile":"false","encoding":"none","x":520,"y":3140,"wires":[["2d0dd892de6d450f"]]},{"id":"2d0dd892de6d450f","type":"debug","z":"da8a6ef0b3c9a5c8","name":"debug 224","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"false","statusVal":"","statusType":"auto","x":430,"y":3100,"wires":[]}]

Is it possible to send this to Influx or Mysql Database directly

Yes it is possible.

You need to supply info request by other contributors, as to do what you ask requires what fields and tags you wish to save.

msg.payload = [{
    device_mac: device_macaddr,
    temp: Temp,
    Battery: Batt,
    rssi: device_rssi,
    Upload_time: influx_uploadtime_custom,
    date: influx_time_custom,
    Influx_timestamp: time,
    Latitude: device_lat,
    Longitude: device_lon,
    device_voltage: voltage,
    device_mask: sensormask,
    device_temperature: Temp,
    device_humidity: Humidity,
    raw_data: raw,
    raw_length_int: raw_length,
    rssi_distance: calculateDistance(msg.payload.rssi),
},
{
     
     
     
    
    host: msg.payload.mac.toUpperCase(),
    device_mac: msg.payload.mac.toUpperCase(),
    location: msg.payload.mac.toUpperCase(),
    gateway: "MADDRES",
    device_info: msg.payload.name


}];
return msg;

This is the format , which I need to push back to mysql or influx db.
All Records

I can't relate that to the "raw data" you posted before.

Anyway, since you don't seem to care what sort of database, and you have not shared the schema, I produced a flow to insert the raw data into MySQL. Obviously I defined a table for this data, I expect you can infer the schema from the function code.

[{"id":"047642bda9e2093c","type":"function","z":"cfb92dc5a11cbc66","name":"raw data","func":"msg.payload = [{ \"type\": 1, \"dmac\": \"BC572900A04B\", \"time\": \"2023-01-09 15:25:01.907\", \"rssi\": -29, \"ver\": 1, \"vbatt\": 3576, \"temp\": -19.21, \"humidty\": 71.8, \"x0\": 31, \"y0\": -46, \"z0\": 1046 }, { \"type\": 1, \"dmac\": \"BC572900A04B\", \"time\": \"2023-01-09 15:25:01.907\", \"rssi\": -29, \"ver\": 1, \"vbatt\": 3576, \"temp\": -19.21, \"humidty\": 71.8, \"x0\": 15, \"y0\": -31, \"z0\": 1031 }, { \"type\": 1, \"dmac\": \"BC572900A04B\", \"time\": \"2023-01-09 15:25:02.087\", \"rssi\": -36, \"ver\": 1, \"vbatt\": 3576, \"temp\": -19.21, \"humidty\": 71.8, \"x0\": 0, \"y0\": -15, \"z0\": 1046 }, { \"type\": 1, \"dmac\": \"BC572900A04B\", \"time\": \"2023-01-09 15:25:02.087\", \"rssi\": -37, \"ver\": 1, \"vbatt\": 3576, \"temp\": -19.21, \"humidty\": 71.8, \"x0\": 31, \"y0\": -15, \"z0\": 1031 }, { \"type\": 1, \"dmac\": \"BC572900A04B\", \"time\": \"2023-01-09 15:25:02.292\", \"rssi\": -60, \"ver\": 1, \"vbatt\": 3576, \"temp\": -19.21, \"humidty\": 71.8, \"x0\": 0, \"y0\": -31, \"z0\": 1046 }, { \"type\": 1, \"dmac\": \"BC572900A04B\", \"time\": \"2023-01-09 15:25:02.292\", \"rssi\": -57, \"ver\": 1, \"vbatt\": 3576, \"temp\": -19.21, \"humidty\": 71.8, \"x0\": 15, \"y0\": -46, \"z0\": 1046 }, { \"type\": 1, \"dmac\": \"BC572900A04B\", \"time\": \"2023-01-09 15:25:02.488\", \"rssi\": -29, \"ver\": 1, \"vbatt\": 3576, \"temp\": -19.21, \"humidty\": 71.8, \"x0\": 15, \"y0\": -31, \"z0\": 1031 }, { \"type\": 1, \"dmac\": \"BC572900A04B\", \"time\": \"2023-01-09 15:25:02.488\", \"rssi\": -29, \"ver\": 1, \"vbatt\": 3576, \"temp\": -19.21, \"humidty\": 71.8, \"x0\": 31, \"y0\": -46, \"z0\": 1031 }, { \"type\": 1, \"dmac\": \"BC572900A04B\", \"time\": \"2023-01-09 15:25:02.648\", \"rssi\": -29, \"ver\": 1, \"vbatt\": 3576, \"temp\": -19.21, \"humidty\": 71.8, \"x0\": 15, \"y0\": -31, \"z0\": 1031 }, { \"type\": 1, \"dmac\": \"BC572900A04B\", \"time\": \"2023-01-09 15:25:02.648\", \"rssi\": -36, \"ver\": 1, \"vbatt\": 3576, \"temp\": -19.21, \"humidty\": 71.8, \"x0\": 0, \"y0\": -46, \"z0\": 1046 }, { \"type\": 1, \"dmac\": \"BC572900A04B\", \"time\": \"2023-01-09 15:25:02.890\", \"rssi\": -55, \"ver\": 1, \"vbatt\": 3576, \"temp\": -19.21, \"humidty\": 71.8, \"x0\": 15, \"y0\": -15, \"z0\": 1031 }, { \"type\": 1, \"dmac\": \"BC572900A04B\", \"time\": \"2023-01-09 15:25:02.890\", \"rssi\": -55, \"ver\": 1, \"vbatt\": 3576, \"temp\": -19.21, \"humidty\": 71.8, \"x0\": 15, \"y0\": -62, \"z0\": 1046 }, { \"type\": 1, \"dmac\": \"BC572900A04B\", \"time\": \"2023-01-09 15:25:03.096\", \"rssi\": -57, \"ver\": 1, \"vbatt\": 3576, \"temp\": -19.21, \"humidty\": 71.8, \"x0\": 15, \"y0\": -31, \"z0\": 1031 }, { \"type\": 1, \"dmac\": \"BC572900A04B\", \"time\": \"2023-01-09 15:25:03.096\", \"rssi\": -30, \"ver\": 1, \"vbatt\": 3576, \"temp\": -19.21, \"humidty\": 71.8, \"x0\": 0, \"y0\": -31, \"z0\": 1046 }, { \"type\": 1, \"dmac\": \"BC572900A04B\", \"time\": \"2023-01-09 15:25:03.290\", \"rssi\": -36, \"ver\": 1, \"vbatt\": 3576, \"temp\": -19.21, \"humidty\": 71.8, \"x0\": 15, \"y0\": -31, \"z0\": 1031 }, { \"type\": 1, \"dmac\": \"BC572900A04B\", \"time\": \"2023-01-09 15:25:03.290\", \"rssi\": -36, \"ver\": 1, \"vbatt\": 3576, \"temp\": -19.21, \"humidty\": 71.8, \"x0\": 0, \"y0\": -46, \"z0\": 1046 }, { \"type\": 1, \"dmac\": \"BC572900A04B\", \"time\": \"2023-01-09 15:25:03.490\", \"rssi\": -56, \"ver\": 1, \"vbatt\": 3576, \"temp\": -19.21, \"humidty\": 71.8, \"x0\": 15, \"y0\": -31, \"z0\": 1031 }, { \"type\": 1, \"dmac\": \"BC572900A04B\", \"time\": \"2023-01-09 15:25:03.490\", \"rssi\": -56, \"ver\": 1, \"vbatt\": 3576, \"temp\": -19.21, \"humidty\": 71.8, \"x0\": 15, \"y0\": -46, \"z0\": 1046 }, { \"type\": 1, \"dmac\": \"BC572900A04B\", \"time\": \"2023-01-09 15:25:03.690\", \"rssi\": -30, \"ver\": 1, \"vbatt\": 3576, \"temp\": -19.21, \"humidty\": 71.8, \"x0\": 15, \"y0\": -46, \"z0\": 1031 }, { \"type\": 1, \"dmac\": \"BC572900A04B\", \"time\": \"2023-01-09 15:25:03.690\", \"rssi\": -30, \"ver\": 1, \"vbatt\": 3576, \"temp\": -19.21, \"humidty\": 71.8, \"x0\": 0, \"y0\": -31, \"z0\": 1046 }, { \"type\": 1, \"dmac\": \"BC572900A04B\", \"time\": \"2023-01-09 15:25:03.996\", \"rssi\": -36, \"ver\": 1, \"vbatt\": 3576, \"temp\": -19.21, \"humidty\": 71.8, \"x0\": 0, \"y0\": -62, \"z0\": 1062 }, { \"type\": 1, \"dmac\": \"BC572900A04B\", \"time\": \"2023-01-09 15:25:03.996\", \"rssi\": -56, \"ver\": 1, \"vbatt\": 3576, \"temp\": -19.21, \"humidty\": 71.8, \"x0\": 31, \"y0\": -31, \"z0\": 1031 }, { \"type\": 1, \"dmac\": \"BC572900A04B\", \"time\": \"2023-01-09 15:25:03.996\", \"rssi\": -37, \"ver\": 1, \"vbatt\": 3576, \"temp\": -19.21, \"humidty\": 71.8, \"x0\": 31, \"y0\": -31, \"z0\": 1031 }, { \"type\": 1, \"dmac\": \"BC572900A04B\", \"time\": \"2023-01-09 15:25:04.301\", \"rssi\": -57, \"ver\": 1, \"vbatt\": 3576, \"temp\": -19.22, \"humidty\": 71.74, \"x0\": 31, \"y0\": -31, \"z0\": 1031 }, { \"type\": 1, \"dmac\": \"BC572900A04B\", \"time\": \"2023-01-09 15:25:04.301\", \"rssi\": -30, \"ver\": 1, \"vbatt\": 3576, \"temp\": -19.22, \"humidty\": 71.74, \"x0\": 0, \"y0\": -31, \"z0\": 1046 }, { \"type\": 1, \"dmac\": \"BC572900A04B\", \"time\": \"2023-01-09 15:25:04.498\", \"rssi\": -30, \"ver\": 1, \"vbatt\": 3576, \"temp\": -19.22, \"humidty\": 71.74, \"x0\": 15, \"y0\": -31, \"z0\": 1046 }, { \"type\": 1, \"dmac\": \"BC572900A04B\", \"time\": \"2023-01-09 15:25:04.498\", \"rssi\": -38, \"ver\": 1, \"vbatt\": 3576, \"temp\": -19.22, \"humidty\": 71.74, \"x0\": 15, \"y0\": -46, \"z0\": 1046 }, { \"type\": 1, \"dmac\": \"BC572900A04B\", \"time\": \"2023-01-09 15:25:04.654\", \"rssi\": -37, \"ver\": 1, \"vbatt\": 3576, \"temp\": -19.22, \"humidty\": 71.74, \"x0\": 31, \"y0\": -46, \"z0\": 1031 }, { \"type\": 1, \"dmac\": \"BC572900A04B\", \"time\": \"2023-01-09 15:25:04.654\", \"rssi\": -58, \"ver\": 1, \"vbatt\": 3576, \"temp\": -19.22, \"humidty\": 71.74, \"x0\": 15, \"y0\": -46, \"z0\": 1046 }, { \"type\": 1, \"dmac\": \"BC5729009F06\", \"time\": \"2023-01-09 15:25:02.648\", \"rssi\": -33, \"ver\": 1, \"vbatt\": 3594, \"temp\": 4.55, \"humidty\": 28.38 }, { \"type\": 1, \"dmac\": \"BC5729009F06\", \"time\": \"2023-01-09 15:25:04.654\", \"rssi\": -33, \"ver\": 1, \"vbatt\": 3594, \"temp\": 4.56, \"humidty\": 28.41 }, { \"type\": 1, \"dmac\": \"BC5729009415\", \"time\": \"2023-01-09 15:25:03.096\", \"rssi\": -86, \"ver\": 1, \"vbatt\": 3617, \"temp\": 27.55, \"humidty\": -1 }] \nreturn msg","outputs":1,"noerr":0,"initialize":"","finalize":"","libs":[],"x":380,"y":100,"wires":[["e32ba1aba39837e2"]]},{"id":"712c998d148d5ebe","type":"inject","z":"cfb92dc5a11cbc66","name":"","props":[{"p":"payload"},{"p":"topic","vt":"str"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"","payload":"","payloadType":"date","x":240,"y":100,"wires":[["047642bda9e2093c"]]},{"id":"e32ba1aba39837e2","type":"function","z":"cfb92dc5a11cbc66","name":"format SQL","func":"let newmsg = {}\nnewmsg.topic = \"INSERT INTO mytable (dmac, temp, humidty) values (?, ?, ?)\"\nfor (let i = 0; i< msg.payload.length; i++) {\n    newmsg.payload = [msg.payload[i].dmac, msg.payload[i].temp, msg.payload[i].humidty]\n    node.send(newmsg)\n}","outputs":1,"noerr":0,"initialize":"","finalize":"","libs":[],"x":530,"y":100,"wires":[["78b427d66162a2ad"]]},{"id":"78b427d66162a2ad","type":"mysql","z":"cfb92dc5a11cbc66","mydb":"2381cb15.b563bc","name":"My Database","x":690,"y":100,"wires":[[]]},{"id":"2381cb15.b563bc","type":"MySQLdatabase","name":"","host":"127.0.0.1","port":"3306","db":"espresso","tz":"","charset":"UTF8"}]

Note that I retained the misspelling of humidity and took no account of the multiple duplicates in your data.

If it turns out that this is not what you want, perhaps you can tell us more about what you are trying to do?

This solution works for me , Now Can we create a queue system so that, max concurrent connection issue can be resolved .

for (let i = 0; i< msg.payload.length; i++) {

newmsg.payload = [{
    device_mac: msg.payload[i].dmac,
    temp: (msg.payload[i].temp),
    humidty: (msg.payload[i].humidty),
    rssi: BigInt(msg.payload[i].rssi),
    ver: msg.payload[i].ver,
    x0:  (msg.payload[i].x0),
    y0:  (msg.payload[i].y0),
    z0:  (msg.payload[i].z0),
    type:  (msg.payload[i].type),

    date: influx_uploadtime_custom,
  
},
{
host: msg.payload[i].dmac,

}];

node.send(newmsg)

}

I am trying to do something like this , inserting into influxdb.
any better approach which can be used please suggest

Sorry, I don't use Influx.

send a mail if a specific device temperature has crossed a specific limit , In the message we can send
few device details and set an interval so that we do not flood the user.

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