@underpop okay - so it looks like msg.pid and msg.temperature are actually different messages - they are not two properties on the same message object.
The Function node is run each time a message arrives. So it will be run when the msg with pid arrives, and it will be run again when the msg with temperature arrives. But at no time does the Function have both messages.
To make this work you need to store the value of msg.pid and msg.temperature in Flow Context - so their values can be retrieved whenever a message arrives.
For example:
// store pid/temperature in flow context
if (msg.hasOwnProperty("pid")) {
flow.set('pid', msg.pid);
} else if (msg.hasOwnProperty("temperature")) {
flow.set('temperature', msg.temperature);
}
// get the latest values of pid/temperature from context - default to 0 if not yet set
var pid = flow.get('pid') || 0;
var temperature = flow.get('temperature') || 0;
msg.payload = pid+temperature;
return msg