Here is what I use to log values to various DBs. These various DBs store different parameters for different reasons. The Link In brings a formatted message with the data.
[{"id":"cf4a0627.2b0918","type":"link in","z":"215f1be9ab83682d","name":"","links":["57806943.2ec6f8"],"x":75,"y":200,"wires":[["3e7bcafb.7ec11e"]]},{"id":"42a1a605.960d58","type":"function","z":"215f1be9ab83682d","name":"String Object to InfluxDB Single","func":"let str1 = msg.payload.measurement;\ndelete msg.payload.measurement;\nlet str2 = msg.payload.timestamp;\ndelete msg.payload.timestamp;\nstr = msg.payload;\n\nvar str = JSON.stringify(str);\nstr = str.replace(/[\\\"]+/g, '');\nstr = str.replace(/[\\:]+/g, '=');\nstr = str.slice(1,-1);\n\nif ((str1 == \"temperature\") || (str1 == \"humidity\") || (str1 == \"Other\") || (str1 == \"bme680\")) {\n msg.url = \"http://localhost:8086/write?db=logs&precision=s\";\n}\nif (str1 == \"slots\") {\n msg.url = \"http://localhost:8086/write?db=energy&precision=ms\";\n}\nif ((str1 == \"power\")) {\n msg.url = \"http://localhost:8086/write?db=pzem&precision=ms\";\n}\nif ((str1 == \"usageKWH\") || (str1 == \"costs\")) {\n msg.url = \"http://localhost:8086/write?db=consumption&precision=ms\";\n}\nif (str1 == \"epexspot\") {\n msg.url = \"http://localhost:8086/write?db=epexspot&precision=ms\";\n}\nif (str1 == \"meterConsumption\") {\n msg.url = \"http://localhost:8086/write?db=meters&precision=s\";\n}\n\nmsg.payload = str1 + \" \" + str + \" \" + str2;\nmsg.str1 = str1;\n\nreturn {url:msg.url, payload:msg.payload};","outputs":1,"noerr":0,"initialize":"","finalize":"","libs":[],"x":410,"y":200,"wires":[["85962925.6e2ec8"]]},{"id":"85962925.6e2ec8","type":"http request","z":"215f1be9ab83682d","name":"POST logs.","method":"POST","ret":"txt","paytoqs":"ignore","url":"","tls":"","persist":false,"proxy":"","authType":"","x":650,"y":200,"wires":[["06dba7aa85161e05"]]},{"id":"3e7bcafb.7ec11e","type":"delay","z":"215f1be9ab83682d","name":"Rate limit","pauseType":"rate","timeout":"1","timeoutUnits":"seconds","rate":"2","nbRateUnits":"1","rateUnits":"second","randomFirst":"1","randomLast":"5","randomUnits":"seconds","drop":false,"outputs":1,"x":180,"y":200,"wires":[["42a1a605.960d58"]]},{"id":"b52ea062.b6cae","type":"debug","z":"215f1be9ab83682d","name":"OK","active":false,"tosidebar":true,"console":false,"tostatus":false,"complete":"payload","targetType":"msg","statusVal":"","statusType":"auto","x":970,"y":140,"wires":[]},{"id":"1c12dfdf.441648","type":"debug","z":"215f1be9ab83682d","name":"FAIL","active":false,"tosidebar":true,"console":false,"tostatus":false,"complete":"payload","targetType":"msg","statusVal":"","statusType":"auto","x":970,"y":260,"wires":[]},{"id":"ab225df.7ef652","type":"catch","z":"215f1be9ab83682d","name":"","scope":["85962925.6e2ec8"],"uncaught":false,"x":710,"y":240,"wires":[["1c12dfdf.441648","23b7dcf6.bf27f4"]]},{"id":"2977655d.e4260a","type":"complete","z":"215f1be9ab83682d","name":"","scope":["85962925.6e2ec8"],"uncaught":false,"x":730,"y":160,"wires":[["b52ea062.b6cae","694eba36.bb7d54"]]},{"id":"6e0a51de.4c33a","type":"comment","z":"215f1be9ab83682d","name":"Success","info":"","x":1000,"y":180,"wires":[]},{"id":"c3e38c1d.ef6fe8","type":"comment","z":"215f1be9ab83682d","name":"Fail","info":"","x":990,"y":220,"wires":[]},{"id":"06dba7aa85161e05","type":"debug","z":"215f1be9ab83682d","name":"","active":false,"tosidebar":true,"console":false,"tostatus":false,"complete":"false","statusVal":"","statusType":"auto","x":390,"y":140,"wires":[]}]
You could also assemble all of the sensor readings into a single string and pass to a single database.
e.g.
return { payload: { measurement: "usageKWH", usekWh: usekWh, cost: cost, gfCost: gfCost, gfSave: gfSave, saving: saving, avIncPeak: avIncPeak, avExPeak: avExPeak, avPeak: avPeak, timestamp: plotTime } }; }
(I know the labels will not match up with yours.)
You need to show us the format of the messages you are getting, put some debug nodes in a semi working flow and show us some results. Until this is done, we are just guessing at what is going on. With our limited time resources, we can only guess for so long.