Template sensor for expected rainfall

Hi folks,
I have some skylights in my house that I tend to open in the morning and I’d love if my system would warn me if rain is expected during the day and if possible at what time. I’m assuming I’ll need to create some template sensors, but if someone else has already done this, I’d be grateful if you could share your code. Obviously the 1st step is to parse the data from my weather integration, but I’m not entirely sure how to go about that.

Doesn’t the AccuWeather integration’s precipitation field give you what you are looking for?

Eventually, you can run this action, to get data in the daily variable and use the values from there:

  - action: weather.get_forecasts
    data:
      type: daily
    target:
      entity_id: weather.forecast_home
    response_variable: daily

When I run it, variable daily contains:

daily:
  weather.forecast_home:
    forecast:
      - condition: sunny
        datetime: '2025-05-01T10:00:00+00:00'
        wind_bearing: 221.1
        uv_index: 2.9
        temperature: 23.7
        templow: 15.4
        wind_speed: 13
        precipitation: 0
        humidity: 40
      - condition: partlycloudy
        datetime: '2025-05-02T10:00:00+00:00'
        wind_bearing: 172
        uv_index: 6.8
        temperature: 25.5
        templow: 11.7
        wind_speed: 21.6
        precipitation: 0
        humidity: 37
      - other days follow

I think we need to know what weather integration you’re using. Some of them have a “probability of precipitation” attribute.

That’s fair. It’s my local weather service in Ireland, so information comes from met.ie. I can get the hourly forecast on the forecast card, which gives me Air pressure, temperature, wind speed and direction, and weather conditions (sunny / raining / cloudy / etc)
So all I need to to get the weather conditions attribute each hour for the current day (ie. Sunny, cloudy, rain, etc)

It does, but I also need to figure out how to request just the condition attribute, for each hour of the day, and then in an automation I want to be able to search that variable for any mention of rain, if you follow.

Can’t you do the automation every hour (trigger is time pattern), get the weather on an hourly basis, and then continue with whatever is needed?

Something like:

alias: New automation
description: ""
triggers:
  - trigger: time_pattern
    hours: "*"
    minutes: "0"
    seconds: "0"
conditions: []
actions:
  - action: weather.get_forecasts
    data:
      type: hourly
    target:
      entity_id: weather.forecast_home
    response_variable: hourly_result
  - variables:
      precipitation_0: >
        {{
        hourly_result['weather.forecast_home']['forecast'][0]['precipitation']
        }}
      precipitation_1: >
        {{
        hourly_result['weather.forecast_home']['forecast'][1]['precipitation']
        }}
      precipitation_2: >
        {{
        hourly_result['weather.forecast_home']['forecast'][2]['precipitation']
        }}
  - if: 
    // do your stuff with variables here...
mode: single

Or you manage some other variables, but at least you get the idea I believe.

I cant because i want to trigger it when i open the skylights in the morning. The idea is that when i open the windows, the system will check the forecast and let me know if rain is due while im at work. I know it wont be perfect, but its where id like to start.

Then do the same as above, except trigger will be something else (either when windows are open or at specific morning time).

You anyway need to:

  • Ask for a forecast at specific event
  • Decode the event
  • Continue running automation with if statement and check if value is at your desired state
  • Do whatever you plan once you detect it might rain later

Since you’re in Ireland, you can probably use the UK Met office DataHub, which gives quite a lot of detail on the probability of rain.

There’s a hourly, three-hourly and daily sensors.

No official HA integration at the moment (the current Met Office integration will stop working later this year), but this template system works really well:

As I’m in Ireland, and as mentioned above, I’m using the data from “met.ie” which is the irish weather service and has an official integration. The weather.get_forecasts action gives me the following for each hour;

weather.home:
  forecast:
    - precipitation: 0
      wind_bearing: 23.4
      condition: sunny
      datetime: "2025-05-02T10:00:00+00:00"
      temperature: 14.2
      pressure: 1020.1
      wind_speed: 10.8

So what I need to figure out, is how to check, in that data, for the condition “rainy” or any condition to do with rain.
The point is that when I open the skylight in the morning, my system will check the forecast for the day and let me know if rain is forecast, in which case I’ll close the skylights again. It’s a bit roundabout, and perhaps I’m not explaining myself clearly, but it’s more for my wife, who doesn’t check the weather, so just having the forecast on a screen wouldn’t work.

{{ 'rainy' in your_response_variable['weather.home'].forecast | map(attribute='condition') | list }}
2 Likes