How to do mathematic calculations

I want to start a fan when relative humidity is lower outside than in the basement. To make this work I need to calculate the new relative humidity when the air cools down in the basement.
The formula for this is pretty advanced as you can see below. G1 to G3 is sensor values of indoor and outdoor temperatures and outdoor relative humidity.
Is it possible to create a flow for this?
I suppose I need better logic app.

RH=100*(EXP((17,625*(243,04*(ln(G1/100)+((17,625G2)/(243,04+G2)))/(17,625-ln(G1/100)-((17,625G2)/(243,04+G2)))))/(243,04+(243,04*(ln(G1/100)+((17,625G2)/(243,04+G2)))/(17,625-ln(G1/100)-((17,625G2)/(243,04+G2))))))/EXP((17,625*G4)/(243,04+G4)))

Gues you can do this easely in HomeyScript.

Then I need to learn how to do scripts.

https://www.w3schools.com/js/default.asp
you’r never to old to learn, just start, search this forum for HomeyScript and if you get stuck, you always can ask here for help/support. It’s FUN :smiley:

Install the app betterlogic
It supports math.js functions

What I would do is split it up in several flows and use multiple variables…

Something like:
When Temp changes THEN calculate the part with the temp in it and assign tthe outcome to a variable1

When humidity changes THEN calculate the part with the humidity in it and assign tthe outcome to a variable2

When variable1 changes THEN calculate the next part and assign tthe outcome to a variable
Etc

Hi

You can easily do this with better-logic app. I have made similar calculation to calculate the absolute humidity of outside and inside temperature, which can be compared.

https://homey.app/f/8jiC0c

sisäkosteus=indoor humidity
AH=absolute humidity

1 Like