Feels Like (Heat Index) temperature from real temp and humidity in Fahrenheit

After much to-do, I have been able to calculate the Heat Index or Feels Like temperature. Using this post as a guide:

and help from @mostlychris with the MQTT portion.

Here is the code with a MQTT provided temp reference from an Ambient Weather 2902.

#Local Weather
- platform: mqtt
  state_topic: "rtl_433/Fineoffset-WH65B/105"
  name: "WH65B Temp F"
  unit_of_measurement: "°F"
  force_update: true
  value_template: "{{ value_json.temperature_F }}"

- platform: mqtt
  state_topic: 'rtl_433/Fineoffset-WH65B/105'
  name: 'WH65B Humidity'
  unit_of_measurement: "%"
  force_update: true
  value_template: "{{ value_json.humidity }}"



- 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.wh65b_temp_f.state|float)) + (10.14333127*(states.sensor.wh65b_humidity.state|float)) - (0.22475541*(states.sensor.wh65b_temp_f.state|float)*(states.sensor.wh65b_humidity.state|float)) - (0.00683783*(states.sensor.wh65b_temp_f.state|float)*(states.sensor.wh65b_temp_f.state|float)) - (0.05481717*(states.sensor.wh65b_humidity.state|float)*(states.sensor.wh65b_humidity.state|float)) + (0.00122874*(states.sensor.wh65b_temp_f.state|float)*(states.sensor.wh65b_temp_f.state|float)*(states.sensor.wh65b_humidity.state|float)) + (0.00085282*(states.sensor.wh65b_temp_f.state|float)*(states.sensor.wh65b_humidity.state|float)*(states.sensor.wh65b_humidity.state|float)) - (0.00000199*(states.sensor.wh65b_temp_f.state|float)*(states.sensor.wh65b_temp_f.state|float)*(states.sensor.wh65b_humidity.state|float)*(states.sensor.wh65b_humidity.state|float)))| round(3)) }}'
      unit_of_measurement: '°F'
1 Like

The original post does not take into account the full temperature and humidity adjustments. There are actually 4 different formulas to get the Heat Index. I have finally succeeded on building a usable conditional statement for each of the formula differences. Here is the new value template for heat index. Simply put your sensors for temperature and humidity into the equations and it should work for you.

The source for these formulas is https://www.wpc.ncep.noaa.gov/html/heatindex_equation.shtml

