"{"values":[{"key": "id", "value": 171},{"key": "counter", "value": 0},{"key": "temperature", "value": 2561},{"key": "x_axis", "value": -223},{"key": "y_axis", "value": -256},{"key": "z_axis", "value": 246},{"key": "battery", "value": 2817}]}"
I have a device (zolertia z1) sending in json data using MQTT and I'm using a function in node-RED to extract values but i keep getting errors my code
return {values: msg.values.temperature};
error :
function : (error)
"TypeError: Cannot read property 'temperature' of undefined"
The output from the MQTT node is a String not a JSON object.
Run the output through a JSON node to convert the string to a JSON object before passing it to your function node.
Also the object will be set as the msg.payload.values
not msg.values