Thanks! Works like a charm
Great job!
Any idea how to scrape the forecast for the next days?
Nice!
Somewhat the same overhere. Used templating to get the right value (and color) shown in the card.
Thats nice, how did you do that?
FYI, as nobody seems to pick it up here, I created an issue in HA Core GitHub
No more scraping just use the Kleenex pollen radar / Scottex custom component you can get from the HACS store!
Here is my setup, I’ll show you how to create an attractive and functional widget to display pollen levels in your area using Home Assistant. We will use the button-card
custom component for this setup.
Prerequisites
Before you begin, make sure you have the following:
- Home Assistant installed and running
- HACS (Home Assistant Community Store) installed
1. Install Kleenex Pollen Radar via HACS
- Go to your Home Assistant.
- Click on “HACS” in the sidebar.
- Click on “Integrations”.
- Search for “Kleenex Pollen Radar” and install it.
2. Install button-card
via HACS
- Go to your Home Assistant.
- Click on “HACS” in the sidebar.
- Click on “Frontend”.
- Search for “button-card” and install it.
3. Update configuration.yaml
Add the following template sensors to your configuration.yaml
file to categorize pollen levels:
sensor:
- platform: template
sensors:
grass_pollen_home_level:
friendly_name: "Grass Pollen Level (Home)"
value_template: >-
{% set value = states('sensor.grass_pollen_home') | int %}
{% if value <= 29 %}
Laag
{% elif value <= 60 %}
Gemiddeld
{% elif value <= 341 %}
Hoog
{% else %}
Zeer Hoog
{% endif %}
icon_template: >-
{% set value = states('sensor.grass_pollen_home') | int %}
{% if value <= 29 %}
mdi:leaf
{% elif value <= 60 %}
mdi:tree
{% elif value <= 341 %}
mdi:tree-outline
{% else %}
mdi:forest
{% endif %}
tree_pollen_home_level:
friendly_name: "Tree Pollen Level (Home)"
value_template: >-
{% set value = states('sensor.tree_pollen_home') | int %}
{% if value <= 95 %}
Laag
{% elif value <= 207 %}
Gemiddeld
{% elif value <= 703 %}
Hoog
{% else %}
Zeer Hoog
{% endif %}
icon_template: >-
{% set value = states('sensor.tree_pollen_home') | int %}
{% if value <= 95 %}
mdi:leaf
{% elif value <= 207 %}
mdi:tree
{% elif value <= 703 %}
mdi:tree-outline
{% else %}
mdi:forest
{% endif %}
weed_pollen_home_level:
friendly_name: "Weed Pollen Level (Home)"
value_template: >-
{% set value = states('sensor.weed_pollen_home') | int %}
{% if value <= 20 %}
Laag
{% elif value <= 77 %}
Gemiddeld
{% elif value <= 266 %}
Hoog
{% else %}
Zeer Hoog
{% endif %}
icon_template: >-
{% set value = states('sensor.weed_pollen_home') | int %}
{% if value <= 20 %}
mdi:leaf
{% elif value <= 77 %}
mdi:tree
{% elif value <= 266 %}
mdi:tree-outline
{% else %}
mdi:forest
{% endif %}
4. Update customize.yaml
Add the following to your customize.yaml
file to set the icon colors based on the pollen levels:
homeassistant:
customize: !include customize.yaml
sensor.grass_pollen_home_level:
templates:
icon_color: >
if (state === 'Laag') return 'green';
if (state === 'Gemiddeld') return 'orange';
if (state === 'Hoog') return 'red';
if (state === 'Zeer Hoog') return 'purple';
sensor.tree_pollen_home_level:
templates:
icon_color: >
if (state === 'Laag') return 'green';
if (state === 'Gemiddeld') return 'orange';
if (state === 'Hoog') return 'red';
if (state === 'Zeer Hoog') return 'purple';
sensor.weed_pollen_home_level:
templates:
icon_color: >
if (state === 'Laag') return 'green';
if (state === 'Gemiddeld') return 'orange';
if (state === 'Hoog') return 'red';
if (state === 'Zeer Hoog') return 'purple';
5. Add the Lovelace Dashboard Widget
Add the following configuration to your Lovelace dashboard. This example uses the vertical-stack-in-card
custom card, which you can also install via HACS if you haven’t already.
type: vertical-stack
cards:
- type: custom:vertical-stack-in-card
title: Pollen Levels (Home)
cards:
- type: horizontal-stack
cards:
- type: custom:button-card
entity: sensor.grass_pollen_home_level
name: Grass Pollen
icon: mdi:grass
show_state: true
state:
- value: Laag
color: green
- value: Gemiddeld
color: orange
- value: Hoog
color: red
- value: Zeer Hoog
color: purple
styles:
card:
- height: 120px
- border-radius: 10px
name:
- font-size: 16px
- font-weight: bold
state:
- font-size: 14px
icon:
- height: 40px
- width: 40px
- type: custom:button-card
entity: sensor.tree_pollen_home_level
name: Tree Pollen
icon: mdi:tree
show_state: true
state:
- value: Laag
color: green
- value: Gemiddeld
color: orange
- value: Hoog
color: red
- value: Zeer Hoog
color: purple
styles:
card:
- height: 120px
- border-radius: 10px
name:
- font-size: 16px
- font-weight: bold
state:
- font-size: 14px
icon:
- height: 40px
- width: 40px
- type: custom:button-card
entity: sensor.weed_pollen_home_level
name: Weed Pollen
icon: mdi:flower
show_state: true
state:
- value: Laag
color: green
- value: Gemiddeld
color: orange
- value: Hoog
color: red
- value: Zeer Hoog
color: purple
styles:
card:
- height: 120px
- border-radius: 10px
name:
- font-size: 16px
- font-weight: bold
state:
- font-size: 14px
icon:
- height: 40px
- width: 40px
- type: custom:button-card
entity: sensor.last_updated_pollen_home
name: Last Updated
icon: mdi:clock
show_state: true
styles:
card:
- height: 120px
- border-radius: 10px
name:
- font-size: 16px
- font-weight: bold
state:
- font-size: 14px
icon:
- height: 40px
- width: 40px
6. Add to Lovelace Dashboard
To add this configuration to your Lovelace dashboard:
- Go to your Home Assistant dashboard.
- Click on the three dots in the top right corner and select “Edit Dashboard”.
- Click on “Add Card” and choose “Manual Card”.
- Paste the YAML configuration above into the card configuration and click “Save”.
Final Result
Here’s how your dashboard should look:
Now you have a beautiful and functional widget displaying the pollen levels in your area, complete with dynamic colors indicating the severity of pollen levels.
Feel free to customize the card styles and layout to better fit your needs!
Update your post.
You have to add “GitHub - MarcoGos/kleenex_pollenradar: Kleenex pollenradar custom component integration for Home Assistant” add custom repositories to Abel to install the Kleenex Pollen Radar
I still use the scrape and it is still working. Good to know there is a custom component, just in case the scrape breaks down.
Copied it all over. I get data but the colors are not showing. I don’t understand why.
Anybody got a working forecast example?
i saw this one online and it looks amazing!
To bad that the code is not shared
do u use the correct sensors? I had the same problem and noticed that i was using the wrong ones.