Wind chill

I want to show wind chill temperature and have used a value-template for that. This is working fine.

      windchill:
        value_template: '{{(13.12 +0.6215*float(states.sensor.out_temp.state) -11.37*(float(states.sensor.yr_wind_speed.state)*3.6)**0.16 +0.3965*float(states.sensor.out_temp.state)*(float(states.sensor.yr_wind_speed.state)*3.6)**0.16) | round(1) }}'
        unit_of_measurement: '°C'
        friendly_name: Wind chill

However the wind chill temperature is defined only for temperatures at or below 10 °C and wind speeds above 1.34 m/s.
Is it somehow possible to integrate this into the template, so when these conditions are not fulfilled the wind chill temperature shows “NA”?

Assuming your temp & wind speed sensors are in the correct units:

windchill:
  value_template: >
    {% if states('sensor.out_temp') | float < 10 and states('sensor.yr_wind_speed') | float > 1.34 %}
      {{(13.12 +0.6215*float(states.sensor.out_temp.state) -11.37*(float(states.sensor.yr_wind_speed.state)*3.6)**0.16 +0.3965*float(states.sensor.out_temp.state)*(float(states.sensor.yr_wind_speed.state)*3.6)**0.16) | round(1) }}
    {% else %}
      NA
    {% endif %}
  unit_of_measurement: '°C'
  friendly_name: Wind chill
3 Likes

Works like a charm :+1::slight_smile: Thanks for helping

1 Like

must be:

No?

oops. yeah I read what you wrote backwards.

so…yes! :slightly_smiling_face:

I actually did correct this minor typo when I used the template but forgot to mention it here :open_mouth::slight_smile:

I feel a correction to the posted code comming on :smiley:

OK, OK! Stop nagging me already! :laughing:

Done…

1 Like

I sometimes get this error regarding the wind chill template:

ERROR (MainThread) [homeassistant.helpers.entity] Update for sensor.windchill fails
TypeError: can’t multiply sequence by non-int of type ‘float’

What does it mean?

When I try this out within the template tool I get a wind chill value that is higher than the current temp. At the time of testing this my ‘Sensor.dark_sky_temperature’ was 49.4 and the sensor.dark_sky_wind_speed was 11.25. The Wind chill value provided from this template gave me 59.3 (these are all Fahrenheit). I wasn’t expecting a higher value than the current temp. Something I am doing wrong or does the calculation change for Fahrenheit?

    {% if states('sensor.dark_sky_temperature') | float < 50 and states('sensor.dark_sky_wind_speed') | float > 1.34 %}
      {{(13.12 +0.6215*float(states.sensor.dark_sky_temperature.state) -11.37*(float(states.sensor.dark_sky_wind_speed.state)*3.6)**0.16 +0.3965*float(states.sensor.dark_sky_temperature.state)*(float(states.sensor.dark_sky_wind_speed.state)*3.6)**0.16) | round(1) }}
    {% else %}
      NA
    {% endif %}

**Edit - the formula does need to change for Fahrenheit. Everything in bold & italic I updated in the formula but what I am not sure about is the (states.sensor.dark_sky_wind_speed.state) *3.6)*0.16
Does this value need to change?

    {% if states('sensor.dark_sky_temperature') | float < 50 and states('sensor.dark_sky_wind_speed') | float > 1.34 %}
      {{(***35.74* +0.*6215****float(states.sensor.dark_sky_temperature.state) **-35.74** (float**(states.sensor.dark_sky_wind_speed.state) 3.6) **0.16 +0.*4275**float(states.sensor.dark_sky_temperature.state)*(float(states.sensor.dark_sky_wind_speed.state)*3.6)**0.16) | round(1) }}
    {% else %}
      NA
    {% endif %}

Please read tinkerer’s sticky at the top of the forum and post code in the proper format (use the </> button)
Looking at your profile I’m willing to bet that this was just a mistake though :smiley:

That is just the code entered into the dev template tool

I rarely have access to the entities to be used in other people’s instances.
So I use the template editor where I can.
I still post the code so that others can read it.
(eg where are the line breaks, spacing (mono space font used), quotation usage etc. - but… whatever you are happy with)
Good luck.

Here is the windchill calculation for degrees measured in F and wind speed measured in M/h.

It only applies if the T < 50F and Wind > 3mph

{{35.74 + (0.6215 * (states('sensor.dark_sky_temperature') | float)) - (35.75 * (states('sensor.dark_sky_wind_speed') | float)**0.16)
+ (0.4275 * (states('sensor.dark_sky_temperature') | float) * (states('sensor.dark_sky_wind_speed') | float)**0.16)}}

Source: https://www.weather.gov/epz/wxcalc_windchill

follow the link on that page for the pdf to the calculation

Thanks, I’ll try this!

No one else getting this error after restart?
I guess there has to be an error in the following, but it works fine.

      windchill:
        value_template: >
          {% if states('sensor.out_temp') | float < 10 and states('sensor.yr_wind_speed') | float > 1.34 %}
            {{(13.12 + 0.6215*float(states.sensor.out_temp.state) - 11.37*(float(states.sensor.yr_wind_speed.state)*3.6)**0.16 + 0.3965*float(states.sensor.out_temp.state)*(float(states.sensor.yr_wind_speed.state)*3.6)**0.16) | round(1) }}
          {% else %}
            N/A
          {% endif %}
        unit_of_measurement: '°C'
        friendly_name: Wind chill

What error.? You don’t specify ?
Though looking at the template and you specifying that it only happens at restart would lead me to think that it’s the use of " states. " rather than " states ()" the former can give errors if the sensor is unavailable.

Sorry. The error i refer to is the one mentioned earlier in this discussion, This one:

ERROR (MainThread) [homeassistant.helpers.entity] Update for sensor.windchill fails
TypeError: can’t multiply sequence by non-int of type ‘float’

I’m not sure, will have to try this in my template editor, but I’d be willing to bet this is a result of (‘unavailable’ * 9 / 5) | float or some such.
Try reconfiguring the template to use states()

Use finity’s example given above, it uses the correct syntax to avoid these errors, just convert it to the entities you use.

Would this be more correct?

      windchill:
        value_template: >
          {% if states('sensor.out_temp') | float < 10 and states('sensor.yr_wind_speed') | float > 1.34 %}
            {{(13.12 + (0.6215 * (states('sensor.out_temp') | float)) - (11.37 * (states('sensor.yr_wind_speed') | float * 3.6)**0.16)
            + (0.3965 * (states('sensor.out_temp') | float) * (states('sensor.yr_wind_speed') | float *3.6)**0.16)) | round(1) }}
          {% else %}
            N/A
          {% endif %}
        unit_of_measurement: '°C'
        friendly_name: Wind chill
1 Like