DEV Community

Gene Liverman
Gene Liverman

Posted on • Originally published at beanbag.technicalissues.us on

Custom Weather Entity

Screenshot of weather card in Home Assistant

In Home Assistant 2024.4, this note was in the “Backward-incompatible changes” section of the release announcement

The previously deprecated forecast attribute of weather entities, has now been removed. Use the weather.get_forecasts service to get the forecast data instead.

(@gjohansson-ST - #110761) (documentation)

I had a heck of a time finding docs on this, so I have compiled what I did here.

Base weather integration

I am using the Tomorrow.io integration to get forecasts, but what I have done should work with any weather provider.

Current Conditions from Weather Station

I have made a custom weather entity that pulls current conditions from the weather station in my back yard and forecast data from the Tomorrow.io integration. The integration is known on my system as weather.tomorrow_io_leaky_cauldron_daily.

Custom Sensors

To make this work, I first needed to make sure my configuration.yaml contains this line:

template: !include templates.yaml

Enter fullscreen mode Exit fullscreen mode

I then edited templates.yaml and added this:

- trigger:
    - platform: time_pattern
      minutes: /15
  action:
    - service: weather.get_forecasts
      data:
        type: hourly
      target:
        entity_id: weather.tomorrow_io_leaky_cauldron_daily
      response_variable: hourly
    - service: weather.get_forecasts
      data:
        type: daily
      target:
        entity_id: weather.tomorrow_io_leaky_cauldron_daily
      response_variable: daily
  sensor:
    - name: Weather Forecast Hourly
      unique_id: weather_forecast_hourly
      state: ""
      attributes:
        forecast: ""
    - name: Weather Forecast Daily
      unique_id: weather_forecast_daily
      state: ""
      attributes:
        forecast: ""

Enter fullscreen mode Exit fullscreen mode

This creates two sensors: one with the hourly forecast data and one with the daily forecast data.

Custom weather entity

Next, I needed to return to configuration.yaml and add this:

weather:
  - platform: template
    name: "Home + Tomorrow.io"
    unique_id: home_plus_forecast
    condition_template: ""
    temperature_template: ""
    temperature_unit: "°F"
    humidity_template: ""
    attribution_template: "Home weather station + Tomorrow.io"
    pressure_template: ""
    pressure_unit: "inHg"
    wind_speed_template: ""
    wind_speed_unit: "mph"
    wind_bearing_template: ""
    forecast_hourly_template: ""
    forecast_daily_template: ""

Enter fullscreen mode Exit fullscreen mode

The parts of this that have weather.tomorrow_io_leaky_cauldron_daily in them are pulled from the Tomorrow.io integration while the parts that start with sensor.outdoor_weather_station are pulled from the Ecowitt integration that equates to my weather station.

The result of this is shown below:

Screenshot of custom weather and daily forecast

Screenshot of custom weather and hourly forecast

Top comments (0)