Calculating wind chill using data from Wunderground

We have a wood/oil combo furnace and only light a fire when it’s cold enough. Otherwise we just use the oil. I’ve been relying on data in Home Assistant to help decide if I should light a fire or not. Right now I have a temperature sensor in the furnace room that I combine with “derivative” and “history_stats” sensors to determine how often the oil is cutting on. However, I’d like to consider the outside temperature as well. I have an outdoor temperature sensor already but it’s not a great metric on it’s own. A wind chill estimate would be much more effective. Although to get that I need to know the wind speed.

I looked at buying a weather station that I could read data from using “rtl_433” but they were all sold out at my local hardware store. I briefly considered relying on a weather forecast service but decided I’d prefer real-time data. This led me to look at Wunderground. Turns out a neighbour across the road has a weather station connected to Wunderground already. I just need to get that data into HA. There is a custom component available that will take Wunderground data and pass it to HA but it requires an API key. Wunderground only gives out API keys to users that contribute their own data. No problem, I’ll just provide temperature and humidity data from my outdoor sensor.

Wunderground accepts uploading data through GET requests and my preferred way of sending GET requests is through Node-Red. All I need to do is get my data from HA and pass it to a “http request” node. The “http request” node can append payload data as GET parameters to the URL so that seemed the easiest way to go about it. Using a “HA template node” I can format the data so the “http request” node can use it directly. The only configuration needed for the “http request” node is the Wunderground upload URL. I combined all this with an inject node and now my data gets uploaded every 5 minutes.

My flow looks like this:

node-red flow

After you sign up for a Wunderground account you can create a “personal weather station” device (I chose “other” as the type) and it will give you a “station_id” and “station_key.” I put this into my “HA template node” to simply the whole process like so:

{% set station_id = "XXXXXX" %}
{% set station_key = "XXXXXX" %}

{% set tempf = states('sensor.temperature_outside_garage_back')|float * 9/5 + 32 %}
{% set humidity = states('sensor.humidity_outside_garage_back') %}

{% set data = {
  "ID": station_id,
  "PASSWORD": station_key,
  "dateutc": "now",
  "action": "updateraw",
  "tempf": tempf,
  "humidity": humidity,
} %}

{{ data|to_json }}

Now with Node-Red uploading data I can get an API key. After installing the custom component I can add the following to my sensor config:

  - platform: wundergroundpws
    api_key: XXXXXX
    pws_id: XXXXXX
    numeric_precision: decimal
    monitored_conditions:
      - windSpeed

With the wind speed data now in HA, I just need calculate the wind chill. I use Environment Canada’s formula for this:

  - platform: template
    sensors:
      windchill:
        friendly_name: Wind chill
        value_template: >
          {% set t = states('sensor.temperature_outside_garage_back')|float %}
          {% set v = states('sensor.wupws_windspeed')|float %}
          {% if t>=10 or v<4.8 -%}
          {{ t }}
          {%- else -%}
          {{ (((13.12 + 0.6215*t - 11.37*v**0.16 + 0.3965*t*v**0.16) * 10)|int)|float/10 }}
          {%- endif %}
        unit_of_measurement: "°C"

That’s it! I now have wind chill data in HA!

As a final note, it’s worth mentioning you could skip the last step by just pulling wind chill data from the Wunderground station instead. Although the method I opted for provides two distinct advantages. First, I can change the data sources that the calculation is based on whenever I want. Second, I know how it’s being calculated (and could change that too if I wanted).

3 Likes