Pollen-Sensor (Austria) - json_attributes

Hi Rene!

Let’s stay in english - since this is an international forum.
To be honest - that’s not very special. Just put the configuration from above somewhere in your config-file and you’re good to go.

Take the config from the second post. Do you get any error messages in your HA logfile about the rest-sensors?

Cheers mate

Hi

it tried to add your code from the 2nd post in my configuration.yaml (as Sensor), restarted HA but I don’t get any data from polleninformation.at
I didn’t change something (also the coordinates still yours). Do I have to change something more?
Can you please help me?

Thanks
Markus

In the meanwhile I could solve this by my self.
It wat was a user error, i was looking at a attribute that is not active now.

Now I’m looking for a solution to get a overall number for the actual day, like on the homepage.
Can some one help me with this?
Is this also in the answer from the homepage? Do i hace tho calculate it?

Please some support
Thanke
Markus

I’m not sure what do you mean. What kind of number do you expect?

thx Florian

Thank you for asking.

I am referring to the key figure (allergy risk) that is displayed at the top of https://www.polleninformation.at/.
I am not sure whether it is a rounded average or the maximum value of all allergy substances.

Maybe I can calculate it yourself with a template sensor. Unfortunately, I’m not that good at it.

I would like to display this key figure in a dashboard and then open the detailed view by clicking on it.

We are all allergy sufferers in my household, so the information would be very interesting.

Thank you very much
Markus

Hi Markus,

unfortunately I can not answer that yet - since I don’t know how this value (i guess you mean this one? →

) is calculated. Unfortunately currently I do not have the time to install a intercepting-proxy to check.

Maybe I’ll have time later on.

sorry mate :frowning:

Cheers Flo

I’m not entirely certain if this is the correct value, but I am assuming it is. Below is the additional rest-template sensor that can be used to retrieve the forecast data.

If my interpretation is correct, this should display the daily average of the allergy risk.

- name: pollen_report_klagenfurt_dayrisk
  unique_id: 'e0279661-35cc-43ae-931b-8d7af59b8e80'
  resource: 'https://www.polleninformation.at/index.php?eID=appinterface&pure_json=1&lang_code=de&lang_id=0&action=getFullContaminationData&type=gps&value[latitude]=46.628&value[longitude]=14.309&country_id=1&personal_contamination=false&sensitivity=0&country=AT&sessionid='
  platform: rest
  icon: mdi:flower-pollen-outline
  scan_interval: 600
  value_template: >
    {% set dayrisk = value_json.result.additionalForecastData[0].dayrisk %}
    {% if dayrisk == 0 %} Keine
    {% elif dayrisk == 1 %} Niedrig
    {% elif dayrisk == 2 %} Mittel
    {% elif dayrisk == 3 %} Hoch
    {% else %} Unbekannt
    {% endif %}
  json_attributes_path: "$.result.additionalForecastData[0]"
  json_attributes:
    - dayrisk
    - air_quality
    - asthma_weather
    - ozone
    - particulate_matter
    - sulphur_dioxide
    - nitrogen_dioxide

this will result in:

Cheers Flo

There is also this data in the Json

    "hourlyLoadData": {
      "total": [3, 3, 3, 3],
      "dayrisk_personalized": false,
      "hourly": [
        [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 2, 2, 2, 2, 2, 2, 2, 3, 3, 3],
        [2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 3, 2, 2, 3, 3, 3, 3, 3, 3, 3, 3],
        [3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3],
        [3, 3, 1, 1, 1, 2, 2, 2, 2, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]
      ]
    },

which I interpret as hourly allergy risk. The correct rest-sensor to fetch this data would be

- platform: rest
  name: "pollen_data_klagenfurt"
  unique_id: '648d2575-31af-455d-9866-bcfafd68d892'
  icon: mdi:flower-pollen-outline
  resource: "https://www.polleninformation.at/index.php?eID=appinterface&pure_json=1&lang_code=de&lang_id=0&action=getFullContaminationData&type=gps&value[latitude]=46.628&value[longitude]=14.309&country_id=1&personal_contamination=false&sensitivity=0&country=AT&sessionid="
  method: GET
  scan_interval: 600
  value_template: "{{ value_json.success }}"
  json_attributes_path: "$.result.hourlyLoadData"
  json_attributes:
    - hourly

also you would need an template sensor to interpret this data for homeassistant

- platform: template
  sensors:
    pollen_risk_current_hour:
      friendly_name: "Pollenrisiko Aktuelle Stunde"
      value_template: >
        {% set current_hour = now().hour %}
        {% set hourly_risks = state_attr('sensor.pollen_data_klagenfurt', 'hourly') %}
        {% if hourly_risks is not none and current_hour < hourly_risks[0] | length %}
          {{ hourly_risks[0][current_hour] }}
        {% else %}
          unknown
        {% endif %}
      icon_template: "mdi:flower-pollen"

pps: this is my updated pollen-auto-entities-card:

type: custom:auto-entities
card:
  square: false
  type: grid
  columns: 1
card_param: cards
filter:
  include:
    - entity_id: "*pollen_report*"
      options:
        type: custom:mushroom-template-card
        primary: "{{ state_attr(config.entity, 'poll_title') }}"
        secondary: "{{ states(config.entity) }}"
        icon: mdi:flower-pollen-outline
        tap_action: none
        icon_color: |
          {% set contamination = state_attr(config.entity, 'contamination_2') %}
          {% if contamination == 4 %}
            red
          {% elif contamination == 3 %}
            orange
          {% elif contamination in [2, 1] %}
            yellow
          {% else %}
            default
          {% endif %}
  exclude:
    - state: unknown
    - state: Keine
    - entity_id: sensor.pollen_report_hourly_klagenfurt
    - entity_id: sensor.pollen_report_dayrisk_klagenfurt
