
I've created the above Home Assistant (lovelace) dashboard card which you can add to your own dashboard.
It uses data from DEFRA's UK air pollution RSS feed which is available for over 4000 locations across the UK.
- Find your local measuring station
- Filter the RSS feed
- Install feedparser
- Create a sensor
- Install the mushroom card
- Install card-mod
- Restart home assistant
- Card
- Credits
- Enter your postcode on DEFRA's UK Air Pollution forecast website.
- Take note of the name of the nearest station given in the table that appears. (For this example, we're going to use 'Southwark'.)
DEFRA's RSS feed contains over 4000 entries. You only need one.
- Go to https://siftrss.com
- Enter the DEFRA RSS feed url: https://uk-air.defra.gov.uk/assets/rss/forecast.xml and your station name in capital letters.
- Click Feed me!
- Take note of the filtered RSS feed.
- Click on the filtered URL to check it contains only one entry. (If more than one entry contains your station name, you may need to use the 'matches regex' option in siftrss instead.)

Install feedparser into Home Assistant if you don't already have it.
In your configuration.yaml
file, add the following sensor substituting in your filtered feed_url.
sensor:
- platform: feedparser
name: Defra air quality forecast
# Used siftrss to filter https://uk-air.defra.gov.uk/assets/rss/forecast.xml
# to show only Southwark
feed_url: https://siftrss.com/f/P19Z3RPQXLW
date_format: '%a, %b %d %I:%M %p'
scan_interval:
hours: 8
Go to 'Developer tools' and click check configuration.
Install the mushroom card into Home Assistant if you don't already have it.
Install card mod into Home Assistant if you don't already have it.
Restart home assistant.

Add a new manual card to your dashboard. Delete the default text and paste in the following YAML code.
> Click here to see the dashboard YAML code >>
# Sourcecode by CJDumbleton
square: true
type: grid
cards:
- type: custom:mushroom-template-card
primary: >-
{% set summary =
state_attr('sensor.defra_air_quality_forecast','entries')[0].summary %}
{{ summary | regex_findall_index(find='\w\w\w', index=-5,
ignorecase=False) }}
icon: >-
{% set summary =
state_attr('sensor.defra_air_quality_forecast','entries')[0].summary %}
{% set index = summary | regex_findall_index(find='\d+', index=-5,
ignorecase=False) | int %}
{% set icon = {
1: 'mdi:numeric-1',
2: 'mdi:numeric-2',
3: 'mdi:numeric-3',
4: 'mdi:numeric-4',
5: 'mdi:numeric-5',
6: 'mdi:numeric-6',
7: 'mdi:numeric-7',
8: 'mdi:numeric-8',
9: 'mdi:numeric-9',
10: 'mdi:numeric-10'} %}
{{ icon.get(index, 'mdi:cloud-question' ) }}
icon_color: >-
{% set summary =
state_attr('sensor.defra_air_quality_forecast','entries')[0].summary %}
{% set index = summary | regex_findall_index(find='\d+', index=-5,
ignorecase=False) | int %}
{% set color = {
1: 'teal',
2: 'green',
3: 'lime',
4: 'yellow',
5: 'amber',
6: 'orange',
7: 'red',
8: 'pink',
9: 'brown',
10: 'purple'} %}
{{ color.get(index, 'grey' ) }}
layout: vertical
entity: sensor.defra_air_quality_forecast
multiline_secondary: false
layout_options:
grid_columns: 1
grid_rows: 2
secondary: >-
{% set summary =
state_attr('sensor.defra_air_quality_forecast','entries')[0].summary %}
{% set index = summary | regex_findall_index(find='\d+', index=-5,
ignorecase=False) | int %}
{% set level = {
1: 'Low',
2: 'Low',
3: 'Low',
4: 'Moderate',
5: 'Moderate',
6: 'Moderate',
7: 'High',
8: 'High',
9: 'High',
10: 'Very high'} %}
{{ level.get(index, 'Unknown' ) }}
card_mod:
style: |
ha-card {
--icon-size: 60px;
background-color: hsla(0, 0%, 0%, 0);
}
- type: custom:mushroom-template-card
primary: >-
{% set summary =
state_attr('sensor.defra_air_quality_forecast','entries')[0].summary %}
{{ summary | regex_findall_index(find='\w\w\w', index=-4,
ignorecase=False) }}
icon: >-
{% set summary =
state_attr('sensor.defra_air_quality_forecast','entries')[0].summary %}
{% set index = summary | regex_findall_index(find='\d+', index=-4,
ignorecase=False) | int %}
{% set icon = {
1: 'mdi:numeric-1',
2: 'mdi:numeric-2',
3: 'mdi:numeric-3',
4: 'mdi:numeric-4',
5: 'mdi:numeric-5',
6: 'mdi:numeric-6',
7: 'mdi:numeric-7',
8: 'mdi:numeric-8',
9: 'mdi:numeric-9',
10: 'mdi:numeric-10'} %}
{{ icon.get(index, 'mdi:cloud-question' ) }}
icon_color: >-
{% set summary =
state_attr('sensor.defra_air_quality_forecast','entries')[0].summary %}
{% set index = summary | regex_findall_index(find='\d+', index=-4,
ignorecase=False) | int %}
{% set color = {
1: 'teal',
2: 'green',
3: 'lime',
4: 'yellow',
5: 'amber',
6: 'orange',
7: 'red',
8: 'pink',
9: 'brown',
10: 'purple'} %}
{{ color.get(index, 'grey' ) }}
layout: vertical
entity: sensor.defra_air_quality_forecast
multiline_secondary: false
layout_options:
grid_columns: 1
grid_rows: 2
secondary: >-
{% set summary =
state_attr('sensor.defra_air_quality_forecast','entries')[0].summary %}
{% set index = summary | regex_findall_index(find='\d+', index=-4,
ignorecase=False) | int %}
{% set level = {
1: 'Low',
2: 'Low',
3: 'Low',
4: 'Moderate',
5: 'Moderate',
6: 'Moderate',
7: 'High',
8: 'High',
9: 'High',
10: 'Very high'} %}
{{ level.get(index, 'Unknown' ) }}
card_mod:
style: |
ha-card {
--icon-size: 60px;
background-color: hsla(0, 0%, 0%, 0);
}
- type: custom:mushroom-template-card
primary: >-
{% set summary =
state_attr('sensor.defra_air_quality_forecast','entries')[0].summary %}
{{ summary | regex_findall_index(find='\w\w\w', index=-3,
ignorecase=False) }}
icon: >-
{% set summary =
state_attr('sensor.defra_air_quality_forecast','entries')[0].summary %}
{% set index = summary | regex_findall_index(find='\d+', index=-3,
ignorecase=False) | int %}
{% set icon = {
1: 'mdi:numeric-1',
2: 'mdi:numeric-2',
3: 'mdi:numeric-3',
4: 'mdi:numeric-4',
5: 'mdi:numeric-5',
6: 'mdi:numeric-6',
7: 'mdi:numeric-7',
8: 'mdi:numeric-8',
9: 'mdi:numeric-9',
10: 'mdi:numeric-10'} %}
{{ icon.get(index, 'mdi:cloud-question' ) }}
icon_color: >-
{% set summary =
state_attr('sensor.defra_air_quality_forecast','entries')[0].summary %}
{% set index = summary | regex_findall_index(find='\d+', index=-3,
ignorecase=False) | int %}
{% set color = {
1: 'teal',
2: 'green',
3: 'lime',
4: 'yellow',
5: 'amber',
6: 'orange',
7: 'red',
8: 'pink',
9: 'brown',
10: 'purple'} %}
{{ color.get(index, 'grey' ) }}
layout: vertical
entity: sensor.defra_air_quality_forecast
multiline_secondary: false
layout_options:
grid_columns: 1
grid_rows: 2
secondary: >-
{% set summary =
state_attr('sensor.defra_air_quality_forecast','entries')[0].summary %}
{% set index = summary | regex_findall_index(find='\d+', index=-3,
ignorecase=False) | int %}
{% set level = {
1: 'Low',
2: 'Low',
3: 'Low',
4: 'Moderate',
5: 'Moderate',
6: 'Moderate',
7: 'High',
8: 'High',
9: 'High',
10: 'Very high'} %}
{{ level.get(index, 'Unknown' ) }}
card_mod:
style: |
ha-card {
--icon-size: 60px;
background-color: hsla(0, 0%, 0%, 0);
}
- type: custom:mushroom-template-card
primary: >-
{% set summary =
state_attr('sensor.defra_air_quality_forecast','entries')[0].summary %}
{{ summary | regex_findall_index(find='\w\w\w', index=-2,
ignorecase=False) }}
icon: >-
{% set summary =
state_attr('sensor.defra_air_quality_forecast','entries')[0].summary %}
{% set index = summary | regex_findall_index(find='\d+', index=-2,
ignorecase=False) | int %}
{% set icon = {
1: 'mdi:numeric-1',
2: 'mdi:numeric-2',
3: 'mdi:numeric-3',
4: 'mdi:numeric-4',
5: 'mdi:numeric-5',
6: 'mdi:numeric-6',
7: 'mdi:numeric-7',
8: 'mdi:numeric-8',
9: 'mdi:numeric-9',
10: 'mdi:numeric-10'} %}
{{ icon.get(index, 'mdi:cloud-question' ) }}
icon_color: >-
{% set summary =
state_attr('sensor.defra_air_quality_forecast','entries')[0].summary %}
{% set index = summary | regex_findall_index(find='\d+', index=-2,
ignorecase=False) | int %}
{% set color = {
1: 'teal',
2: 'green',
3: 'lime',
4: 'yellow',
5: 'amber',
6: 'orange',
7: 'red',
8: 'pink',
9: 'brown',
10: 'purple'} %}
{{ color.get(index, 'grey' ) }}
layout: vertical
entity: sensor.defra_air_quality_forecast
multiline_secondary: false
layout_options:
grid_columns: 1
grid_rows: 2
secondary: >-
{% set summary =
state_attr('sensor.defra_air_quality_forecast','entries')[0].summary %}
{% set index = summary | regex_findall_index(find='\d+', index=-2,
ignorecase=False) | int %}
{% set level = {
1: 'Low',
2: 'Low',
3: 'Low',
4: 'Moderate',
5: 'Moderate',
6: 'Moderate',
7: 'High',
8: 'High',
9: 'High',
10: 'Very high'} %}
{{ level.get(index, 'Unknown' ) }}
card_mod:
style: |
ha-card {
--icon-size: 60px;
background-color: hsla(0, 0%, 0%, 0);
}
- type: custom:mushroom-template-card
primary: >-
{% set summary =
state_attr('sensor.defra_air_quality_forecast','entries')[0].summary %}
{{ summary | regex_findall_index(find='\w\w\w', index=-1,
ignorecase=False) }}
icon: >-
{% set summary =
state_attr('sensor.defra_air_quality_forecast','entries')[0].summary %}
{% set index = summary | regex_findall_index(find='\d+', index=-1,
ignorecase=False) | int %}
{% set icon = {
1: 'mdi:numeric-1',
2: 'mdi:numeric-2',
3: 'mdi:numeric-3',
4: 'mdi:numeric-4',
5: 'mdi:numeric-5',
6: 'mdi:numeric-6',
7: 'mdi:numeric-7',
8: 'mdi:numeric-8',
9: 'mdi:numeric-9',
10: 'mdi:numeric-10'} %}
{{ icon.get(index, 'mdi:cloud-question' ) }}
icon_color: >-
{% set summary =
state_attr('sensor.defra_air_quality_forecast','entries')[0].summary %}
{% set index = summary | regex_findall_index(find='\d+', index=-1,
ignorecase=False) | int %}
{% set color = {
1: 'teal',
2: 'green',
3: 'lime',
4: 'yellow',
5: 'amber',
6: 'orange',
7: 'red',
8: 'pink',
9: 'brown',
10: 'purple'} %}
{{ color.get(index, 'grey' ) }}
layout: vertical
entity: sensor.defra_air_quality_forecast
multiline_secondary: false
layout_options:
grid_columns: 1
grid_rows: 2
secondary: >-
{% set summary =
state_attr('sensor.defra_air_quality_forecast','entries')[0].summary %}
{% set index = summary | regex_findall_index(find='\d+', index=-1,
ignorecase=False) | int %}
{% set level = {
1: 'Low',
2: 'Low',
3: 'Low',
4: 'Moderate',
5: 'Moderate',
6: 'Moderate',
7: 'High',
8: 'High',
9: 'High',
10: 'Very high'} %}
{{ level.get(index, 'Unknown' ) }}
card_mod:
style: |
ha-card {
--icon-size: 60px;
background-color: hsla(0, 0%, 0%, 0);
}
title: DEFRA air pollution 5-day forecast
columns: 5
- Forecast data: © Crown 2025 copyright Defra via uk-air.defra.gov.uk, licenced under the Open Government Licence OGL.
- Forecast provided by the Met Office
Buy coffees for:
- I based the card on vd Brink's Kleenex pollen radar card
- siftrss
- feedparser
- Mushroom card
- Card mod