I want to add two numeric values and display in a dashboard

This is the Debug Messsage and I would like to add the 2663.03774 and 3205.9554799999996 and show the value in a gauge

3/8/2023, 11:10:04 AMnode: Total DC Watts
sbfspot/2130438358 : msg.payload : Object
sbfspot/2130438237: 2663.03774
sbfspot/2130438358: 3205.9554799999996

This is what I tried but it does not work: Get a NaN message

3/8/2023, 11:45:03 AM[node: Total DC Watts]( : msg.payload : number


This is my edit node

msg.payload = (msg.payload.sbfspot / 2130438237) + (msg.payload.sbfspot / 2130438358);
return msg;

Since the properties have special characters you need to use the square bracket notation to access them, otherwise javascript interprets the / characters and divide symbols.

msg.payload = msg.payload["sbfspot/2130438237"] + msg.payload["sbfspot/2130438358"]

Edit, fixed the code, missing quotes.

Thank you very much @Colin ,

In the end this is what works.

msg.payload = msg.payload["sbfspot/2130438237"] + msg.payload["sbfspot/2130438358"];

Thank you very much for helping me.

1 Like

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