I know this post has been “solved” but since it is so different to the solution that i came across, I thought I would share.
Using calculations found on this page {dehumidification - What is a formula to approximate the change in relative humidity cause by a change in temp? - Engineering Stack Exchange } I created the following code.
My test seem to match online calculators that i have seen
One matches exactly (Calculate humidity after changing air temperature | Markus Weimar )
another is always 1% different (Relative humidity calculator) but a 1% error is fine for my usages.
Hope this is of use to others.
{# some notes
Known values:
T1 = outdoor Temperature sensor
RH1= outdoor Relative Humidity sensor
T2 = indoor Temperature sensor
Assumptions:
pressure between 2 temperatures is the same
Measurement units:
Temperature = Celsius/Centigrade
Moisture Content = g/m^3:
Relative Humidity = %
To calculate
RH2 = indoor Relative Humidity
via
M1 = outdoor Moisture Content
M2 = outdoor Moisture Content
#}
{% set T1 = states('sensor.outdoor_temperature') | float %}
{% set RH1= states('sensor.outdoor_humidity') | float %}
{% set T2 = states('sensor.indoor_temperature') | float %}
{# test set to check against online calculators
{% set T1 = 30 | float %}
{% set RH1= 20 | float %}
{% set T2 = 20 | float %} #}
{% set M1 = 6.112 * e**( ( 17.67 * T1 ) / ( T1 + 243.5 ) ) * RH1 * 18.02 / ( ( 273.15 + T1 ) * 100 * 0.08314) %}
{% set M2 = M1 / ( ( T2 + 273.15 ) / (T1 + 273.15 ) ) %}
{% set RH2 = (M2 * e** ( - ( 17.67 *T2 ) / ( T2 + 243.5 ) ) * ( 0.075487 * T2 + 20.6193)) | round(1) %}
Estimated Relative Humidity = {{RH2}}