Wet Bulb Globe Temperature for NWS integration

The NWS recently started observing and forecasting the Wet Bulb Globe temperature. It would be awesome if this could be added as one of the initially disabled sensors as part of the NWS integration.

Please see links below explaining Wet Bulb Globe Temp and why its important, and the NWS page showing the data. Thanks.

https://digital.mdl.nws.noaa.gov/?zoom=4&lat=37&lon=-96.5&layers=F000BTTTFTT&region=0&element=8&mxmz=false&barbs=false&subl=TFFFFF&units=english&wunits=nautical&coords=latlon&tunits=localt

Unfortunately, the wet bulb temperature is not available on the API endpoint being used in home assistant, i.e. api.weather.gov. The one from the link is the ndfd api National Digital Forecast Database - MDL - Virtual Lab. This would likely require a completely new integration unfortunately, unless NWS adds it to the API data.

1 Like

Ok wasn’t sure if it would be simple or not. Thanks for the explanation and quick reply.

The ndfd data seems to have a rest service though.

Good to know. Guess I have another reason to try and learn the rest integrations. I’m a pilot and I’ve been trying to get Raw Metar Pulled into HA, from https://account.avwx.rest/ but when I looked at the the REST integrations, I kinda got stuck on parsing it. Going to have to find a decent tutorial and try and do both.

I believe the nws api already uses the metar data to generate the current observations. At least I assume so, since the only observations are only available at metar stations. And the raw metar data is also available, for free.

If you find the api doesn’t work for you, there is a python-metar library that will decode it for you. GitHub - python-metar/python-metar: a python package that parses coded METAR weather reports.

You can use the dew point or relative humidity and the temperature to calculate the wet bulb temperature, but I think these are only available right now on the observation. These could be added to the forecasts with some effort.

If you’d like to try it out, here is an example to grab the current data, including the raw metar data from KADW:

https://api.weather.gov/stations/KADW/observations/latest

The raw metar is under properties and rawMessage.

Were you able to get the Wet Bulb observation figured out? I’m looking for something similar. Thank you!

I would use a template to convert the existing relative humidity and temperature to a wet bulb temperature. Here is one such equation. I’m not confident you can get this to work in a template, but there are bound to be simpler formulas.

To my future self, I tried adding the following via HACS, using my local Temp, Humidity and pressure sensor values, but the wet bulb came across as an attribute and was not reliable.

So I created the following template and added it to sensor.yaml. I had a bunch of issues with home assistant auto changing the temp units, which is why I made sure to do my own conversions. The same template could be modified by changing the temperature and humidity values to whatever sensor you’d like. Please note that the temperature value must be in C:

- platform: template
  sensors:
    frontyard_temperature_in_c:
      unit_of_measurement: "C"
      value_template: '{{ ((states("sensor.shellyht_outdoor_temperature") | float -32) *5/9) }}'
      device_class: temperature
    wetbulb_temperature_in_c:
      unit_of_measurement: "C"
      value_template: '{{
        (states("sensor.frontyard_temperature_in_c") |float * atan(0.151977 * ((states("sensor.shellyht_outdoor_humidity") | float + 8.313659) **(1/2) )))
        + (atan((states("sensor.frontyard_temperature_in_c") | float ) + (states("sensor.shellyht_outdoor_humidity") | float)))
        - (atan(states("sensor.shellyht_outdoor_humidity") | float - 1.676331))
        + (((states("sensor.shellyht_outdoor_humidity") | float) **(3/2))  * (atan((states("sensor.shellyht_outdoor_humidity") | float) * 0.023101)) * 0.00391838)
        - 4.686035
        }}'
      device_class: temperature
    wetbulb_f:
      unit_of_measurement: "F"
      value_template: '{{(states("sensor.wetbulb_temperature_in_c") | float * 9/5+32) | round(2) }}'
      device_class: temperature
2 Likes

Very interesting. Thank you a lot.
I am trying to make it work for me.
As I am in Europe, all temps are in C, so I must double check the °F->°C->°F conversions.

For anyone coming across this now, there’s a reasonable way to grab WBGT from NOAA’s REST API. Drop this into your configuration.yml:

sensor:
  - platform: rest
    name: wbgt_noaa
    resource_template: "https://digital.mdl.nws.noaa.gov/xml/sample_products/browser_interface/ndfdXMLclient.php?whichClient=NDFDgen&lat=XXXXXX&lon=XXXXXX&product=time-series&XMLformat=DWML&begin={{now().replace(microsecond=0).isoformat()}}&end={{(now() + timedelta(hours=1)).replace(microsecond=0).isoformat()}}&Unit=e&wbgt=wbgt"
    value_template: "{{ value_json['dwml']['data']['parameters']['temperature']['value'] }}"
    device_class: temperature

Replace the XXXXXX with your specific lat/lon coordinates. Sensor will return your local WBGT value as an entity with name sensor.wbgt_noaa

2 Likes

is there a variable for the home assistant lat/lon that could be inserted into this yml instead of manual entry?

Yes, you can usually grab those from the entity’s attributes. For example: {{state_attr(‘device_tracker.name_of_device_tracker’,‘latitude’)}}