sort:
  method: attribute
  attribute: contamination_2
  reverse: true

Hello Flo

that was exactly what I meant. Thank you for being able to implement it so quickly.

I have implemented your code and get a value for Dayrisk with your coordinates. However, if I set the coordinates to my home town (also the nearest large city - Graz) I get the, actually invalid, value 5 back.

The individual pollen values are read out correctly with my coordinates.

Do you have any idea why this could be?

Thanks again for the quick implementation
Markus

sure you put in the correct URL?

if I put this into the url instead of mine for Klagenfurt

https://www.polleninformation.at/index.php?eID=appinterface&pure_json=1&lang_code=de&lang_id=0&action=getFullContaminationData&type=gps&value[latitude]=47.073&value[longitude]=15.400&country_id=1&personal_contamination=false&sensitivity=0&country=AT&sessionid=

it produces valid data for Graz …

PS: I’m not sure if this is even available for each and every city. I guess it’s maybe just for capitals?

I dunno

Cheers

Yes, the individual pollen seem to provide valid data.

The Dayrisk value is somewhat peculiar. Perhaps it is not rated from 0-4 as on the homepage, but goes up to 10.
In the forcast for Graz I see values up to 9.

I think I will simply adapt your code accordingly.

Thanks also for the rest of the new code. Let’s see how I can process it further :smiley:

Thanks
Markus

Made some modifications to the card so it will display the names without the Latin names, show them in a 4x1 grid and sort them by highest. Also excluded everything “Niedrig” and “Keine” and changed the tap action.

type: custom:auto-entities
card:
  square: false
  type: grid
  columns: 4
card_param: cards
filter:
  include:
    - entity_id: "*pollen_report*"
      options:
        type: custom:mushroom-template-card
        primary: "{{ state_attr(config.entity, 'poll_title').split('(')[0] | trim }}"
        icon: mdi:flower-pollen-outline
        tap_action:
          action: more-info
        icon_color: |
          {% set contamination = state_attr(config.entity, 'contamination_2') %}
          {% if contamination == 4 %}
            red
          {% elif contamination == 3 %}
            orange
          {% elif contamination == 2 %}
            yellow
          {% elif contamination == 1 %}
            default
          {% else %}
            default
          {% endif %}  
  exclude:
    - state: Keine
    - state: unknown
    - state: Niedrig
show_empty: false
sort:
  method: attribute
  attribute: contamination_2
  reverse: true

so i just wanted to post here because im also from Graz. I created sensors following way. It works really good

configuration.yaml

sensor:
  - platform: rest
    name: Pollen Raw Data
    resource: https://www.polleninformation.at/index.php?eID=appinterface&pure_json=1&lang_code=de&lang_id=0&action=getFullContaminationData&type=gps&value[latitude]=46.628&value[longitude]=14.309&country_id=1&personal_contamination=false&sensitivity=0&country=AT&sessionid=
    scan_interval: 10800 # every 3 hours
    value_template: "{{ value_json.success }}"
    json_attributes_path: "$.result"
    json_attributes:
      - contamination