#Heat index
- platform: template
  sensors:
    heat_index:
      friendly_name: 'Feels Like'
      #formula taken from http://www.srh.noaa.gov/ama/?n=heatindex
      value_template: >-
        {% if 112 > states('sensor.wh65b_temp_f') | float > 80 and states('sensor.wh65b_humidity') | float < 13 %}
          {{ (((-42.379 + (2.04901523*(states.sensor.wh65b_temp_f.state|float)) + (10.14333127*(states.sensor.wh65b_humidity.state|float)) - (0.22475541*(states.sensor.wh65b_temp_f.state|float)*(states.sensor.wh65b_humidity.state|float)) - (0.00683783*(states.sensor.wh65b_temp_f.state|float)*(states.sensor.wh65b_temp_f.state|float)) - (0.05481717*(states.sensor.wh65b_humidity.state|float)*(states.sensor.wh65b_humidity.state|float)) + (0.00122874*(states.sensor.wh65b_temp_f.state|float)*(states.sensor.wh65b_temp_f.state|float)*(states.sensor.wh65b_humidity.state|float)) + (0.00085282*(states.sensor.wh65b_temp_f.state|float)*(states.sensor.wh65b_humidity.state|float)*(states.sensor.wh65b_humidity.state|float)) - (0.00000199*(states.sensor.wh65b_temp_f.state|float)*(states.sensor.wh65b_temp_f.state|float)*(states.sensor.wh65b_humidity.state|float)*(states.sensor.wh65b_humidity.state|float)))-(((13-(states.sensor.wh65b_humidity.state|float))/4)*sqrt((17-(((states.sensor.wh65b_temp_f.state|float)-95)|abs))/17))) | round(3)) }}
        {% elif 87 > states('sensor.wh65b_temp_f') | float > 80 and states('sensor.wh65b_humidity') | float > 85 %} 
          {{ (((-42.379 + (2.04901523*(states.sensor.wh65b_temp_f.state|float)) + (10.14333127*(states.sensor.wh65b_humidity.state|float)) - (0.22475541*(states.sensor.wh65b_temp_f.state|float)*(states.sensor.wh65b_humidity.state|float)) - (0.00683783*(states.sensor.wh65b_temp_f.state|float)*(states.sensor.wh65b_temp_f.state|float)) - (0.05481717*(states.sensor.wh65b_humidity.state|float)*(states.sensor.wh65b_humidity.state|float)) + (0.00122874*(states.sensor.wh65b_temp_f.state|float)*(states.sensor.wh65b_temp_f.state|float)*(states.sensor.wh65b_humidity.state|float)) + (0.00085282*(states.sensor.wh65b_temp_f.state|float)*(states.sensor.wh65b_humidity.state|float)*(states.sensor.wh65b_humidity.state|float)) - (0.00000199*(states.sensor.wh65b_temp_f.state|float)*(states.sensor.wh65b_temp_f.state|float)*(states.sensor.wh65b_humidity.state|float)*(states.sensor.wh65b_humidity.state|float)))-(((states.sensor.wh65b_humidity.state|float)-85)/10)*((87-(states.sensor.wh65b_temp_f.state|float))/5)) | round(3)) }}
        {% elif states('sensor.wh65b_temp_f') | float < 80 %}
          {{ ((0.5*((states.sensor.wh65b_temp_f.state|float) + 61.0 + (((states.sensor.wh65b_temp_f.state|float)-68)*1.2) + ((states.sensor.wh65b_humidity.state|float)*0.094))) | round(3)) }}
        {% else %}
          {{ ((-42.379 + (2.04901523*(states.sensor.wh65b_temp_f.state|float)) + (10.14333127*(states.sensor.wh65b_humidity.state|float)) - (0.22475541*(states.sensor.wh65b_temp_f.state|float)*(states.sensor.wh65b_humidity.state|float)) - (0.00683783*(states.sensor.wh65b_temp_f.state|float)*(states.sensor.wh65b_temp_f.state|float)) - (0.05481717*(states.sensor.wh65b_humidity.state|float)*(states.sensor.wh65b_humidity.state|float)) + (0.00122874*(states.sensor.wh65b_temp_f.state|float)*(states.sensor.wh65b_temp_f.state|float)*(states.sensor.wh65b_humidity.state|float)) + (0.00085282*(states.sensor.wh65b_temp_f.state|float)*(states.sensor.wh65b_humidity.state|float)*(states.sensor.wh65b_humidity.state|float)) - (0.00000199*(states.sensor.wh65b_temp_f.state|float)*(states.sensor.wh65b_temp_f.state|float)*(states.sensor.wh65b_humidity.state|float)*(states.sensor.wh65b_humidity.state|float)))| round(3)) }}
        {% endif %}
      unit_of_measurement: '°F'

1 Like

If anyone ever wants this in celsius, I updated the above like this:

