I just built my first Mysensors sensor (temperature-humidity sensor) and it was successfully integrated in HASS. I extend it further by making a Heat Index sensor using this formula .
Here is the code in configuration.yaml
sensor:
- platform: template
sensors:
heat_index_1:
friendly_name: 'Feels Like'
#formula taken from http://www.srh.noaa.gov/ama/?n=heatindex
value_template: '{{ (((-42.379 + (2.04901523*(((states.sensor.humidity_1_1.state|float)*1.8)+32)) + (10.14333127*(states.sensor.humidity_1_0.state|float)) - (0.22475541*(((states.sensor.humidity_1_1.state|float)*1.8)+32)*(states.sensor.humidity_1_0.state|float)) - (6.83783 * (10**(-3))*((((states.sensor.humidity_1_1.state|float)*1.8)+32)**2)) - (5.481717 * (10**(-2))*((states.sensor.humidity_1_0.state|float)**2)) + (1.22874 * (10**(-3))*((((states.sensor.humidity_1_1.state|float)*1.8)+32)**2*(states.sensor.humidity_1_0.state|float))) + (8.5282 * (10**(-4))*((((states.sensor.humidity_1_1.state|float)*1.8)+32)*(states.sensor.humidity_1_0.state|float)**2)) - (1.99 * (10**(-6))*((((states.sensor.humidity_1_1.state|float)*1.8)+32)**2)*((states.sensor.humidity_1_0.state|float)**2)))-32)/1.8)|round(1) }}'
unit_of_measurement: '°C'
Then you can display it in the group such as this…
6 Likes
Is that accurate? Big difference in Feels Like and temperature there.
mrumble
(mrumble)
January 24, 2018, 6:02pm
4
Resurrecting an old thread but (hopefully) for good reason.
At home right now it’s 18C & 40% inside according to my Nest. That produces a Heat Index of 26 using your formula so I used the simpler Heat Index Formula from http://www.wpc.ncep.noaa.gov/html/heatindex_equation.shtml (last one on the page)
HI = 0.5 * {T + 61.0 + [(T-68.0)*1.2] + (RH*0.094)}
So, pulling the info from my Nest and converting it to Fahrenheit for the equation (but keeping the result in Celsius), my value template looks like this:
value_template: '{{ (((((((states.sensor.upstairs_thermostat_nest_temperature.state|float)*1.8)+32) + 61.0 + (((((states.sensor.upstairs_thermostat_nest_temperature.state|float)*1.8)+32)-68.0)*1.2) + ((states.sensor.upstairs_thermostat_nest_humidity.state|float)*0.094))*0.5)-32)/1.8)|round(1) }}'
The result is 16.9C, which I figure is much more likely given how chilly I feel.
Next step is to write an automation that triggers the AC when the Heat Index rises above the Set Temperature… Helps me feel warm to think about such things in the middle of winter!
4 Likes
ratsputin
(Ratsputin)
January 6, 2019, 4:46pm
5
Re-resurrecting an old thread for reasons I feel are good as well…
I did a bit of research about heat index and it seemed to only apply to the great outdoors. Then I stumbled across the following article: http://www-das.uwyo.edu/~geerts/cwx/notes/chap05/apparentt.html
It was clear to me that heat index and wind chill really don’t apply in the case of indoor temperature. I really wanted to take advantage of the formula provided, but needed Saturation Vapor Pressure and Actual Vapor pressure in order to calculate that value. That’s when I found the following: https://physics.stackexchange.com/questions/4343/how-can-i-calculate-vapor-pressure-deficit-from-temperature-and-relative-humidit which provided the final piece of the puzzle.
Armed with all of the above, I came up with the following value template:
value_template: >
{% set upstairs_temp_c = ((states('sensor.upstairs_temperature') | float) - 32) * 5/9 %}
{% set es = 0.6108 * e ** (17.27 * upstairs_temp_c / (upstairs_temp_c + 237.3)) %} {# Saturation vapor pressure in kPa #}
{% set ea = ((states('sensor.upstairs_humidity') | float) / 100 * es) %} {# Actual vapor pressure in kPa #}
{% set tp = -1.3 + 0.92 * upstairs_temp_c + 2.2 * ea %} {# Apparent temperature in C #}
{% set tpf = (tp * 9/5) + 32 %}
{{ tpf | round(1) }}
6 Likes
thanks for sharing this. but I’m not sure is this the right one. I have compared the apparent temperature given by dark sky vs the result calculated at https://www.calculator.net/heat-index-calculator.html using the temperature and humidity value from dark sky are quite consistent.
Anyway, I have revisited the formula page at https://www.wpc.ncep.noaa.gov/html/heatindex_equation.shtml and updated the template based on my understanding. Here is the latest version…
- platform: template
sensors:
outdoor_heat_index:
friendly_name: 'Outdoor Feels Like'
value_template: >-
{% set T = ((states.sensor.outdoor_temperature.state|float)*1.8)+32 %}
{% set RH = states.sensor.outdoor_humidity.state|float %}
{% set STEADMAN_HI = 0.5 * (T + 61.0 + ((T-68.0)*1.2) + (RH*0.094)) %}
{% if STEADMAN_HI >= 80 %}
{% set ROTHFUSZ_HI = -42.379 + 2.04901523*T + 10.14333127*RH - 0.22475541*T*RH - 0.00683783*T*T - 0.05481717*RH*RH + 0.00122874*T*T*RH + 0.00085282*T*RH*RH - 0.00000199*T*T*RH*RH %}
{% set HI = ROTHFUSZ_HI %}
{% if RH < 13 and 80 < T < 112 %}
{% set ADJUSTMENT = ((13-RH)/4)*((17-(T-95)|abs)/17)**0.5 %}
{% set HI = HI - ADJUSTMENT %}
{% elif RH > 85 and 80 < T < 87 %}
{% set ADJUSTMENT = ((RH-85)/10) * ((87-T)/5) %}
{% set HI = HI + ADJUSTMENT %}
{% endif %}
{% else %}
{% set HI = STEADMAN_HI %}
{% endif %}
{% set HI_C = (HI-32)/1.8 %}
{{- HI_C|round(1) -}}
unit_of_measurement: '°C'
3 Likes
Hi.
Sorry for resurrecting this topic, but I get errors on this config:
- platform: template
sensors:
outdoor_heat_index:
friendly_name: 'Outdoor Feels Like'
value_template: >-
{% set T = ((states.sensor.0x00158d000304031a_temperature.state|float)*1.8)+32 %}
{% set RH = states.sensor.0x00158d000304031a_humidity.state|float %}
{% set STEADMAN_HI = 0.5 * (T + 61.0 + ((T-68.0)*1.2) + (RH*0.094)) %}
{% if STEADMAN_HI >= 80 %}
{% set ROTHFUSZ_HI = -42.379 + 2.04901523*T + 10.14333127*RH - 0.22475541*T*RH - 0.00683783*T*T - 0.05481717*RH*RH + 0.00122874*T*T*RH + 0.00085282*T*RH*RH - 0.00000199*T*T*RH*RH %}
{% set HI = ROTHFUSZ_HI %}
{% if RH < 13 and 80 < T < 112 %}
{% set ADJUSTMENT = ((13-RH)/4)*((17-(T-95)|abs)/17)**0.5 %}
{% set HI = HI - ADJUSTMENT %}
{% elif RH > 85 and 80 < T < 87 %}
{% set ADJUSTMENT = ((RH-85)/10) * ((87-T)/5) %}
{% set HI = HI + ADJUSTMENT %}
{% endif %}
{% else %}
{% set HI = STEADMAN_HI %}
{% endif %}
{% set HI_C = (HI-32)/1.8 %}
{{- HI_C|round(1) -}}
unit_of_measurement: '°C'
Log:
# hassio ha check
Error: Testing configuration at /config
Failed config
sensor.template:
- Invalid config for [sensor.template]: invalid template (TemplateSyntaxError: expected token ')', got 'x00158d000304031a_temperature') for dictionary value @ data['sensors']['outdoor_heat_index']['value_template']. Got '{% set T = ((states.sensor.0x00158d000304031a_temperature.state|float)*1.8)+32 %} {% set RH = states.sensor.0x00158d000304031a_humidity.state|float %} {% set STEADMAN_HI = 0.5 * (T + 61.0 + ((T-68.0)*1.2) + (RH*0.094)) %} {% if STEADMAN_HI >= 80 %}\n {% set ROTHFUSZ_HI = -42.379 + 2.04901523*T + 10.14333127*RH - 0.22475541*T*RH - 0.00683783*T*T - 0.05481717*RH*RH + 0.00122874*T*T*RH + 0.00085282*T*RH*RH - 0.00000199*T*T*RH*RH %}\n {% set HI = ROTHFUSZ_HI %}\n {% if RH < 13 and 80 < T < 11.... (See ?, line ?). Please check the docs at https://home-assistant.io/components/sensor.template/
- platform: template
sensors: [source /config/configuration.yaml:297]
outdoor_heat_index: [source /config/configuration.yaml:298]
friendly_name: Outdoor Feels Like
unit_of_measurement: °C
value_template: {% set T = ((states.sensor.0x00158d000304031a_temperature.state|float)*1.8)+32 %} {% set RH = states.sensor.0x00158d000304031a_humidity.state|float %} {% set STEADMAN_HI = 0.5 * (T + 61.0 + ((T-68.0)*1.2) + (RH*0.094)) %} {% if STEADMAN_HI >= 80 %}
{% set ROTHFUSZ_HI = -42.379 + 2.04901523*T + 10.14333127*RH - 0.22475541*T*RH - 0.00683783*T*T - 0.05481717*RH*RH + 0.00122874*T*T*RH + 0.00085282*T*RH*RH - 0.00000199*T*T*RH*RH %}
{% set HI = ROTHFUSZ_HI %}
{% if RH < 13 and 80 < T < 112 %}
{% set ADJUSTMENT = ((13-RH)/4)*((17-(T-95)|abs)/17)**0.5 %}
{% set HI = HI - ADJUSTMENT %}
{% elif RH > 85 and 80 < T < 87 %}
{% set ADJUSTMENT = ((RH-85)/10) * ((87-T)/5) %}
{% set HI = HI + ADJUSTMENT %}
{% endif %}
{% else %} {% set HI = STEADMAN_HI %} {% endif %} {% set HI_C = (HI-32)/1.8 %} {{- HI_C|round(1) -}}
Successful config (partial)
sensor.template:
Solved:
- platform: template
sensors:
heat_index_suite:
friendly_name: 'Feels Like - Suite'
value_template: >-
{% set T = ((states('sensor.0x00158d000304031a_temperature')|float)*1.8+32) %}
{% set RH = states('sensor.0x00158d000304031a_humidity')|float %}
{% set STEADMAN_HI = 0.5 * (T + 61.0 + ((T-68.0)*1.2) + (RH*0.094)) %}
{% if STEADMAN_HI >= 80 %}
{% set ROTHFUSZ_HI = -42.379 + 2.04901523*T + 10.14333127*RH - 0.22475541*T*RH - 0.00683783*T*T - 0.05481717*RH*RH + 0.00122874*T*T*RH + 0.00085282*T*RH*RH - 0.00000199*T*T*RH*RH %}
{% set HI = ROTHFUSZ_HI %}
{% if RH < 13 and 80 < T < 112 %}
{% set ADJUSTMENT = ((13-RH)/4)*((17-(T-95)|abs)/17)**0.5 %}
{% set HI = HI - ADJUSTMENT %}
{% elif RH > 85 and 80 < T < 87 %}
{% set ADJUSTMENT = ((RH-85)/10) * ((87-T)/5) %}
{% set HI = HI + ADJUSTMENT %}
{% endif %}
{% else %}
{% set HI = STEADMAN_HI %}
{% endif %}
{% set HI_C = (HI-32)/1.8 %}
{{- HI_C|round(1) -}}
unit_of_measurement: '°C'
2 Likes
ratsputin
(Ratsputin)
April 29, 2019, 6:48pm
10
I was just rereading this thread after I came across it again. I just realized we had very different goals in mind.
The heat index calculation you’re using is, in fact, the correct calculation for outdoor “feels like” temperatures. My goal was to calculate a “feels like” temperature for the indoors, which is a very different calculation–note the NOAA formula is only accurate down to 80 degrees F, which would definitely be outside my comfort zone for an indoor temperature.
My usage is primarly for the purpose of tweaking indoor thermostat settings based on a “feels like” temperature rather than an absolute temperature.
Hopefully, that clarifies the use-case and reasoning behind the different formula.
2 Likes
Thanks – this is nearly what I was looking for. I have also realised that even indoor airflow (through fans and ventilators) affect the comfort level.
Is there a method we can first measure indoor air velocity and then use it to tweak the thermostats.
Bartem
September 1, 2019, 1:39pm
12
ratsputin:
Re-resurrecting an old thread for reasons I feel are good as well…
I did a bit of research about heat index and it seemed to only apply to the great outdoors. Then I stumbled across the following article: http://www-das.uwyo.edu/~geerts/cwx/notes/chap05/apparentt.html
It was clear to me that heat index and wind chill really don’t apply in the case of indoor temperature. I really wanted to take advantage of the formula provided, but needed Saturation Vapor Pressure and Actual Vapor pressure in order to calculate that value. That’s when I found the following: https://physics.stackexchange.com/questions/4343/how-can-i-calculate-vapor-pressure-deficit-from-temperature-and-relative-humidit which provided the final piece of the puzzle.
Armed with all of the above, I came up with the following value template:
Copy to clipboard
value_template: >
{% set upstairs_temp_c = ((states('sensor.upstairs_temperature') | float) - 32) * 5/9 %}
{% set es = 0.6108 * e ** (17.27 * upstairs_temp_c / (upstairs_temp_c + 237.3)) %} {# Saturation vapor pressure in kPa #}
{% set ea = ((states('sensor.upstairs_humidity') | float) / 100 * es) %} {# Actual vapor pressure in kPa #}
{% set tp = -1.3 + 0.92 * upstairs_temp_c + 2.2 * ea %} {# Apparent temperature in C #}
{% set tpf = (tp * 9/5) + 32 %}
{{ tpf | round(1) }}
Do you know what I’d have to change to get this to work in Fahrenheit?
I might be missing something, but that template solves for Fahrenheit. It converts to F to C back to F.
t_rage
(Tyler)
October 24, 2019, 8:39am
15
ReDaLeRt:
{{- HI_C|round(1) -}}
Thank you for this template. I needed a template sensor for VPD.
tal
(Tal Atlas)
July 27, 2020, 7:33pm
16
Anyone know if there’s a way to make this calculation reusable?
I’m a bit confused with the above calculations, as the UK Meterology Office describes outdoor ‘Feels Like’ temperature as a measurement of temp/humidity/windspeed at a height of 5ft. Unless I’m missing something I don’t see windspeed integrated in those calcs. If I find the calculation for this missing piece of info, I’ll post it here.
1 Like
ratsputin
(Ratsputin)
August 29, 2020, 12:41am
18
Here in the US, windspeed isn’t considered in the feels-like temperature. Here’s the formula: https://www.weather.gov/media/epz/wxcalc/heatIndex.pdf .
Are you still using this formula for indoor? How has it worked for you?
I’m looking into implementing something like that for my home and I think what you wanted is exactly what I want to do.
Could you tell me if you have noticed a difference by using the feeling temperature compared to the real temp?
ratsputin
(Ratsputin)
October 4, 2020, 12:19pm
20
There’s generally not a vast difference between the measured temperature and the feels-like temperature. For example, right now there’s only a one-degree difference between the feels-like temperature upstairs and the actual temperature (69.8 vs. 68.8) and that’s with 66% humidity.
I was going to try to look at a historical graph and discovered that history doesn’t record derived values, unfortunately. Otherwise, I might have been able to see how much of a delta I saw between the two.
If you’re interested in picking up a 1-2 degree difference, it might be useful; otherwise, it’s more of a novelty, I think. To answer your question more directly, the only place I leveraged the feels-like temperature is in determining whether to switch over between A/C and Heat. Otherwise, my house uses the thermostat temperature as you would normally.
Aaron_P
December 17, 2020, 9:41pm
21
Just popped in to say this is so beautiful I could cry. You should see my brute force attempt to do the same. With zillions of ifs and ().
Sad.
1 Like