2 columns on a table node red - influx db

Hello,
So I have this dashboard

code bellow

[{"id":"c2e8e157.a11cc","type":"tab","label":"Flow 1","disabled":false,"info":""},{"id":"8fd285ae.e97da8","type":"mosca in","z":"c2e8e157.a11cc","mqtt_port":1883,"mqtt_ws_port":8080,"name":"","username":"","password":"","dburl":"","x":310,"y":100,"wires":[[]]},{"id":"af115c63.5b8398","type":"mqtt in","z":"c2e8e157.a11cc","name":"","topic":"esp32/accelerometerX","qos":"2","broker":"30e6b4e8.0662cc","x":320,"y":340,"wires":[["ce9f6912.d54f68","1b4f6c1f.e3000c"]]},{"id":"31811800.54bcc8","type":"mqtt in","z":"c2e8e157.a11cc","name":"","topic":"esp32/speed","qos":"2","broker":"30e6b4e8.0662cc","x":290,"y":140,"wires":[["bc3c5dcb.83c2c8"]]},{"id":"bc3c5dcb.83c2c8","type":"ui_gauge","z":"c2e8e157.a11cc","name":"","group":"9b963a24.e9d3d","order":4,"width":0,"height":0,"gtype":"wave","title":"Speed","label":"km/h","format":"{{value}}","min":0,"max":"250","colors":["#00b500","#e6e600","#ff0209"],"seg1":"","seg2":"","x":510,"y":140,"wires":[]},{"id":"5115a818.8843c8","type":"mqtt in","z":"c2e8e157.a11cc","name":"","topic":"esp32/movement","qos":"2","broker":"30e6b4e8.0662cc","x":300,"y":240,"wires":[["2ef834c6.7827bc","2313fd57.1fec8a","83059ea4.50a0f"]]},{"id":"2ef834c6.7827bc","type":"ui_text","z":"c2e8e157.a11cc","group":"9b963a24.e9d3d","order":3,"width":0,"height":0,"name":"","label":"Movement","format":"{{msg.payload}}","layout":"row-left","x":520,"y":280,"wires":[]},{"id":"ce9f6912.d54f68","type":"ui_text","z":"c2e8e157.a11cc","group":"9b963a24.e9d3d","order":3,"width":0,"height":0,"name":"","label":"X","format":"{{msg.payload}}","layout":"row-spread","x":510,"y":320,"wires":[]},{"id":"e2ec9c80.d45f6","type":"ui_text","z":"c2e8e157.a11cc","group":"9b963a24.e9d3d","order":3,"width":0,"height":0,"name":"","label":"Y","format":"{{msg.payload}}","layout":"row-spread","x":490,"y":440,"wires":[]},{"id":"8bea2566.934838","type":"mqtt in","z":"c2e8e157.a11cc","name":"","topic":"esp32/accelerometerY","qos":"2","broker":"30e6b4e8.0662cc","x":320,"y":400,"wires":[["e2ec9c80.d45f6","c0f7a105.86c038"]]},{"id":"2313fd57.1fec8a","type":"debug","z":"c2e8e157.a11cc","name":"","active":false,"tosidebar":true,"console":false,"tostatus":false,"complete":"payload","x":530,"y":240,"wires":[]},{"id":"83059ea4.50a0f","type":"change","z":"c2e8e157.a11cc","name":"Set Topic","rules":[{"t":"set","p":"topic","pt":"msg","to":"rflink","tot":"str"}],"action":"","property":"","from":"","to":"","reg":false,"x":520,"y":200,"wires":[["63ee3d4f.2206f4","5bc661ec.d1dca8"]]},{"id":"63ee3d4f.2206f4","type":"debug","z":"c2e8e157.a11cc","name":"","active":false,"tosidebar":true,"console":true,"tostatus":false,"complete":"true","x":690,"y":220,"wires":[]},{"id":"5bc661ec.d1dca8","type":"influxdb out","z":"c2e8e157.a11cc","influxdb":"b2337330.1c6a9","name":"movements","measurement":"root","precision":"s","retentionPolicy":"","x":770,"y":160,"wires":[]},{"id":"cf704ba5.beaba8","type":"influxdb out","z":"c2e8e157.a11cc","influxdb":"b2337330.1c6a9","name":"movements","measurement":"accele","precision":"s","retentionPolicy":"","x":970,"y":340,"wires":[]},{"id":"1b4f6c1f.e3000c","type":"change","z":"c2e8e157.a11cc","name":"Topic X","rules":[{"t":"set","p":"topic","pt":"msg","to":"X","tot":"str"}],"action":"","property":"","from":"","to":"","reg":false,"x":500,"y":360,"wires":[["8e881fbd.e3b178"]]},{"id":"c0f7a105.86c038","type":"change","z":"c2e8e157.a11cc","name":"Topic Y","rules":[{"t":"set","p":"topic","pt":"msg","to":"Y","tot":"str"}],"action":"","property":"","from":"","to":"","reg":false,"x":500,"y":400,"wires":[["8e881fbd.e3b178"]]},{"id":"34f8f2c1.f95f1e","type":"function","z":"c2e8e157.a11cc","name":"Formatting","func":"var xval = msg.payload[\"X\"];//h thermokrasia poy erxetai apo to topic ekxwriseth se miametavlith\nvar yval = msg.payload[\"Y\"];\nvar data = {\n    X: xval,\n    Y: yval\n}\nmsg.payload = data\nreturn msg","outputs":1,"noerr":0,"x":770,"y":360,"wires":[["5c463f71.9719c"]]},{"id":"8e881fbd.e3b178","type":"join","z":"c2e8e157.a11cc","name":"","mode":"custom","build":"object","property":"payload","propertyType":"msg","key":"topic","joiner":"\\n","joinerType":"str","accumulate":false,"timeout":"","count":"1","reduceRight":false,"reduceExp":"","reduceInit":"","reduceInitType":"num","reduceFixup":"","x":630,"y":380,"wires":[["34f8f2c1.f95f1e"]]},{"id":"c6e86da0.48c61","type":"debug","z":"c2e8e157.a11cc","name":"","active":false,"tosidebar":true,"console":false,"tostatus":false,"complete":"true","x":710,"y":300,"wires":[]},{"id":"5c463f71.9719c","type":"debug","z":"c2e8e157.a11cc","name":"","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"payload","x":970,"y":440,"wires":[]},{"id":"71972f91.01c318","type":"json","z":"c2e8e157.a11cc","name":"","property":"payload","action":"","pretty":false,"x":970,"y":220,"wires":[[]]},{"id":"30e6b4e8.0662cc","type":"mqtt-broker","z":"","name":"mqtt","broker":"localhost","port":"1883","clientid":"","usetls":false,"compatmode":true,"keepalive":"60","cleansession":true,"birthTopic":"","birthQos":"0","birthPayload":"","closeTopic":"","closeQos":"0","closePayload":"","willTopic":"","willQos":"0","willPayload":""},{"id":"9b963a24.e9d3d","type":"ui_group","z":"","name":"Main","tab":"dec672d9.239ef","disp":true,"width":"6","collapse":false},{"id":"b2337330.1c6a9","type":"influxdb","z":"","hostname":"127.0.0.1","port":"8086","protocol":"http","database":"IoT","name":"","usetls":false,"tls":""},{"id":"dec672d9.239ef","type":"ui_tab","z":"","name":"Dashboard","icon":"dashboard"}]

I send accelerometer values from a esp32 and I want to save them on a table and have this from
TIMESTAMP -- X -- Y
X and Y two different columns

So I receive them, set topics, join them with key/value object (their topics are X and Y).
then I use this function to combine them into one payload.
Screenshot_1

and then try to add them to my table but I get this error
Error: A 400 Bad Request error occurred: {"error":"unable to parse 'accele xval="182",yval=undefined': invalid boolean"}

I have seen previous asked questions but I cannot understand what I'm doing wrong.

Add a debug node showing what is going into the influx node and check it looks right. I suspect that you will see that it is not. To paste a function here it is better to copy/paste the text, use the same method of formatting as with pasting a flow here. I don't see how the funtion you posted relates to the the problem though, as it doesn't seem to be setting up x and y.
The first line could use msg.payload.path, the only time you need to use a string in brackets is if the string has special characters in it (or is a variable). for example you could not use msg.payload.a-b as it would the minus sign was a subtraction rather than part of the attribute name.

sorry my function

var xval = msg.payload["X"];
var yval = msg.payload["Y"];
msg.payload = {
 X: xval,
 Y:yval
}
return msg;

I have added debug message the thing is that it displays it as 2 messages like {X: 181} and then {Y:182} shouldn't it display it only on one ?

You are returning the same as your input

var xval = msg.payload["X"];
var yval = msg.payload["Y];

And this actually has a typo: ["Y] - missing double quote.

In reality you are not changing the payload. You have X and Y as input and you overwrite it with the same key/values ?

I want to combine the outputs
and add the to influx db and have a form like
Screenshot_1

Attach a debug node to the join node, set the output to "complete msg object". what is the output in the debug window ? (copy and paste the text here, screenshots is not useful)

3 May 01:19:09 - [info] [debug:3a4146f7.f4bf12]
{ topic: 'X',
  payload: { X: '182', Y: undefined },
  qos: 1,
  retain: false,
  _topic: 'esp32/accelerometerX',
  _msgid: 'ea2ef86.dbe6708' }
3 May 01:19:09 - [info] [debug:3a4146f7.f4bf12]
{ topic: 'Y',
  payload: { X: undefined, Y: '184' },
  qos: 1,
  retain: false,
  _topic: 'esp32/accelerometerY',
  _msgid: '2b9901e3.9657ee' }

You need to add a batch node in order for the join node to function, example flow

[{"id":"797e64b0.cde3c4","type":"change","z":"ac78339e.50f838","name":"Topic X","rules":[{"t":"set","p":"topic","pt":"msg","to":"X","tot":"str"}],"action":"","property":"","from":"","to":"","reg":false,"x":492,"y":288,"wires":[["2cf22338.172c94"]]},{"id":"87c2c83.abb44b8","type":"change","z":"ac78339e.50f838","name":"Topic Y","rules":[{"t":"set","p":"topic","pt":"msg","to":"Y","tot":"str"}],"action":"","property":"","from":"","to":"","reg":false,"x":492,"y":336,"wires":[["2cf22338.172c94"]]},{"id":"8f7483ed.110458","type":"join","z":"ac78339e.50f838","name":"","mode":"custom","build":"object","property":"payload","propertyType":"msg","key":"topic","joiner":"\\n","joinerType":"str","accumulate":false,"timeout":"","count":"2","reduceRight":false,"reduceExp":"","reduceInit":"","reduceInitType":"num","reduceFixup":"","x":770,"y":312,"wires":[["171b46cb.56d009"]]},{"id":"50f9c758.ef0398","type":"inject","z":"ac78339e.50f838","name":"","topic":"","payload":"23","payloadType":"num","repeat":"","crontab":"","once":false,"onceDelay":0.1,"x":338,"y":288,"wires":[["797e64b0.cde3c4"]]},{"id":"5df3d9d0.40409","type":"inject","z":"ac78339e.50f838","name":"","topic":"","payload":"54","payloadType":"num","repeat":"","crontab":"","once":false,"onceDelay":0.1,"x":338,"y":336,"wires":[["87c2c83.abb44b8"]]},{"id":"2cf22338.172c94","type":"batch","z":"ac78339e.50f838","name":"","mode":"count","count":"2","overlap":0,"interval":10,"allowEmptySequence":false,"topics":[{"topic":"X"},{"topic":"Y"}],"x":650,"y":312,"wires":[["8f7483ed.110458"]]},{"id":"7318486.9718fb8","type":"debug","z":"ac78339e.50f838","name":"","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"true","targetType":"full","x":938,"y":312,"wires":[]},{"id":"171b46cb.56d009","type":"change","z":"ac78339e.50f838","name":"","rules":[{"t":"delete","p":"topic","pt":"msg"}],"action":"","property":"","from":"","to":"","reg":false,"x":855,"y":312,"wires":[["7318486.9718fb8"]],"l":false}]

Output

Screenshot 2020-05-04 at 07.48.46

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