sensor:
  #Heat index
  - platform: template
    sensors:
      heat_index:
        friendly_name: 'Feels Like'
        #formula taken from http://www.srh.noaa.gov/ama/?n=heatindex
        value_template: >-
          {%- set outside_f = ((states('sensor.outside_temperature')|float * 1.8000)+32.00) -%}
          {% if 112 > outside_f | float > 80 and states('sensor.outside_humidity') | float < 13 %}
            {% set value = (((-42.379 + (2.04901523*(outside_f|float)) + (10.14333127*(states.sensor.outside_humidity.state|float)) - (0.22475541*(outside_f|float)*(states.sensor.outside_humidity.state|float)) - (0.00683783*(outside_f|float)*(outside_f|float)) - (0.05481717*(states.sensor.outside_humidity.state|float)*(states.sensor.outside_humidity.state|float)) + (0.00122874*(outside_f|float)*(outside_f|float)*(states.sensor.outside_humidity.state|float)) + (0.00085282*(outside_f|float)*(states.sensor.outside_humidity.state|float)*(states.sensor.outside_humidity.state|float)) - (0.00000199*(outside_f|float)*(outside_f|float)*(states.sensor.outside_humidity.state|float)*(states.sensor.outside_humidity.state|float)))-(((13-(states.sensor.outside_humidity.state|float))/4)*sqrt((17-(((outside_f|float)-95)|abs))/17))) | round(3)) %}
          {% elif 87 > outside_f | float > 80 and states('sensor.outside_humidity') | float > 85 %} 
            {% set value = (((-42.379 + (2.04901523*(outside_f|float)) + (10.14333127*(states.sensor.outside_humidity.state|float)) - (0.22475541*(outside_f|float)*(states.sensor.outside_humidity.state|float)) - (0.00683783*(outside_f|float)*(outside_f|float)) - (0.05481717*(states.sensor.outside_humidity.state|float)*(states.sensor.outside_humidity.state|float)) + (0.00122874*(outside_f|float)*(outside_f|float)*(states.sensor.outside_humidity.state|float)) + (0.00085282*(outside_f|float)*(states.sensor.outside_humidity.state|float)*(states.sensor.outside_humidity.state|float)) - (0.00000199*(outside_f|float)*(outside_f|float)*(states.sensor.outside_humidity.state|float)*(states.sensor.outside_humidity.state|float)))-(((states.sensor.outside_humidity.state|float)-85)/10)*((87-(outside_f|float))/5)) | round(3)) %}
          {% elif outside_f | float < 80 %}
            {% set value = ((0.5*((outside_f|float) + 61.0 + (((outside_f|float)-68)*1.2) + ((states.sensor.outside_humidity.state|float)*0.094))) | round(3)) %}
          {% else %}
            {% set value = ((-42.379 + (2.04901523*(outside_f|float)) + (10.14333127*(states.sensor.outside_humidity.state|float)) - (0.22475541*(outside_f|float)*(states.sensor.outside_humidity.state|float)) - (0.00683783*(outside_f|float)*(outside_f|float)) - (0.05481717*(states.sensor.outside_humidity.state|float)*(states.sensor.outside_humidity.state|float)) + (0.00122874*(outside_f|float)*(outside_f|float)*(states.sensor.outside_humidity.state|float)) + (0.00085282*(outside_f|float)*(states.sensor.outside_humidity.state|float)*(states.sensor.outside_humidity.state|float)) - (0.00000199*(outside_f|float)*(outside_f|float)*(states.sensor.outside_humidity.state|float)*(states.sensor.outside_humidity.state|float)))| round(3)) %}
          {% endif %}
          {{ ((value - 32)/1.8000|float) | round(3) }}
        unit_of_measurement: '°C'

Formulas for converting based on:
https://www.metric-conversions.org/temperature/fahrenheit-to-celsius.htm and https://www.metric-conversions.org/temperature/celsius-to-fahrenheit.htm

6 Likes

Published beta-version of Feels Like Temperature Sensor:

How would you go about updating that so that will work with the new way they use in the config files now?
Because evertime I try to put it in sure the template part likes it when I put my sensor info in the right place but every time I try adding it to my config file I get this.

Logger: homeassistant.config
Source: config.py:982
First occurred: 12:29:09 PM (1 occurrences)
Last logged: 12:29:09 PM

Invalid config for [template]: required key not provided @ data['sensor'][0]['state']. Got None. (See /config/configuration.yaml, line 95).

Now I do have a weater Under ground addon that is in place before this one.
Here is my fill config file maybe someone could help me figure this out as to why it’s not working like it should?

# Loads default set of integrations. Do not remove.
default_config:

# Load frontend themes from the themes folder
frontend:
  themes: !include_dir_merge_named themes

# Text to speech
tts:
  - platform: google_translate

#http proxies
http:
  use_x_forwarded_for: true
  trusted_proxies:
    - 172.17.0.0/24
    - 192.168.1.0/24


automation: !include automations.yaml
script: !include scripts.yaml
scene: !include scenes.yaml

#WeaterUnderGround
wundergroundpws:
  api_key: 3b7a03cf1e7940d9ba03cf1e7970d938
  pws_id: KTXALVOR24

weather:
  - platform: wundergroundpws
sensor:
  - platform: wundergroundpws
    monitored_conditions:
      - dewpt
      - elev
      - heatIndex
      - humidity
      - neighborhood
      - obsTimeLocal
      - precip_1d
      - precip_2d
      - precip_3d
      - precip_4d
      - precip_5d
      - precip_chance_1d
      - precip_chance_1n
      - precip_chance_2d
      - precip_chance_2n
      - precip_chance_3d
      - precip_chance_3n
      - precip_chance_4d
      - precip_chance_4n
      - precip_chance_5d
      - precip_chance_5n
      - precipRate
      - precipTotal
      - pressure
      - solarRadiation
      - stationID
      - temp
      - temp_high_1d
      - temp_high_2d
      - temp_high_3d
      - temp_high_4d
      - temp_high_5d
      - temp_low_1d
      - temp_low_2d
      - temp_low_3d
      - temp_low_4d
      - temp_low_5d
      - today_summary
      - uv
      - weather_1d
      - weather_1n
      - weather_2d
      - weather_2n
      - weather_3d
      - weather_3n
      - weather_4d
      - weather_4n
      - weather_5d
      - weather_5n
      - wind_1d
      - wind_2d
      - wind_3d
      - wind_4d
      - wind_5d
      - windChill
      - winddir
      - windDirectionName
      - windGust
      - windSpeed    
      
