Hello everybody,
Is there a way to make calculations witch sensors-data in HA?

I have temperature sensors and humidity sensors outdoor and indoor.
Now I would like to calculate from these values the dew point and then turn on a fan in the basement.

But I have to perform calculations to calculate the dew point. Similar to this Arduino script:

//int runtime;
float tautemp;
float tau, maxtau, mintau;
//Temp & Humid
float a = 17.271; // für Taupunkt Formel
float b = 237.7; // für Taupunkt Formel
float temperature;
float temp, maxtemp, mintemp;
float h,h1, maxh, minh;
float t,t1;
void taupunkt()
{
tautemp = (a * t1) / (b + temp) + log(h1 / 100);
tau = (b * tautemp) / (a - tautemp);
}
oid minmax()
{
if (temp > maxtemp) maxtemp = temp;
if (temp < mintemp) mintemp = temp;
if (h > maxh) maxh = h;
if (h < minh) minh = h;
if (tau > maxtau) maxtau = tau;
if (tau < mintau) mintau = tau; */
}

Is it possible to calculate this for two sensors without duplicating the code?
With AppDaemon you can. I don’t think you can with regular Home Assistant sensors.

I added this to my configuration.yaml:
sensor:
platform: template
sensors:
taupunkt_keller:
value_template: "{{ ((sensor.hmwds40thi2_meq1651011_temperature | float - ((100 - sensor.hmwds40thi2_meq1651011_humidity | float) /5)))}}"

But I get this error message:

rror loading /home/homeassistent/.homeassistant/configuration.yaml: mapping values are not allowed here
in "/home/homeassistent/.homeassistant/configuration.yaml", line 76, column 12

But actually I am confused how it calculates --> heavily wrong!

With the given values of the sensors it calculates dew point = -20 !
The formula seems right for me. I calculated “by hand” and got another value: 7,6 WTF!

It gets even more strange, when I replace the sensor Id with the actual values of the sensors, it gets another value:

I realize the thread is older, but it really helped me! Here are some sensors with a fancier dew point calculation, in case it’s of use to someone else.

Sorry, I should have included a reference to source documentation. I borrowed the first relationship listed on the Wikipedia page for calculating dew point, here: https://en.m.wikipedia.org/wiki/Dew_point.

The ‘gamma’ sensor is just a intermediate step that isn’t very meaningful. Its used twice in the actual dewpoint calculation (the ‘lr_dewpt’ sensor), it just saves me from writing the math out twice. I hide the gamma portion in my setup. You could also copy the math into the final sensor and only have one sensor (that’s very long) since no one will see the math…

I’m pretty sure the whole thing is just an empirical data fit of the steam tables anyways.