template:
  - sensor:
      - name: "Pollen Birke"
        state: >-
          {% set levels = ["keine Belastung", "gering", "mäßig", "hoch", "sehr hoch"] %}
          {% set p = state_attr('sensor.pollen_raw_data', 'contamination') | selectattr('poll_title', 'search', 'Birke') | list | first %}
          {{ levels[p.contamination_1 | int] if p is defined else 'unavailable' }}
        attributes:
          raw_value: >-
            {% set p = state_attr('sensor.pollen_raw_data', 'contamination') | selectattr('poll_title', 'search', 'Birke') | list | first %}
            {{ p.contamination_1 if p is defined else 'unknown' }}
          title: "Birke"

      - name: "Pollen Esche"
        state: >-
          {% set levels = ["keine Belastung", "gering", "mäßig", "hoch", "sehr hoch"] %}
          {% set p = state_attr('sensor.pollen_raw_data', 'contamination') | selectattr('poll_title', 'search', 'Esche') | list | first %}
          {{ levels[p.contamination_1 | int] if p is defined else 'unavailable' }}
        attributes:
          raw_value: >-
            {% set p = state_attr('sensor.pollen_raw_data', 'contamination') | selectattr('poll_title', 'search', 'Esche') | list | first %}
            {{ p.contamination_1 if p is defined else 'unknown' }}
          title: "Esche"

      - name: "Pollen Zypressen"
        state: >-
          {% set levels = ["keine Belastung", "gering", "mäßig", "hoch", "sehr hoch"] %}
          {% set p = state_attr('sensor.pollen_raw_data', 'contamination') | selectattr('poll_title', 'search', 'Zypressen') | list | first %}
          {{ levels[p.contamination_1 | int] if p is defined else 'unavailable' }}
        attributes:
          raw_value: >-
            {% set p = state_attr('sensor.pollen_raw_data', 'contamination') | selectattr('poll_title', 'search', 'Zypressen') | list | first %}
            {{ p.contamination_1 if p is defined else 'unknown' }}
          title: "Zypressen"

      - name: "Pollen Erle"
        state: >-
          {% set levels = ["keine Belastung", "gering", "mäßig", "hoch", "sehr hoch"] %}
          {% set p = state_attr('sensor.pollen_raw_data', 'contamination') | selectattr('poll_title', 'search', 'Erle') | list | first %}
          {{ levels[p.contamination_1 | int] if p is defined else 'unavailable' }}
        attributes:
          raw_value: >-
            {% set p = state_attr('sensor.pollen_raw_data', 'contamination') | selectattr('poll_title', 'search', 'Erle') | list | first %}
            {{ p.contamination_1 if p is defined else 'unknown' }}
          title: "Erle"

      - name: "Pollen Hasel"
        state: >-
          {% set levels = ["keine Belastung", "gering", "mäßig", "hoch", "sehr hoch"] %}
          {% set p = state_attr('sensor.pollen_raw_data', 'contamination') | selectattr('poll_title', 'search', 'Hasel') | list | first %}
          {{ levels[p.contamination_1 | int] if p is defined else 'unavailable' }}
        attributes:
          raw_value: >-
            {% set p = state_attr('sensor.pollen_raw_data', 'contamination') | selectattr('poll_title', 'search', 'Hasel') | list | first %}
            {{ p.contamination_1 if p is defined else 'unknown' }}
          title: "Hasel"

      - name: "Pollen Platane"
        state: >-
          {% set levels = ["keine Belastung", "gering", "mäßig", "hoch", "sehr hoch"] %}
          {% set p = state_attr('sensor.pollen_raw_data', 'contamination') | selectattr('poll_title', 'search', 'Platane') | list | first %}
          {{ levels[p.contamination_1 | int] if p is defined else 'unavailable' }}
        attributes:
          raw_value: >-
            {% set p = state_attr('sensor.pollen_raw_data', 'contamination') | selectattr('poll_title', 'search', 'Platane') | list | first %}
            {{ p.contamination_1 if p is defined else 'unknown' }}
          title: "Platane"

      - name: "Pollen Gräser"
        state: >-
          {% set levels = ["keine Belastung", "gering", "mäßig", "hoch", "sehr hoch"] %}
          {% set p = state_attr('sensor.pollen_raw_data', 'contamination') | selectattr('poll_title', 'search', 'Grä') | list | first %}
          {{ levels[p.contamination_1 | int] if p is defined else 'unavailable' }}
        attributes:
          raw_value: >-
            {% set p = state_attr('sensor.pollen_raw_data', 'contamination') | selectattr('poll_title', 'search', 'Grä') | list | first %}
            {{ p.contamination_1 if p is defined else 'unknown' }}
          title: "Gräser"

      - name: "Pollen Roggen"
        state: >-
          {% set levels = ["keine Belastung", "gering", "mäßig", "hoch", "sehr hoch"] %}
          {% set p = state_attr('sensor.pollen_raw_data', 'contamination') | selectattr('poll_title', 'search', 'Roggen') | list | first %}
          {{ levels[p.contamination_1 | int] if p is defined else 'unavailable' }}
        attributes:
          raw_value: >-
            {% set p = state_attr('sensor.pollen_raw_data', 'contamination') | selectattr('poll_title', 'search', 'Roggen') | list | first %}
            {{ p.contamination_1 if p is defined else 'unknown' }}
          title: "Roggen"

      - name: "Pollen Urticaceae"
        state: >-
          {% set levels = ["keine Belastung", "gering", "mäßig", "hoch", "sehr hoch"] %}
          {% set p = state_attr('sensor.pollen_raw_data', 'contamination') | selectattr('poll_title', 'search', 'Urticaceae') | list | first %}
          {{ levels[p.contamination_1 | int] if p is defined else 'unavailable' }}
        attributes:
          raw_value: >-
            {% set p = state_attr('sensor.pollen_raw_data', 'contamination') | selectattr('poll_title', 'search', 'Urticaceae') | list | first %}
            {{ p.contamination_1 if p is defined else 'unknown' }}
          title: "Nessel- und Glaskraut"

      - name: "Pollen Ölbaum"
        state: >-
          {% set levels = ["keine Belastung", "gering", "mäßig", "hoch", "sehr hoch"] %}
          {% set p = state_attr('sensor.pollen_raw_data', 'contamination') | selectattr('poll_title', 'search', 'Ölbaum') | list | first %}
          {{ levels[p.contamination_1 | int] if p is defined else 'unavailable' }}
        attributes:
          raw_value: >-
            {% set p = state_attr('sensor.pollen_raw_data', 'contamination') | selectattr('poll_title', 'search', 'Ölbaum') | list | first %}
            {{ p.contamination_1 if p is defined else 'unknown' }}
          title: "Ölbaum"

      - name: "Pollen Beifuß"
        state: >-
          {% set levels = ["keine Belastung", "gering", "mäßig", "hoch", "sehr hoch"] %}
          {% set p = state_attr('sensor.pollen_raw_data', 'contamination') | selectattr('poll_title', 'search', 'Beifu') | list | first %}
          {{ levels[p.contamination_1 | int] if p is defined else 'unavailable' }}
        attributes:
          raw_value: >-
            {% set p = state_attr('sensor.pollen_raw_data', 'contamination') | selectattr('poll_title', 'search', 'Beifu') | list | first %}
            {{ p.contamination_1 if p is defined else 'unknown' }}
          title: "Beifuß"

      - name: "Pollen Ragweed"
        state: >-
          {% set levels = ["keine Belastung", "gering", "mäßig", "hoch", "sehr hoch"] %}
          {% set p = state_attr('sensor.pollen_raw_data', 'contamination') | selectattr('poll_title', 'search', 'Ragweed') | list | first %}
          {{ levels[p.contamination_1 | int] if p is defined else 'unavailable' }}
        attributes:
          raw_value: >-
            {% set p = state_attr('sensor.pollen_raw_data', 'contamination') | selectattr('poll_title', 'search', 'Ragweed') | list | first %}
            {{ p.contamination_1 if p is defined else 'unknown' }}
          title: "Ragweed"

      - name: "Pollen Pilzsporen"
        state: >-
          {% set levels = ["keine Belastung", "gering", "mäßig", "hoch", "sehr hoch"] %}
          {% set p = state_attr('sensor.pollen_raw_data', 'contamination') | selectattr('poll_title', 'search', 'Pilzsporen') | list | first %}
          {{ levels[p.contamination_1 | int] if p is defined else 'unavailable' }}
        attributes:
          raw_value: >-
            {% set p = state_attr('sensor.pollen_raw_data', 'contamination') | selectattr('poll_title', 'search', 'Pilzsporen') | list | first %}
            {{ p.contamination_1 if p is defined else 'unknown' }}
          title: "Pilzsporen"

