I am extracting data from my smart meter and thought I could make this change node into a one liner. But for the life of me I cannot replace "calc" in the second entry in the node with the reference to the value in the first line. The value is a string containing a hex value. If it's not possible I am also very happy
What does the input payload look like ?
"00000B96" - for example, it's the actual consumption in Watt hours.
Could you please post a debug output including the object ? (meaning the input that goes into this change node)
In jsonata i don't see a quick way as it does not seem to like concatenation and parsing it after that.
In a function node it works;
m = "0x"+msg.payload
return {WattsNow:parseInt(m)};
Oh yes, I have already done it in a function node with:
msg.Wh_now = parseInt(msg.payload.elecMtr["0702"]["04"]["00"], 16);
I was just wondering if it was possible in a change node with a simple JSONata expression.
Fiddling a bit further, this works in jsonata:
$parseInteger($string("0x"&payload),'0')
Nice!, I'll try that later!
Yes that works, but the normal notation for referencing the value doesn't work in JSONata. You need to replace the square brackets with"."
Took me a while, this works fine:
$parseInteger("0x"&payload.elecMtr."0702"."04"."00",'0')
This topic was automatically closed 60 days after the last reply. New replies are no longer allowed.