Template Weather Provider Help

I can’t seem to get the Template Weather Provider to work, specifically importing a weather provider to provide the hourly and daily forecasts. I’m trying to combine an Ecowitt weather station with Tomorrow.io’s hourly and daily forecasts. Here are the templates that I’m using:

template:
  - trigger:
      - platform: time_pattern
        hours: /1
    action:
      - service: weather.get_forecast
        data:
          type: daily
        target:
          entity_id: weather.tomorrow_io_home_daily
        response_variable: daily
    sensor:
      - name: Daily Forecast
        unique_id: weather_forecast_daily
        state: "{{ now().isoformat() }}"
        attributes:
          forecast: "{{ daily.forecast }}"
  - trigger:
      - platform: time_pattern
        hours: /1
    action:
      - service: weather.get_forecast
        data:
          type: hourly
        target:
          entity_id: weather.tomorrow_io_home_daily
        response_variable: hourly
    sensor:
      - name: Hourly Forecast
        unique_id: weather_forecast_hourly
        state: "{{ now().isoformat() }}"
        attributes:
          forecast: "{{ hourly.forecast }}"

weather:
  - platform: template
    name: "Weather"
    condition_template: "{{states('weather.tomorrow_io_home_daily')}}"
    temperature_template: "{{states('sensor.gw2000b_v2_1_8_outdoor_temperature') | float }}"
    dew_point_template: "{{ states('sensor.gw2000b_v2_1_8_dewpoint') | float }}"
    apparent_temperature_template: "{{ states('sensor.gw2000b_v2_1_8_feels_like_temperature') | float }}"
    temperature_unit: "°F"
    humidity_template: "{{states('sensor.gw2000b_v2_1_8_humidity') | float }}"
    pressure_template: "{{states('sensor.gw2000b_v2_1_8_absolute_pressure') | float }}"
    pressure_unit: "inHg"
    wind_speed_template: "{{states('sensor.gw2000b_v2_1_8_wind_speed') | float }}"
    wind_gust_speed_template: "{{ states('sensor.gw2000b_v2_1_8_wind_gust') | float }}"
    wind_speed_unit: "mph"
    wind_bearing_template: "{{states('sensor.gw2000b_v2_1_8_wind_direction') |  float }}"
    ozone_template: "{{states('sensor.current_ozone_level') | float }}"
    visibility_template: "{{state_attr('weather.tomorrow_io_home_daily','visibility') | float }}"
    visibility_unit: "mi"
    forecast_daily_template: "{{ state_attr('weather_forecast_daily', 'forecast') }}"
    forecast_hourly_template: "{{ state_attr('weather_forecast_hourly', 'forecast') }}"
    precipitation_unit: "in"

Template sensor properly report the hourly and daily forecasts. However, the combine platform only reports information from the actual sensors and doesn’t include anything from the template sensors. When I try to call my new weather provider with weather.get_forecast, the response is forecast: [ ].

Thanks for your help.

1 Like

The entity_ids of your two Template Sensors are derived from their name option.

sensor.daily_forecast
sensor.hourly_forecast

You can confirm that by looking for them in Developer Tools > States.

Use those entity_ids in your templates as shown here:

    forecast_daily_template: "{{ state_attr('sensor.daily_forecast', 'forecast') }}"
    forecast_hourly_template: "{{ state_attr('sensor.hourly_forecast', 'forecast') }}"
1 Like

Thanks! That fixed it!

1 Like