Wich creates me Sensors :wink: for the Lovelace I use following code

type: vertical-stack
cards:
  - type: horizontal-stack
    cards:
      - type: custom:mushroom-template-card
        entity: sensor.pollen_birke
        primary: Birke
        icon: mdi:leaf
        icon_color: >
          {% set state = states('sensor.pollen_birke') %} {% if state == 'sehr
          hoch' %}
            red
          {% elif state == 'hoch' %}
            deep-orange
          {% elif state == 'mäßig' %}
            amber
          {% elif state == 'gering' %}
            orange
          {% else %}
            green
          {% endif %}
      - type: custom:mushroom-template-card
        entity: sensor.pollen_esche
        primary: Esche
        icon: mdi:pine-tree
        icon_color: >
          {% set state = states('sensor.pollen_esche') %} {% if state == 'sehr
          hoch' %}
            red
          {% elif state == 'hoch' %}
            deep-orange
          {% elif state == 'mäßig' %}
            amber
          {% elif state == 'gering' %}
            orange
          {% else %}
            green
          {% endif %}
      - type: custom:mushroom-template-card
        entity: sensor.pollen_zypressen
        primary: Zypressen
        icon: mdi:flower
        icon_color: >
          {% set state = states('sensor.pollen_zypressen') %} {% if state ==
          'sehr hoch' %}
            red
          {% elif state == 'hoch' %}
            deep-orange
          {% elif state == 'mäßig' %}
            amber
          {% elif state == 'gering' %}
            orange
          {% else %}
            green
          {% endif %}
      - type: custom:mushroom-template-card
        entity: sensor.pollen_erle
        primary: Erle
        icon: mdi:pine-tree
        icon_color: >
          {% set state = states('sensor.pollen_erle') %} {% if state == 'sehr
          hoch' %}
            red
          {% elif state == 'hoch' %}
            deep-orange
          {% elif state == 'mäßig' %}
            amber
          {% elif state == 'gering' %}
            orange
          {% else %}
            green
          {% endif %}
  - type: horizontal-stack
    cards:
      - type: custom:mushroom-template-card
        entity: sensor.pollen_hasel
        primary: Hasel
        icon: mdi:leaf-maple
        icon_color: >
          {% set state = states('sensor.pollen_hasel') %} {% if state == 'sehr
          hoch' %}
            red
          {% elif state == 'hoch' %}
            deep-orange
          {% elif state == 'mäßig' %}
            amber
          {% elif state == 'gering' %}
            orange
          {% else %}
            green
          {% endif %}
      - type: custom:mushroom-template-card
        entity: sensor.pollen_platane
        primary: Platane
        icon: mdi:leaf-maple
        icon_color: >
          {% set state = states('sensor.pollen_platane') %} {% if state == 'sehr
          hoch' %}
            red
          {% elif state == 'hoch' %}
            deep-orange
          {% elif state == 'mäßig' %}
            amber
          {% elif state == 'gering' %}
            orange
          {% else %}
            green
          {% endif %}
      - type: custom:mushroom-template-card
        entity: sensor.pollen_graeser
        primary: Gräser
        icon: mdi:leaf-circle
        icon_color: >
          {% set state = states('sensor.pollen_graeser') %} {% if state == 'sehr
          hoch' %}
            red
          {% elif state == 'hoch' %}
            deep-orange
          {% elif state == 'mäßig' %}
            amber
          {% elif state == 'gering' %}
            orange
          {% else %}
            green
          {% endif %}
      - type: custom:mushroom-template-card
        entity: sensor.pollen_roggen
        primary: Roggen
        icon: mdi:tree-outline
        icon_color: >
          {% set state = states('sensor.pollen_roggen') %} {% if state == 'sehr
          hoch' %}
            red
          {% elif state == 'hoch' %}
            deep-orange
          {% elif state == 'mäßig' %}
            amber
          {% elif state == 'gering' %}
            orange
          {% else %}
            green
          {% endif %}
  - type: horizontal-stack
    cards:
      - type: custom:mushroom-template-card
        entity: sensor.pollen_urticaceae
        primary: Urticaceae
        icon: mdi:tree
        icon_color: >
          {% set state = states('sensor.pollen_urticaceae') %} {% if state ==
          'sehr hoch' %}
            red
          {% elif state == 'hoch' %}
            deep-orange
          {% elif state == 'mäßig' %}
            amber
          {% elif state == 'gering' %}
            orange
          {% else %}
            green
          {% endif %}
      - type: custom:mushroom-template-card
        entity: sensor.pollen_oelbaum
        primary: Ölbaum
        icon: mdi:flower-tulip
        icon_color: >
          {% set state = states('sensor.pollen_oelbaum') %} {% if state == 'sehr
          hoch' %}
            red
          {% elif state == 'hoch' %}
            deep-orange
          {% elif state == 'mäßig' %}
            amber
          {% elif state == 'gering' %}
            orange
          {% else %}
            green
          {% endif %}
      - type: custom:mushroom-template-card
        entity: sensor.pollen_beifuss
        primary: Beifuß
        icon: mdi:leaf
        icon_color: >
          {% set state = states('sensor.pollen_beifuss') %} {% if state == 'sehr
          hoch' %}
            red
          {% elif state == 'hoch' %}
            deep-orange
          {% elif state == 'mäßig' %}
            amber
          {% elif state == 'gering' %}
            orange
          {% else %}
            green
          {% endif %}
      - type: custom:mushroom-template-card
        entity: sensor.pollen_ragweed
        primary: Ragweed
        icon: mdi:leaf-maple
        icon_color: >
          {% set state = states('sensor.pollen_ragweed') %} {% if state == 'sehr
          hoch' %}
            red
          {% elif state == 'hoch' %}
            deep-orange
          {% elif state == 'mäßig' %}
            amber
          {% elif state == 'gering' %}
            orange
          {% else %}
            green
          {% endif %}
  - type: horizontal-stack
    cards:
      - type: custom:mushroom-template-card
        entity: sensor.pollen_pilzsporen
        primary: Pilzsporen
        icon: mdi:mushroom
        icon_color: >
          {% set state = states('sensor.pollen_pilzsporen') %} {% if state ==
          'sehr hoch' %}
            red
          {% elif state == 'hoch' %}
            deep-orange
          {% elif state == 'mäßig' %}
            amber
          {% elif state == 'gering' %}
            orange
          {% else %}
            green
          {% endif %}
title: Allergies

Hi Ejmi!

Wow, I have to say, your improvement is absolutely amazing! :star2: Your idea of using a single REST sensor to fetch all values is such a game-changer—especially during Home Assistant startup! It’s so much cleaner and more efficient than having tons of individual sensors pulling data. I can’t thank you enough for sharing this approach.

The polling interval of 10800 seconds (every 3 hours) is also spot on. Since the calculations are only needed at a daily granularity, this is more than sufficient. It’s such a simple yet effective solution!

I was so impressed that I’ve adopted this into my own smart home setup! :blush: The only tweak I made—just a personal preference—was using helper entities instead of YAML for the template sensors. (EDIT: and reverted it immediately to YAML since I was not able to template attributes with the Helpers :wink: )

You’ve really elevated my original idea to the next level. Thanks for taking the time to refine and share your expertise! I’m sure this will help not only me but many others in the community as well. :blush:

Keep up the awesome work! :rocket:

Not sure if anyone needs this, but I’ve adjusted it to display only the allergies with a value other than “keine Belastung”

type: vertical-stack
cards:
  - type: horizontal-stack
    cards:
      - type: custom:mushroom-template-card
        entity: sensor.pollen_birke
        primary: Birke
        icon: mdi:leaf
        icon_color: >
          {% set state = states('sensor.pollen_birke') %} {% if state == 'sehr
          hoch' %}
            red
          {% elif state == 'hoch' %}
            deep-orange
          {% elif state == 'mäßig' %}
            amber
          {% elif state == 'gering' %}
            orange
          {% else %}
            green
          {% endif %}
        visibility:
          - condition: state
            entity: sensor.pollen_birke
            state_not: keine Belastung
        tap_action:
          action: more-info
        secondary: "{{ states('sensor.pollen_birke')}}"
      - type: custom:mushroom-template-card
        entity: sensor.pollen_esche
        primary: Esche
        icon: mdi:pine-tree
        icon_color: >
          {% set state = states('sensor.pollen_esche') %} {% if state == 'sehr
          hoch' %}
            red
          {% elif state == 'hoch' %}
            deep-orange
          {% elif state == 'mäßig' %}
            amber
          {% elif state == 'gering' %}
            orange
          {% else %}
            green
          {% endif %}
        visibility:
          - condition: state
            entity: sensor.pollen_esche
            state_not: keine Belastung
        tap_action:
          action: more-info
        secondary: "{{ states('sensor.pollen_esche')}}"
      - type: custom:mushroom-template-card
        entity: sensor.pollen_zypressen
        primary: Zypresse
        icon: mdi:flower
        icon_color: >
          {% set state = states('sensor.pollen_zypressen') %} {% if state ==
          'sehr hoch' %}
            red
          {% elif state == 'hoch' %}
            deep-orange
          {% elif state == 'mäßig' %}
            amber
          {% elif state == 'gering' %}
            orange
          {% else %}
            green
          {% endif %}
        visibility:
          - condition: state
            entity: sensor.pollen_zypressen
            state_not: keine Belastung
        tap_action:
          action: more-info
        secondary: "{{ states('sensor.pollen_zypressen')}}"
      - type: custom:mushroom-template-card
        entity: sensor.pollen_erle
        primary: Erle
        icon: mdi:pine-tree
        icon_color: >
          {% set state = states('sensor.pollen_erle') %} {% if state == 'sehr
          hoch' %}
            red
          {% elif state == 'hoch' %}
            deep-orange
          {% elif state == 'mäßig' %}
            amber
          {% elif state == 'gering' %}
            orange
          {% else %}
            green
          {% endif %}
        visibility:
          - condition: state
            entity: sensor.pollen_erle
            state_not: keine Belastung
        tap_action:
          action: more-info
        secondary: "{{ states('sensor.pollen_erle')}}"
  - type: horizontal-stack
    cards:
      - type: custom:mushroom-template-card
        entity: sensor.pollen_hasel
        primary: Hasel
        icon: mdi:leaf-maple
        icon_color: >
          {% set state = states('sensor.pollen_hasel') %} {% if state == 'sehr
          hoch' %}
            red
          {% elif state == 'hoch' %}
            deep-orange
          {% elif state == 'mäßig' %}
            amber
          {% elif state == 'gering' %}
            orange
          {% else %}
            green
          {% endif %}
        visibility:
          - condition: state
            entity: sensor.pollen_hasel
            state_not: keine Belastung
        tap_action:
          action: more-info
        secondary: "{{ states('sensor.pollen_hasel')}}"
      - type: custom:mushroom-template-card
        entity: sensor.pollen_platane
        primary: Platane
        icon: mdi:leaf-maple
        icon_color: >
          {% set state = states('sensor.pollen_platane') %} {% if state == 'sehr
          hoch' %}
            red
          {% elif state == 'hoch' %}
            deep-orange
          {% elif state == 'mäßig' %}
            amber
          {% elif state == 'gering' %}
            orange
          {% else %}
            green
          {% endif %}
        visibility:
          - condition: state
            entity: sensor.pollen_platane
            state_not: keine Belastung
        tap_action:
          action: more-info
        secondary: "{{ states('sensor.pollen_platane')}}"
      - type: custom:mushroom-template-card
        entity: sensor.pollen_graeser
        primary: Gräser
        icon: mdi:leaf-circle
        icon_color: >
          {% set state = states('sensor.pollen_graeser') %} {% if state == 'sehr
          hoch' %}
            red
          {% elif state == 'hoch' %}
            deep-orange
          {% elif state == 'mäßig' %}
            amber
          {% elif state == 'gering' %}
            orange
          {% else %}
            green
          {% endif %}
        visibility:
          - condition: state
            entity: sensor.pollen_graeser
            state_not: keine Belastung
        tap_action:
          action: more-info
        secondary: "{{ states('sensor.pollen_graeser')}}"
      - type: custom:mushroom-template-card
        entity: sensor.pollen_roggen
        primary: Roggen
        icon: mdi:tree-outline
        icon_color: >
          {% set state = states('sensor.pollen_roggen') %} {% if state == 'sehr
          hoch' %}
            red
          {% elif state == 'hoch' %}
            deep-orange
          {% elif state == 'mäßig' %}
            amber
          {% elif state == 'gering' %}
            orange
          {% else %}
            green
          {% endif %}
        visibility:
          - condition: state
            entity: sensor.pollen_roggen
            state_not: keine Belastung
        tap_action:
          action: more-info
        secondary: "{{ states('sensor.pollen_roggen')}}"
  - type: horizontal-stack
    cards:
      - type: custom:mushroom-template-card
        entity: sensor.pollen_urticaceae
        primary: Urticaceae
        icon: mdi:tree
        icon_color: >
          {% set state = states('sensor.pollen_urticaceae') %} {% if state ==
          'sehr hoch' %}
            red
          {% elif state == 'hoch' %}
            deep-orange
          {% elif state == 'mäßig' %}
            amber
          {% elif state == 'gering' %}
            orange
          {% else %}
            green
          {% endif %}
        visibility:
          - condition: state
            entity: sensor.pollen_urticaceae
            state_not: keine Belastung
        tap_action:
          action: more-info
        secondary: "{{ states('sensor.pollen_urticaceae')}}"
      - type: custom:mushroom-template-card
        entity: sensor.pollen_oelbaum
        primary: Ölbaum
        icon: mdi:flower-tulip
        icon_color: >
          {% set state = states('sensor.pollen_oelbaum') %} {% if state == 'sehr
          hoch' %}
            red
          {% elif state == 'hoch' %}
            deep-orange
          {% elif state == 'mäßig' %}
            amber
          {% elif state == 'gering' %}
            orange
          {% else %}
            green
          {% endif %}
        visibility:
          - condition: state
            entity: sensor.pollen_oelbaum
            state_not: keine Belastung
        tap_action:
          action: more-info
        secondary: "{{ states('sensor.pollen_oelbaum')}}"
      - type: custom:mushroom-template-card
        entity: sensor.pollen_beifuss
        primary: Beifuß
        icon: mdi:leaf
        icon_color: >
          {% set state = states('sensor.pollen_beifuss') %} {% if state == 'sehr
          hoch' %}
            red
          {% elif state == 'hoch' %}
            deep-orange
          {% elif state == 'mäßig' %}
            amber
          {% elif state == 'gering' %}
            orange
          {% else %}
            green
          {% endif %}
        visibility:
          - condition: state
            entity: sensor.pollen_beifuss
            state_not: keine Belastung
        tap_action:
          action: more-info
        secondary: "{{ states('sensor.pollen_beifuss')}}"
      - type: custom:mushroom-template-card
        entity: sensor.pollen_ragweed
        primary: Ragweed
        icon: mdi:leaf-maple
        icon_color: >
          {% set state = states('sensor.pollen_ragweed') %} {% if state == 'sehr
          hoch' %}
            red
          {% elif state == 'hoch' %}
            deep-orange
          {% elif state == 'mäßig' %}
            amber
          {% elif state == 'gering' %}
            orange
          {% else %}
            green
          {% endif %}
        visibility:
          - condition: state
            entity: sensor.pollen_ragweed
            state_not: keine Belastung
        tap_action:
          action: more-info
        secondary: "{{ states('sensor.pollen_ragweed')}}"
  - type: horizontal-stack
    cards:
      - type: custom:mushroom-template-card
        entity: sensor.pollen_pilzsporen
        primary: Pilzsporen
        icon: mdi:mushroom
        icon_color: >
          {% set state = states('sensor.pollen_pilzsporen') %} {% if state ==
          'sehr hoch' %}
            red
          {% elif state == 'hoch' %}
            deep-orange
          {% elif state == 'mäßig' %}
            amber
          {% elif state == 'gering' %}
            orange
          {% else %}
            green
          {% endif %}
        visibility:
          - condition: state
            entity: sensor.pollen_pilzsporen
            state_not: keine Belastung
        tap_action:
          action: more-info
        secondary: "{{ states('sensor.pollen_pilzsporen')}}"

would show only allergies which have current contamination like so

      - name: "Pollen Gräser"
        state: >-
          {% set levels = ["keine Belastung", "gering", "mäßig", "hoch", "sehr hoch"] %}
          {% set p = state_attr('sensor.pollen_raw_data', 'contamination') | selectattr('poll_title', 'search', 'Grä') | list | first %}
          {{ levels[p.contamination_1 | int] if p is defined else 'unavailable' }}
        attributes:
          raw_value: >-
            {% set p = state_attr('sensor.pollen_raw_data', 'contamination') | selectattr('poll_title', 'search', 'Grä') | list | first %}
            {{ p.contamination_1 if p is defined else 'unknown' }}
          title: "Gräser"

the search for Grä and Ölbaum doesn’t work for me.
both attributes are going to send back the state unknown.
my try to search for lbaum or Gr doesn’t work. The Link for Graz is also responding unkown on both attributes.

best regards

Looks great – thanks for sharing! :clap:

I’ve built something similar, but with a slightly different approach:
Instead of defining sensors via sensors.yaml, I use Node-RED to fetch the pollen data from polleninformation.at every 3 hours, and then push everything into Home Assistant via MQTT Discovery.

That way, I can assign all the sensors to a dedicated device (which I usually do for external data sources), and keep Home Assistant itself clean – no scraping or logic inside HA, just pure MQTT sensors that appear automatically.

For external scraping tasks like this, Node-RED has worked really well for me – it’s flexible, easy to debug, and keeps the core HA config lightweight.

If you’re curious, I’ve shared my version here (including a screenshot and flow):
:point_right: GitHub - mmick08/node-red-pollen-api: 🏡📊 Automatisierte Pollenbelastung für Home Assistant via Node-RED und polleninformation.at – inkl. MQTT Discovery und Standortvariablen

1 Like

The Sensors have valid data, the problem seems to be that there is “oelbaum” instead of “olbaum” and “graeser” instead of “graser” will be used in the card.

Here is the adapted and working version:

type: vertical-stack
cards:
  - type: horizontal-stack
    cards:
      - type: custom:mushroom-template-card
        entity: sensor.pollen_birke
        primary: Birke
        icon: mdi:leaf
        icon_color: >
          {% set state = states('sensor.pollen_birke') %} {% if state == 'sehr
          hoch' %}
            red
          {% elif state == 'hoch' %}
            deep-orange
          {% elif state == 'mäßig' %}
            amber
          {% elif state == 'gering' %}
            orange
          {% else %}
            green
          {% endif %}
        visibility:
          - condition: state
            entity: sensor.pollen_birke
            state_not: keine Belastung
        tap_action:
          action: more-info
        secondary: "{{ states('sensor.pollen_birke')}}"
      - type: custom:mushroom-template-card
        entity: sensor.pollen_esche
        primary: Esche
        icon: mdi:pine-tree
        icon_color: >
          {% set state = states('sensor.pollen_esche') %} {% if state == 'sehr
          hoch' %}
            red
          {% elif state == 'hoch' %}
            deep-orange
          {% elif state == 'mäßig' %}
            amber
          {% elif state == 'gering' %}
            orange
          {% else %}
            green
          {% endif %}
        visibility:
          - condition: state
            entity: sensor.pollen_esche
            state_not: keine Belastung
        tap_action:
          action: more-info
        secondary: "{{ states('sensor.pollen_esche')}}"
      - type: custom:mushroom-template-card
        entity: sensor.pollen_zypressen
        primary: Zypresse
        icon: mdi:flower
        icon_color: >
          {% set state = states('sensor.pollen_zypressen') %} {% if state ==
          'sehr hoch' %}
            red
          {% elif state == 'hoch' %}
            deep-orange
          {% elif state == 'mäßig' %}
            amber
          {% elif state == 'gering' %}
            orange
          {% else %}
            green
          {% endif %}
        visibility:
          - condition: state
            entity: sensor.pollen_zypressen
            state_not: keine Belastung
        tap_action:
          action: more-info
        secondary: "{{ states('sensor.pollen_zypressen')}}"
      - type: custom:mushroom-template-card
        entity: sensor.pollen_erle
        primary: Erle
        icon: mdi:pine-tree
        icon_color: >
          {% set state = states('sensor.pollen_erle') %} {% if state == 'sehr
          hoch' %}
            red
          {% elif state == 'hoch' %}
            deep-orange
          {% elif state == 'mäßig' %}
            amber
          {% elif state == 'gering' %}
            orange
          {% else %}
            green
          {% endif %}
        visibility:
          - condition: state
            entity: sensor.pollen_erle
            state_not: keine Belastung
        tap_action:
          action: more-info
        secondary: "{{ states('sensor.pollen_erle')}}"
  - type: horizontal-stack
    cards:
      - type: custom:mushroom-template-card
        entity: sensor.pollen_hasel
        primary: Hasel
        icon: mdi:leaf-maple
        icon_color: >
          {% set state = states('sensor.pollen_hasel') %} {% if state == 'sehr
          hoch' %}
            red
          {% elif state == 'hoch' %}
            deep-orange
          {% elif state == 'mäßig' %}
            amber
          {% elif state == 'gering' %}
            orange
          {% else %}
            green
          {% endif %}
        visibility:
          - condition: state
            entity: sensor.pollen_hasel
            state_not: keine Belastung
        tap_action:
          action: more-info
        secondary: "{{ states('sensor.pollen_hasel')}}"
      - type: custom:mushroom-template-card
        entity: sensor.pollen_platane
        primary: Platane
        icon: mdi:leaf-maple
        icon_color: >
          {% set state = states('sensor.pollen_platane') %} {% if state == 'sehr
          hoch' %}
            red
          {% elif state == 'hoch' %}
            deep-orange
          {% elif state == 'mäßig' %}
            amber
          {% elif state == 'gering' %}
            orange
          {% else %}
            green
          {% endif %}
        visibility:
          - condition: state
            entity: sensor.pollen_platane
            state_not: keine Belastung
        tap_action:
          action: more-info
        secondary: "{{ states('sensor.pollen_platane')}}"
      - type: custom:mushroom-template-card
        entity: sensor.pollen_graser
        primary: Gräser
        icon: mdi:leaf-circle
        icon_color: >
          {% set state = states('sensor.pollen_graser') %} {% if state == 'sehr
          hoch' %}
            red
          {% elif state == 'hoch' %}
            deep-orange
          {% elif state == 'mäßig' %}
            amber
          {% elif state == 'gering' %}
            orange
          {% else %}
            green
          {% endif %}
        visibility:
          - condition: state
            entity: sensor.pollen_graser
            state_not: keine Belastung
        tap_action:
          action: more-info
        secondary: "{{ states('sensor.pollen_graser')}}"
      - type: custom:mushroom-template-card
        entity: sensor.pollen_roggen
        primary: Roggen
        icon: mdi:tree-outline
        icon_color: >
          {% set state = states('sensor.pollen_roggen') %} {% if state == 'sehr
          hoch' %}
            red
          {% elif state == 'hoch' %}
            deep-orange
          {% elif state == 'mäßig' %}
            amber
          {% elif state == 'gering' %}
            orange
          {% else %}
            green
          {% endif %}
        visibility:
          - condition: state
            entity: sensor.pollen_roggen
            state_not: keine Belastung
        tap_action:
          action: more-info
        secondary: "{{ states('sensor.pollen_roggen')}}"
  - type: horizontal-stack
    cards:
      - type: custom:mushroom-template-card
        entity: sensor.pollen_urticaceae
        primary: Urticaceae
        icon: mdi:tree
        icon_color: >
          {% set state = states('sensor.pollen_urticaceae') %} {% if state ==
          'sehr hoch' %}
            red
          {% elif state == 'hoch' %}
            deep-orange
          {% elif state == 'mäßig' %}
            amber
          {% elif state == 'gering' %}
            orange
          {% else %}
            green
          {% endif %}
        visibility:
          - condition: state
            entity: sensor.pollen_urticaceae
            state_not: keine Belastung
        tap_action:
          action: more-info
        secondary: "{{ states('sensor.pollen_urticaceae')}}"
      - type: custom:mushroom-template-card
        entity: sensor.pollen_olbaum
        primary: Ölbaum
        icon: mdi:flower-tulip
        icon_color: >
          {% set state = states('sensor.pollen_olbaum') %} {% if state == 'sehr
          hoch' %}
            red
          {% elif state == 'hoch' %}
            deep-orange
          {% elif state == 'mäßig' %}
            amber
          {% elif state == 'gering' %}
            orange
          {% else %}
            green
          {% endif %}
        visibility:
          - condition: state
            entity: sensor.pollen_olbaum
            state_not: keine Belastung
        tap_action:
          action: more-info
        secondary: "{{ states('sensor.pollen_olbaum')}}"
      - type: custom:mushroom-template-card
        entity: sensor.pollen_beifuss
        primary: Beifuß
        icon: mdi:leaf
        icon_color: >
          {% set state = states('sensor.pollen_beifuss') %} {% if state == 'sehr
          hoch' %}
            red
          {% elif state == 'hoch' %}
            deep-orange
          {% elif state == 'mäßig' %}
            amber
          {% elif state == 'gering' %}
            orange
          {% else %}
            green
          {% endif %}
        visibility:
          - condition: state
            entity: sensor.pollen_beifuss
            state_not: keine Belastung
        tap_action:
          action: more-info
        secondary: "{{ states('sensor.pollen_beifuss')}}"
      - type: custom:mushroom-template-card
        entity: sensor.pollen_ragweed
        primary: Ragweed
        icon: mdi:leaf-maple
        icon_color: >
          {% set state = states('sensor.pollen_ragweed') %} {% if state == 'sehr
          hoch' %}
            red
          {% elif state == 'hoch' %}
            deep-orange
          {% elif state == 'mäßig' %}
            amber
          {% elif state == 'gering' %}
            orange
          {% else %}
            green
          {% endif %}
        visibility:
          - condition: state
            entity: sensor.pollen_ragweed
            state_not: keine Belastung
        tap_action:
          action: more-info
        secondary: "{{ states('sensor.pollen_ragweed')}}"
  - type: horizontal-stack
    cards:
      - type: custom:mushroom-template-card
        entity: sensor.pollen_pilzsporen
        primary: Pilzsporen
        icon: mdi:mushroom
        icon_color: >
          {% set state = states('sensor.pollen_pilzsporen') %} {% if state ==
          'sehr hoch' %}
            red
          {% elif state == 'hoch' %}
            deep-orange
          {% elif state == 'mäßig' %}
            amber
          {% elif state == 'gering' %}
            orange
          {% else %}
            green
          {% endif %}
        visibility:
          - condition: state
            entity: sensor.pollen_pilzsporen
            state_not: keine Belastung
        tap_action:
          action: more-info
        secondary: "{{ states('sensor.pollen_pilzsporen')}}"
1 Like

Thank you very much for all the work you’ve all put into this. It’s really helpful.