#Heat index
template:
  - sensor:
    - name: Feels Like Back Room
      unique_id: 'feellike1'
    - value_template: >-
        {% if 112 > states('sensor.temperature_and_humidity_sensor_temperature') | float > 80 and states('sensor.temperature_and_humidity_sensor_humidity') | float < 13 %}
          {{ (((-42.379 + (2.04901523*(states.sensor.temperature_and_humidity_sensor_temperature.state|float)) + (10.14333127*(states.sensor.temperature_and_humidity_sensor_humidity.state|float)) - (0.22475541*(states.sensor.temperature_and_humidity_sensor_temperature.state|float)*(states.sensor.temperature_and_humidity_sensor_humidity.state|float)) - (0.00683783*(states.sensor.temperature_and_humidity_sensor_temperature.state|float)*(states.sensor.temperature_and_humidity_sensor_temperature.state|float)) - (0.05481717*(states.sensor.temperature_and_humidity_sensor_humidity.state|float)*(states.sensor.temperature_and_humidity_sensor_humidity.state|float)) + (0.00122874*(states.sensor.temperature_and_humidity_sensor_temperature.state|float)*(states.sensor.temperature_and_humidity_sensor_temperature.state|float)*(states.sensor.temperature_and_humidity_sensor_humidity.state|float)) + (0.00085282*(states.sensor.temperature_and_humidity_sensor_temperature.state|float)*(states.sensor.temperature_and_humidity_sensor_humidity.state|float)*(states.sensor.temperature_and_humidity_sensor_humidity.state|float)) - (0.00000199*(states.sensor.temperature_and_humidity_sensor_temperature.state|float)*(states.sensor.temperature_and_humidity_sensor_temperature.state|float)*(states.sensor.temperature_and_humidity_sensor_humidity.state|float)*(states.sensor.temperature_and_humidity_sensor_humidity.state|float)))-(((13-(states.sensor.temperature_and_humidity_sensor_humidity.state|float))/4)*sqrt((17-(((states.sensor.temperature_and_humidity_sensor_temperature.state|float)-95)|abs))/17))) | round(3)) }}
        {% elif 87 > states('sensor.temperature_and_humidity_sensor_temperature') | float > 80 and states('sensor.temperature_and_humidity_sensor_humidity') | float > 85 %} 
          {{ (((-42.379 + (2.04901523*(states.sensor.temperature_and_humidity_sensor_temperature.state|float)) + (10.14333127*(states.sensor.temperature_and_humidity_sensor_humidity.state|float)) - (0.22475541*(states.sensor.temperature_and_humidity_sensor_temperature.state|float)*(states.sensor.temperature_and_humidity_sensor_humidity.state|float)) - (0.00683783*(states.sensor.temperature_and_humidity_sensor_temperature.state|float)*(states.sensor.temperature_and_humidity_sensor_temperature.state|float)) - (0.05481717*(states.sensor.temperature_and_humidity_sensor_humidity.state|float)*(states.sensor.temperature_and_humidity_sensor_humidity.state|float)) + (0.00122874*(states.sensor.temperature_and_humidity_sensor_temperature.state|float)*(states.sensor.temperature_and_humidity_sensor_temperature.state|float)*(states.sensor.temperature_and_humidity_sensor_humidity.state|float)) + (0.00085282*(states.sensor.temperature_and_humidity_sensor_temperature.state|float)*(states.sensor.temperature_and_humidity_sensor_humidity.state|float)*(states.sensor.temperature_and_humidity_sensor_humidity.state|float)) - (0.00000199*(states.sensor.temperature_and_humidity_sensor_temperature.state|float)*(states.sensor.temperature_and_humidity_sensor_temperature.state|float)*(states.sensor.temperature_and_humidity_sensor_humidity.state|float)*(states.sensor.temperature_and_humidity_sensor_humidity.state|float)))-(((states.sensor.temperature_and_humidity_sensor_humidity.state|float)-85)/10)*((87-(states.sensor.temperature_and_humidity_sensor_temperature.state|float))/5)) | round(3)) }}
        {% elif states('sensor.temperature_and_humidity_sensor_temperature') | float < 80 %}
          {{ ((0.5*((states.sensor.temperature_and_humidity_sensor_temperature.state|float) + 61.0 + (((states.sensor.temperature_and_humidity_sensor_temperature.state|float)-68)*1.2) + ((states.sensor.temperature_and_humidity_sensor_humidity.state|float)*0.094))) | round(3)) }}
        {% else %}
          {{ ((-42.379 + (2.04901523*(states.sensor.temperature_and_humidity_sensor_temperature.state|float)) + (10.14333127*(states.sensor.temperature_and_humidity_sensor_humidity.state|float)) - (0.22475541*(states.sensor.temperature_and_humidity_sensor_temperature.state|float)*(states.sensor.temperature_and_humidity_sensor_humidity.state|float)) - (0.00683783*(states.sensor.temperature_and_humidity_sensor_temperature.state|float)*(states.sensor.temperature_and_humidity_sensor_temperature.state|float)) - (0.05481717*(states.sensor.temperature_and_humidity_sensor_humidity.state|float)*(states.sensor.temperature_and_humidity_sensor_humidity.state|float)) + (0.00122874*(states.sensor.temperature_and_humidity_sensor_temperature.state|float)*(states.sensor.temperature_and_humidity_sensor_temperature.state|float)*(states.sensor.temperature_and_humidity_sensor_humidity.state|float)) + (0.00085282*(states.sensor.temperature_and_humidity_sensor_temperature.state|float)*(states.sensor.temperature_and_humidity_sensor_humidity.state|float)*(states.sensor.temperature_and_humidity_sensor_humidity.state|float)) - (0.00000199*(states.sensor.temperature_and_humidity_sensor_temperature.state|float)*(states.sensor.temperature_and_humidity_sensor_temperature.state|float)*(states.sensor.temperature_and_humidity_sensor_humidity.state|float)*(states.sensor.temperature_and_humidity_sensor_humidity.state|float)))| round(3)) }}
        {% endif %}
    - unit_of_measurement: '°F'

