Custom Weather Entity
Tags: homeassistant
Published: 2024-05-01 20:49:51

---
title: Custom Weather Entity
published: true
date: 2024-04-30 08:00:00 UTC
tags: homeassistant
canonical_url: https://beanbag.technicalissues.us/custom-weather-entity/
---

![Screenshot of weather card in Home Assistant](https://beanbag.technicalissues.us/assets/images/posts/2024-04-30-weather-card-with-my-data.png)

In Home Assistant 2024.4, this note was in the “Backward-incompatible changes” section of [the release announcement](https://www.home-assistant.io/blog/2024/04/03/release-20244/)

> The previously deprecated `forecast` attribute of weather entities, has now been removed. Use the [`weather.get_forecasts`](https://www.home-assistant.io/integrations/weather#service-weatherget_forecasts) service to get the forecast data instead.

([@gjohansson-ST](https://github.com/gjohansson-ST) - [#110761](https://github.com/home-assistant/core/pull/110761)) ([documentation](https://www.home-assistant.io/integrations/metoffice))

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](https://www.home-assistant.io/integrations/tomorrowio/) 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

```

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: ""

```

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: ""

```

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](https://beanbag.technicalissues.us/assets/images/posts/2024-04-30-custom-weather-daily.png)

![Screenshot of custom weather and hourly forecast](https://beanbag.technicalissues.us/assets/images/posts/2024-04-30-custom-weather-hourly.png)