Templating weather sensor from Weather Underground entity

Hey there, from my understanding to be able to use weather underground as source for the weather cards in lovelace one has to convert it to a weather sensor using templating, right?

The basics are described here:

But what about the details? I couldn’t find a proper example :frowning:
I could find some sort of similar approach here: Create daily forecast from hourly forecast using the template weather platform

My problem is the forecast-array or list, the other are easy and work straight forward.

But I fail on providing the forecast list from combining the single forecast entities of wupws to a list which is consumed by the forecast_template…I tired a bit, but have no clue how to achieve this

    forecast_template: >-

      - datetime: '2022-03-23T00:00:00Z'
        condition: sunny
        temperature: 18
        templow: 0
        precipitation: 0
        wind_bearing: 57.3
        wind_speed: 2.06
        wind_gusts: 4.12
        precipitation_probability: 2
      - datetime: '2022-03-24T00:00:00Z'
        condition: sunny
        temperature: 17
        templow: 1
        precipitation: 0
        wind_bearing: 150.62
        wind_speed: 2.57
        wind_gusts: 4.63
        precipitation_probability: 2
      - datetime: '2022-03-25T00:00:00Z'
        condition: sunny
        temperature: 16
        templow: 2
        precipitation: 0
        wind_bearing: 22.38
        wind_speed: 3.09
        wind_gusts: 5.66
        precipitation_probability: 1
      - datetime: '2022-03-26T00:00:00Z'
        condition: sunny
        temperature: 15
        templow: 3
        precipitation: 0
        wind_bearing: 80.62
        wind_speed: 3.09
        wind_gusts: 5.66
        precipitation_probability: 2
      - datetime: '2022-03-27T00:00:00Z'
        condition: sunny
        temperature: 16
        templow: 3
        precipitation: 0
        wind_bearing: 187.38
        wind_speed: 3.09
        wind_gusts: 5.66
        precipitation_probability: 3
      - datetime: '2022-03-28T00:00:00Z'
        condition: cloudy
        temperature: 11
        templow: 5
        precipitation: 0
        wind_bearing: 304.25
        wind_speed: 4.12
        wind_gusts: 8.23
        precipitation_probability: 19
      - datetime: '2022-03-29T00:00:00Z'
        condition: cloudy
        temperature: 8
        templow: 3
        precipitation: 0
        wind_bearing: 313.62
        wind_speed: 4.12
        wind_gusts: 8.23
        precipitation_probability: 27
      - datetime: '2022-03-30T00:00:00Z'
        condition: cloudy
        temperature: 9
        templow: 2
        precipitation: 0
        wind_bearing: 276.58
        wind_speed: 4.12
        wind_gusts: 7.2
        precipitation_probability: 27
      - datetime: '2022-03-31T00:00:00Z'
        condition: cloudy
        temperature: 9
        templow: 2
        precipitation: 0
        wind_bearing: 237.88
        wind_speed: 4.63
        wind_gusts: 9.77
        precipitation_probability: 25

Help is very much appreciated :slight_smile:

wow, I managed it:

weather:
  - platform: template
    name: WUnderground Template
    temperature_template: "{{ states('sensor.wupws_temp') | float }}"
    humidity_template: "{{ states('sensor.wupws_humidity') | float }}"
    pressure_template: "{{ states('sensor.wupws_pressure') | int }}"
    wind_speed_template: "{{ states('sensor.wupws_windspeed') | float }}"
    wind_bearing_template: "{{ states('sensor.wupws_winddir') | float }}"
    attribution_template: "{{ state_attr('sensor.wupws_temp', 'attribution') }}"

    condition_template: >-

      {% set condition_id = state_attr('sensor.wupws_weather_1d', 'entity_picture') | regex_replace(find='/local/wupws_icons/', replace='', ignorecase=False) | regex_replace(find='.png', replace='', ignorecase=False) | int(0) %}

      {% if condition_id in [-1] -%}
        dummy
      {% elif condition_id in [-2] -%}
        dummy
      {%- else -%}
        unknown
      {%- endif %}


    # forecast_template: "{{ state_attr('weather.dwd_weather_muenster_zentrum', 'forecast') }}"
    forecast_template: >-
      [
        {
          {% set dat = now() + timedelta( days = 0 ) %}
          "datetime": "{{ dat.strftime("%Y-%m-%dT00:00:00Z") }}",
          "temperature": {{ states('sensor.wupws_temp_high_1d') }},
          "templow": {{ states('sensor.wupws_temp_low_1d') }},
          "precipitation": {{ states('sensor.wupws_precip_1d') }},
          "precipitation_probability": {{ states('sensor.wupws_precip_chance_1d') }},
          "wind_speed": {{ states('sensor.wupws_wind_1d') }},
        },
        {
          {% set dat = now() + timedelta( days = 1 ) %}
          "datetime": "{{ dat.strftime("%Y-%m-%dT00:00:00Z") }}",
          "temperature": {{ states('sensor.wupws_temp_high_2d') }},
          "templow": {{ states('sensor.wupws_temp_low_2d') }},
          "precipitation": {{ states('sensor.wupws_precip_2d') }},
          "precipitation_probability": {{ states('sensor.wupws_precip_chance_2d') }},
          "wind_speed": {{ states('sensor.wupws_wind_2d') }},
        },
        {
          {% set dat = now() + timedelta( days = 2 ) %}
          "datetime": "{{ dat.strftime("%Y-%m-%dT00:00:00Z") }}",
          "temperature": {{ states('sensor.wupws_temp_high_3d') }},
          "templow": {{ states('sensor.wupws_temp_low_3d') }},
          "precipitation": {{ states('sensor.wupws_precip_3d') }},
          "precipitation_probability": {{ states('sensor.wupws_precip_chance_3d') }},
          "wind_speed": {{ states('sensor.wupws_wind_3d') }},
        }
      ]

I just have to map the condition coming from the entity_picture :slight_smile:

P.S.: corresponding WU sensor looks like this:

sensor:

  - platform: wundergroundpws
    api_key: $$$INSERT$$$
    pws_id:  $$$INSERT$$$
    numeric_precision: none
    monitored_conditions:
      - solarRadiation
      - uv
      - winddir
      - humidity
      - dewpt
      - heatIndex
      - windChill
      - precipTotal
      - precipRate
      - pressure
      - temp
      - windGust
      - windSpeed
      - weather_1d
      - weather_1n

      - temp_high_1d
      - temp_low_1d
      - precip_1d
      - precip_chance_1d
      - wind_1d

      - temp_high_2d
      - temp_low_2d
      - precip_2d
      - precip_chance_2d
      - wind_2d

      - temp_high_3d
      - temp_low_3d
      - precip_3d
      - precip_chance_3d
      - wind_3d

      - temp_high_4d
      - temp_low_4d
      - precip_4d
      - precip_chance_4d
      - wind_4d

      - temp_high_5d
      - temp_low_5d
      - precip_5d
      - precip_chance_5d
      - wind_5d

1 Like

That is what I’m looking for as well :slight_smile:
Have you ever got it working with icons etc as it doesn’t work as per your example

1 Like