Retrieve a object comming from MQTT

I'm dead sure it's because I'm newbie, I hope someone will help me out here - here is my problem:

I'm trying to calculate where if have power to start other things in the house, this is done by looking at the value: ( - comming on MQTT, this part works.

My problem is in the node: "Calculate power diff" here I keep getting the error: TypeError: Cannot read properties of undefined (reading 'data')

My code is:

var value = msg.payload["power"] 
msg.payload = - 
return msg;

You can see the values from the picture below:

Thank you for your help

There’s a great page in the docs (Working with messages : Node-RED) that will explain how to use the debug panel to find the right path to any data item.

Pay particular attention to the part about the buttons that appear under your mouse pointer when you over hover a debug message property in the sidebar.


in short var value = msg.payload["power"] means value is now pointing to msg.payload.power and is pointing to


But again - use the tools provided to avoid simple mistakes (use the "Copy Path" button)

Thank you, but that is what I have done:/
Hence I need help!!

Clearly you have not (or clicked something else further off screen) - where did msg.payload["power"] come from - its not in that image.

Try again - hover over the item of interest (e.g. PO) and click the "copy path" item. When you paste it in a function you need to suffix it with msg. e.g. msg.payload.x.y.x

Thank you, you are absolutly correct,- I've owe you a beer!


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