Buffer parser and influxdb with 64bit number

hi all

hope someone could shed some light on this issue.

I am reading 2 x 64 unsighned numbers from an energy meter. and trying to pass it to influx.
in the same flow i am passing 64 bit double floating point numbers to db perfectly. however a standard 64 bit number will not go through. no errors in debug just never shows up in the db. The only thing i see that is strange is that the debug node shows the correct number followed by an "n"

image.

yet in the debug column it is not there.?
image

here is a pic of my buffer parser settings.

it is not my influx node that is the problem , because if i route the flow to the influx node above which is working perfectly. i have the same result. biggest thing i have never seen an n attached to the end of an interger before. Any ideas

Numbers in JavaScript have a max size of (2^53 – 1) Docs

Proof

console.log(Number.MAX_SAFE_INTEGER); // Outputs: 9007199254740991
console.log(Number.MIN_SAFE_INTEGER); // Outputs: -9007199254740991

To avoid precision losses, buffer-parser uses BigInt for 64 bit numbers.

These are displayed with an n at the end to clearly denote they are indeed BigInt values not regular Numbers. That is NOT the buffer parser, that is JS!

Proof (NodeJs Repl)
image


I am afraid it most likely is! The issue is that influx node probably does not know how to deal with BigInt typed numbers. As you can see from your own screenshot, the 64bit BigInt IS present and correct coming out of the buffer parser!

To change the BigInts into regular numbers (and risk loss) you can use the Number function

e.g.

Function Node

msg.payload['TOTAL kWH'] = Number(msg.payload['TOTAL kWH'])
return msg
1 Like

Thanks Steve

It worked perfectly. and with no precision loss although my number is still quite small. i even landed up shaving the last 3 digits to make the number more readable.

working as expected

you are 100 percent correct on the max number size for influx . i found their docs while i was lying in bed after posting the plea for help. When i stated infulx was not the problem it was because i was passing 64bit 754 ieee double precision floating point and that was working fine. lesson learnt i assume it is passed to db as 2 x 32 bit values.

thank you for saving my day
Pat

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