Any help would be great as I am needing to get this one working so that I can add 2 more after that to help try to keep my hose cooler.

You are mixing formats again… the current format does not use value_template it uses state.
And you are adding hyphens where they do not belong.

I gave you the correct way to do it your other post

FWIW, using variable will make your templates easier to understand and more efficient.

To add more sensors, you just start the next sensor with a new name: key…

template:
  - sensor:
      - name: Feels Like Back Room
        unique_id: 'feellike1'
        unit_of_measurement: '°F'
        state: |-
          {% set temperature = states('sensor.temperature_and_humidity_sensor_temperature') | float%}
          {% set humidity = states('sensor.temperature_and_humidity_sensor_humidity') | float %}
          {% if 112 > temperature > 80 and humidity < 13 %}
            {{ (((-42.379 + (2.04901523*temperature) + (10.14333127*humidity) - (0.22475541*temperature*humidity) - 
            (0.00683783*temperature**2) - (0.05481717*humidity**2) + (0.00122874*temperature**2*humidity) + (0.00085282*temperature*humidity**2) - 
            (0.00000199*temperature**2*humidity**2))-(((13-humidity)/4)*sqrt((17-((temperature-95)|abs))/17))) | round(3)) }}
          {% elif 87 > temperature > 80 and humidity > 85 %} 
            {{ (((-42.379 + (2.04901523*temperature) + (10.14333127*humidity) - (0.22475541*temperature*humidity) - (0.00683783*temperature**2) - (0.05481717*humidity**2) + (0.00122874*temperature**2*humidity) + (0.00085282*temperature*humidity**2) - (0.00000199*temperature**2*humidity**2))-((humidity-85)/10)*((87-temperature)/5)) | round(3)) }}
          {% elif temperature < 80 %}
            {{ ((0.5*(temperature + 61.0 + ((temperature-68)*1.2) + (humidity*0.094))) | round(3)) }}
          {% else %}
            {{ ((-42.379 + (2.04901523*temperature) + (10.14333127*humidity) - (0.22475541*temperature*humidity) - (0.00683783*temperature**2) - (0.05481717*humidity**2) + (0.00122874*temperature**2*humidity) + (0.00085282*temperature*humidity**2) - (0.00000199*temperature**2*humidity**2))| round(3)) }}
          {% endif %}

      - name: Example Sensor #2
        unique_id: sensor_2_0000001
        state: 

      - name: Example Sensor #3
        unique_id: sensor_3_0000001
        state: 

Okay sorry been slowly trying to work through what is here. I read what you have to say and yes your right… But at the same time everyone keeps pointing me back to the template doc of HA and it shows that other way. It’s really more of a nightmare for me and I thought understanding C++ code was hard. Thanks again and sorry if I got under your skin.