Performing calculations in Node-RED

Hello,

I would like to perform the following calculation in Node-RED:

A value should be calculated from two input values ​​(e.g. temperature and relative humidity) using a formula. The result of the formula should then be displayed in the dashboard as a numerical value in a simple field.

Which elements are used in Node-RED?

Thank you!
Michael

are you asking about how retrieve from and push data back to HA or about a node to perform calculations?

Simple calculations can be done in almost any node using jsonata. More complex may be better suited for the function node. Here is an example for air VPD

//get HA values
const temp = global.get('homeassistant.homeAssistant.states["sensor.2b_air_sensor_01_temperature"].state');
const hum = global.get('homeassistant.homeAssistant.states["sensor.2b_air_sensor_01_humidity"].state');
// F to C
const tCelsius = (5/9)*temp -32;
// VPD calc
const saturation = 0.61078 * Math.pow(Math.E, (17.2694 * tCelsius) / (tCelsius + 238.3));
const actual = ((100 - hum) / 100) * saturation;

// empty message
msg = {};
// round to 2
msg.payload = actual.toFixed(2);

return msg;

You would then send that value to a sensor node, which will create an entity in HA you can then display on a dash. You will need the nodered companion app in hacs for this.

If this is for vpd it maybe easier/more straight forward just creating this sensor in HA.