UK (and worldwide) Pollen Count using tomorrow.io API

I used the Tomorrow.io rest sensors for a while but found the Accuweather HA integration has pollen forecasts so I now use that.

I tried the Accuweather integration and couldn’t find the pollen forecasts you’re referring to. Did you do anything in particular when setting it up?

UPDATE: I restarted my instance and went back to the integraiton and there are a ton of entities created now…They appeared as I activated the Weather Forecast checkbox under Options of the integration. Prior to this I only had around 20 something entities.

Yes there are 109 entities, most of mine were disabled on install, I just use the pollen 0d and 1d forecasts (today and tomorrow)

1 Like

I use all of them in a collapsible card:

3 Likes

That looks awesome! Can you please share your code?

I’m using the Mushroom template card for the majority of it but there are a few other custom cards at play here - stack-in-card, layout-card, grid-layout, bar-card and card_mod:

type: custom:stack-in-card
cards:
  - type: custom:layout-card
    layout_type: custom:grid-layout
    layout:
      grid-template-columns: auto 33px
      margin: '-4px -4px -10px -4px;'
    cards:
      - type: grid
        columns: 3
        cards:
          - type: custom:mushroom-template-card
            primary: Grass pollen
            icon: mdi:grass
            layout: vertical
            entity: sensor.vimoutiers_grass_pollen_0d
            icon_color: |-
              {% if states(config.entity) | int <= 1 %} 
                green
              {% elif states(config.entity) | int <= 4 %}
                orange
              {% elif states(config.entity) | int <= 6 %}
                red
              {% endif %}
            secondary: >-
              Today: {{ state_attr('sensor.vimoutiers_grass_pollen_0d', 'level')
              }}

              Tomorrow: {{ state_attr('sensor.vimoutiers_grass_pollen_1d',
              'level') }}
            tap_action:
              action: more-info
            hold_action:
              action: none
            double_tap_action:
              action: none
            multiline_secondary: true
            card_mod:
              style: |
                ha-card {
                  background: none;
                  --ha-card-box-shadow: 0px;
                }
          - type: custom:mushroom-template-card
            primary: Tree pollen
            icon: mdi:tree
            layout: vertical
            entity: sensor.vimoutiers_tree_pollen_0d
            icon_color: |-
              {% if states(config.entity) | int <= 1 %} 
                green
              {% elif states(config.entity) | int <= 4 %}
                orange
              {% elif states(config.entity) | int <= 6 %}
                red
              {% endif %}
            secondary: >-
              Today: {{ state_attr('sensor.vimoutiers_tree_pollen_0d', 'level')
              }}

              Tomorrow: {{ state_attr('sensor.vimoutiers_tree_pollen_1d',
              'level') }}
            double_tap_action:
              action: none
            tap_action:
              action: more-info
            hold_action:
              action: none
            multiline_secondary: true
            card_mod:
              style: |
                ha-card {
                  background: none;
                  --ha-card-box-shadow: 0px;
                }
          - type: custom:mushroom-template-card
            primary: Weed pollen
            icon: mdi:spa
            layout: vertical
            entity: sensor.vimoutiers_ragweed_pollen_0d
            icon_color: |-
              {% if states(config.entity) | int <= 1 %} 
                green
              {% elif states(config.entity) | int <= 4 %}
                orange
              {% elif states(config.entity) | int <= 6 %}
                red
              {% endif %}
            secondary: >-
              Today: {{ state_attr('sensor.vimoutiers_ragweed_pollen_0d',
              'level') }}

              Tomorrow: {{ state_attr('sensor.vimoutiers_ragweed_pollen_1d',
              'level') }}
            double_tap_action:
              action: none
            tap_action:
              action: more-info
            hold_action:
              action: none
            multiline_secondary: true
            card_mod:
              style: |
                ha-card {
                  background: none;
                  --ha-card-box-shadow: 0px;
                }
      - type: custom:mushroom-template-card
        entity: input_boolean.adaptive_dropdown
        primary: ''
        secondary: ''
        icon: >-
          {{ 'mdi:chevron-up' if is_state(entity, 'on') else 'mdi:chevron-down'
          }}
        icon_color: disabled
        hold_action:
          action: none
        card_mod:
          style: |
            ha-card {
              align-items: flex-end;
              background: none;
              --ha-card-box-shadow: 0px;
            }
            mushroom-shape-icon {
              --shape-color: none !important;
            } 
  - type: conditional
    conditions:
      - entity: input_boolean.adaptive_dropdown
        state: 'on'
    card:
      type: vertical-stack
      cards:
        - type: custom:bar-card
          title: Grass pollen forecast
          direction: up
          columns: 5
          height: 50px
          width: 100%
          min: 0
          max: 5
          positions:
            icon: 'off'
            name: outside
            value: inside
          severity:
            - color: Green
              from: 0
              to: 1
            - color: Orange
              from: 2
              to: 4
            - color: Red
              from: 5
              to: 6
          animation:
            state: 'on'
            speed: 1
          entities:
            - entity: sensor.vimoutiers_grass_pollen_0d
              name: Today
            - entity: sensor.vimoutiers_grass_pollen_1d
              name: Today +1
            - entity: sensor.vimoutiers_grass_pollen_2d
              name: Today +2
            - entity: sensor.vimoutiers_grass_pollen_3d
              name: Today +3
            - entity: sensor.vimoutiers_grass_pollen_4d
              name: Today +4
          card_mod:
            style: |-
              .card-header {
                --ha-card-header-font-size: 20px;
              }
              bar-card-backgroundbar {
                background-color: transparent;
              }
              bar-card-name {
                font-size: 12px;
                font-weight: bolder;
                color: #727272;
              }
        - type: custom:bar-card
          title: Tree pollen forecast
          direction: up
          columns: 5
          height: 50px
          width: 100%
          min: 0
          max: 5
          positions:
            icon: 'off'
            name: outside
            value: inside
          severity:
            - color: Green
              from: 0
              to: 1
            - color: Orange
              from: 2
              to: 4
            - color: Red
              from: 5
              to: 6
          animation:
            state: 'on'
            speed: 1
          entities:
            - entity: sensor.vimoutiers_tree_pollen_0d
              name: Today
            - entity: sensor.vimoutiers_tree_pollen_1d
              name: Today +1
            - entity: sensor.vimoutiers_tree_pollen_2d
              name: Today +2
            - entity: sensor.vimoutiers_tree_pollen_3d
              name: Today +3
            - entity: sensor.vimoutiers_tree_pollen_4d
              name: Today +4
          card_mod:
            style: |-
              .card-header {
                --ha-card-header-font-size: 20px;
              }
              bar-card-backgroundbar {
                background-color: transparent;
              }
              bar-card-name {
                font-size: 12px;
                font-weight: bolder;
                color: #727272;
              }
        - type: custom:bar-card
          title: Weed pollen forecast
          direction: up
          columns: 5
          height: 50px
          width: 100%
          min: 0
          max: 5
          positions:
            icon: 'off'
            name: outside
            value: inside
          severity:
            - color: Green
              from: 0
              to: 1
            - color: Orange
              from: 2
              to: 4
            - color: Red
              from: 5
              to: 20
          animation:
            state: 'on'
            speed: 1
          entities:
            - entity: sensor.vimoutiers_ragweed_pollen_0d
              name: Today
            - entity: sensor.vimoutiers_ragweed_pollen_1d
              name: Today +1
            - entity: sensor.vimoutiers_ragweed_pollen_2d
              name: Today +2
            - entity: sensor.vimoutiers_ragweed_pollen_3d
              name: Today +3
            - entity: sensor.vimoutiers_ragweed_pollen_4d
              name: Today +4
          card_mod:
            style: |-
              .card-header {
                --ha-card-header-font-size: 20px;
              }
              bar-card-backgroundbar {
                background-color: transparent;
              }
              bar-card-name {
                font-size: 12px;
                font-weight: bolder;
                color: #727272;
              }

2 Likes

This is really good!

Do you know why the bar graphs and icon colours are messed up?

1 Like

I was reading the API documentation and they describe the thresholds between 0-6 - so I put the three colours across those ranges. It looks as though the range is much larger, so anything above 6 will show as blue. You will needto tweak the range’s associated with the colours…I haven’t quite figured it out myself.

1 Like
type: custom:stack-in-card
cards:
  - type: custom:layout-card
    layout_type: custom:grid-layout
    layout:
      grid-template-columns: auto 33px
      margin: '-4px -4px -10px -4px;'
    cards:
      - type: grid
        columns: 3
        cards:
          - type: custom:mushroom-template-card
            primary: Grass pollen
            icon: mdi:grass
            layout: vertical
            entity: sensor.home_grass_pollen_0d
            icon_color: |-
              {% if states(config.entity) | int <= 29 %} 
                green
              {% elif states(config.entity) | int <= 60 %}
                orange
              {% elif states(config.entity) | int > 60 %}
               red
              {% endif %}
            secondary: |-
              Today: {{ state_attr('sensor.home_grass_pollen_0d', 'level') }}
              Tomorrow: {{ state_attr('sensor.home_grass_pollen_1d', 'level') }}
            tap_action:
              action: more-info
            hold_action:
              action: none
            double_tap_action:
              action: none
            multiline_secondary: true
            card_mod:
              style: |
                ha-card {
                  background: none;
                  --ha-card-box-shadow: 0px;
                }
          - type: custom:mushroom-template-card
            primary: Tree pollen
            icon: mdi:tree
            layout: vertical
            entity: sensor.home_tree_pollen_0d
            icon_color: |-
              {% if states(config.entity) | int <= 95 %} 
                green
              {% elif states(config.entity) | int <= 207 %}
                orange
              {% elif states(config.entity) | int > 207 %}
                red
              {% endif %}
            secondary: |-
              Today: {{ state_attr('sensor.home_tree_pollen_0d', 'level') }}
              Tomorrow: {{ state_attr('sensor.home_tree_pollen_1d', 'level') }}
            double_tap_action:
              action: none
            tap_action:
              action: more-info
            hold_action:
              action: none
            multiline_secondary: true
            card_mod:
              style: |
                ha-card {
                  background: none;
                  --ha-card-box-shadow: 0px;
                }
          - type: custom:mushroom-template-card
            primary: Weed pollen
            icon: mdi:spa
            layout: vertical
            entity: sensor.home_ragweed_pollen_0d
            icon_color: |-
              {% if states(config.entity) | int <= 20 %} 
                green
              {% elif states(config.entity) | int <= 77 %}
                orange
              {% elif states(config.entity) | int > 77 %}
                red
              {% endif %}
            secondary: >-
              Today: {{ state_attr('sensor.home_ragweed_pollen_0d', 'level') }}

              Tomorrow: {{ state_attr('sensor.home_ragweed_pollen_1d', 'level')
              }}
            double_tap_action:
              action: none
            tap_action:
              action: more-info
            hold_action:
              action: none
            multiline_secondary: true
            card_mod:
              style: |
                ha-card {
                  background: none;
                  --ha-card-box-shadow: 0px;
                }
      - type: custom:mushroom-template-card
        entity: input_boolean.adaptive_dropdown
        primary: ''
        secondary: ''
        icon: >-
          {{ 'mdi:chevron-up' if is_state(entity, 'on') else 'mdi:chevron-down'
          }}
        icon_color: disabled
        hold_action:
          action: none
        card_mod:
          style: |
            ha-card {
              align-items: flex-end;
              background: none;
              --ha-card-box-shadow: 0px;
            }
            mushroom-shape-icon {
              --shape-color: none !important;
            } 
  - type: conditional
    conditions:
      - entity: input_boolean.adaptive_dropdown
        state: 'on'
    card:
      type: vertical-stack
      cards:
        - type: custom:bar-card
          title: Grass pollen forecast
          direction: up
          columns: 5
          height: 50px
          width: 100%
          min: 0
          max: 200
          positions:
            icon: 'off'
            name: outside
            value: inside
          severity:
            - color: Green
              from: 0
              to: 29
            - color: Orange
              from: 30
              to: 60
            - color: Red
              from: 61
              to: 999
          animation:
            state: 'on'
            speed: 1
          entities:
            - entity: sensor.home_grass_pollen_0d
              name: Today
            - entity: sensor.home_grass_pollen_1d
              name: Today +1
            - entity: sensor.home_grass_pollen_2d
              name: Today +2
            - entity: sensor.home_grass_pollen_3d
              name: Today +3
            - entity: sensor.home_grass_pollen_4d
              name: Today +4
          card_mod:
            style: |-
              .card-header {
                --ha-card-header-font-size: 20px;
              }
              bar-card-backgroundbar {
                background-color: transparent;
              }
              bar-card-name {
                font-size: 12px;
                font-weight: bolder;
                color: #727272;
              }
        - type: custom:bar-card
          title: Tree pollen forecast
          direction: up
          columns: 5
          height: 50px
          width: 100%
          min: 0
          max: 208
          positions:
            icon: 'off'
            name: outside
            value: inside
          severity:
            - color: Green
              from: 0
              to: 95
            - color: Orange
              from: 96
              to: 207
            - color: Red
              from: 208
              to: 999
          animation:
            state: 'on'
            speed: 1
          entities:
            - entity: sensor.home_tree_pollen_0d
              name: Today
            - entity: sensor.home_tree_pollen_1d
              name: Today +1
            - entity: sensor.home_tree_pollen_2d
              name: Today +2
            - entity: sensor.home_tree_pollen_3d
              name: Today +3
            - entity: sensor.home_tree_pollen_4d
              name: Today +4
          card_mod:
            style: |-
              .card-header {
                --ha-card-header-font-size: 20px;
              }
              bar-card-backgroundbar {
                background-color: transparent;
              }
              bar-card-name {
                font-size: 12px;
                font-weight: bolder;
                color: #727272;
              }
        - type: custom:bar-card
          title: Weed pollen forecast
          direction: up
          columns: 5
          height: 50px
          width: 100%
          min: 0
          max: 200
          positions:
            icon: 'off'
            name: outside
            value: inside
          severity:
            - color: Green
              from: 0
              to: 20
            - color: Orange
              from: 21
              to: 77
            - color: Red
              from: 78
              to: 999
          animation:
            state: 'on'
            speed: 1
          entities:
            - entity: sensor.home_ragweed_pollen_0d
              name: Today
            - entity: sensor.home_ragweed_pollen_1d
              name: Today +1
            - entity: sensor.home_ragweed_pollen_2d
              name: Today +2
            - entity: sensor.home_ragweed_pollen_3d
              name: Today +3
            - entity: sensor.home_ragweed_pollen_4d
              name: Today +4
          card_mod:
            style: |-
              .card-header {
                --ha-card-header-font-size: 20px;
              }
              bar-card-backgroundbar {
                background-color: transparent;
              }
              bar-card-name {
                font-size: 12px;
                font-weight: bolder;
                color: #727272;
              }

Here’s my revised version.
I used Pollen Count – find pollen levels near me | Kleenex to get the values of severity.

I changed the icon-colour, bar-card min/max and positions.

For those adding to your own dashboard, you’ll need to make a “toggle” (boolean) helper to enable the drop down graphs. Link to Helpers – My Home Assistant (home-assistant.io)

Edit: 2022-08-23 20:20 BST - Fixed “high” values appearing as blue (missing “to:” value - set to 999 so all high values are red.)

4 Likes

Hay, can you please help with the code/app needed to get the values from Kleenex please?
Thanks for your amazing work.

1 Like

Hi there,
I only used the Kleenex website as guide to hardcode how bad each p/m3 value is.
The pollen data is taken from the Accuweather integration.

As for installing the card:
You’ll need the Mushroom cards, stack-in-card, layout-card, grid-layout, bar-card and card_mod from HACS.
Then you can copy and paste the card code into HASS’s interface. You may need to replace all instances of sensor.home_ with whatever your accuweather integration sensors start with.

Hi @LewisSpring and @BlackCatPeanut - Any chance one of you could help me out by answering a question please? I haven’t used a drop down on any card before in my dashboard, so I’m trying to implement one like the one in your example above, for my own pollen cards. What I don’t quite follow is how the input_boolean it actually triggered by clicking the down arrow in your code. If I understand things correctly, once an input_boolean has been created as a Helper, which i’ve done, then a service can be called which toggles the state of the boolean from off to on, or vice versa when called again. When this state changes to on, then the conditional card displays below the current card, showing the charts.

Is there a tap_action of ‘call-service’ required somewhere within the dropdown template card, which calls the input_boolean.turn_on service? Thanks in advance!

Hi @Scoff,

The Helper you created enables or disables the dropdown functionality of the card.
If you leave the Adaptive Dropdown helper enabled, you can then expand and contract the dropdown as you please via the Card.
If you disable the helper, the dropdown is permanently closed.

Hope this helps.

Thanks Lewis, that makes sense now. I can see that the state of my input_boolean.dropdown entity changes from ‘off’ to ‘on’ and vice versa when I click the dropdown arrow in my card. The conditional card isn’t displaying however, so I’ll double check my conditional card code again, as it’s definitely referencing the correct entity and entity state to display the card.

Are people still using this successfully? I haven’t paid much attention to the values over the past few (cold) months, as my conditional card hasn’t been showing. All values have been zero for quite some time now, so I thought I would check my API token is still valid on tomorrow.io, which it is.

In my developer console in the browser when showing my pollen card, I’m seeing errors such as:

{"code":401001,"type":"Invalid Auth","message":"The method requires authentication but it was not presented or is invalid."}

Has something maybe changed in terms of the RESTful sensor setup with HA, or with Tomorrow.io which means that some sort of additional authentication creds need to be passed in with the API key in the request?

could you please share your yaml code for the kleenex
with greeting

That is the code, it uses the severity levels as written on the website. It doesn’t access it or anything.

For AccuWeather - You have to enable weather forecasts using the checkbox inside the integration on the Home Assistant Integrations page (UI). Then restart and the pollen sensors will appear. I’d warn you that the AccuWeather pollen forecasts for trees in the UK are not accurate though, similar to tomorrow.io.

1 Like

The following section of Tomorrow.io API for Health Management section of their API says that data for High Pollen Account is COMING SOON.

EPXR5ir1

i cant get the pollen index using wither teh restful or the inbuilt tomorrow.io. everything returns as 0 when i try and run the following
https://api.tomorrow.io/v4/timelines?location=-Redacted,Redacted&fields=treeIndex,grassIndex,weedIndex&timesteps=1h&units=metric&apikey=Redacted

{"data":{"timelines":[{"timestep":"1h","endTime":"2023-06-10T14:00:00Z","startTime":"2023-06-05T14:00:00Z","intervals":[{"startTime":"2023-06-05T14:00:00Z","values":{"grassIndex":0,"treeIndex":0,"weedIndex":0}},{"startTime":"2023-06-05T15:00:00Z","values":{"grassIndex":0,"treeIndex":0,"weedIndex":0}},{"startTime":"2023-06-05T16:00:00Z","values":{"grassIndex":0,"treeIndex":0,"weedIndex":0}},{"startTime":"2023-06-05T17:00:00Z","values":{"grassIndex":0,"treeIndex":0,"weedIndex":0}},{"startTime":"2023-06-05T18:00:00Z","values":{"grassIndex":0,"treeIndex":0,"weedIndex":0}},{"startTime":"2023-06-05T19:00:00Z","values":{"grassIndex":0,"treeIndex":0,"weedIndex":0}},{"startTime":"2023-06-05T20:00:00Z","values":{"grassIndex":0,"treeIndex":0,"weedIndex":0}},{"startTime":"2023-06-05T21:00:00Z","values":{"grassIndex":0,"treeIndex":0,"weedIndex":0}},{"startTime":"2023-06-05T22:00:00Z","values":{"grassIndex":0,"treeIndex":0,"weedIndex":0}},{"startTime":"2023-06-05T23:00:00Z","values":{"grassIndex":0,"treeIndex":0,"weedIndex":0}},{"startTime":"2023-06-06T00:00:00Z","values":{"grassIndex":0,"treeIndex":0,"weedIndex":0}},{"startTime":"2023-06-06T01:00:00Z","values":{"grassIndex":0,"treeIndex":0,"weedIndex":0}},{"startTime":"2023-06-06T02:00:00Z","values":{"grassIndex":0,"treeIndex":0,"weedIndex":0}},{"startTime":"2023-06-06T03:00:00Z","values":{"grassIndex":0,"treeIndex":0,"weedIndex":0}},{"startTime":"2023-06-06T04:00:00Z","values":{"grassIndex":0,"treeIndex":0,"weedIndex":0}},{"startTime":"2023-06-06T05:00:00Z","values":{"grassIndex":0,"treeIndex":0,"weedIndex":0}},{"startTime":"2023-06-06T06:00:00Z","values":{"grassIndex":0,"treeIndex":0,"weedIndex":0}},{"startTime":"2023-06-06T07:00:00Z","values":{"grassIndex":0,"treeIndex":0,"weedIndex":0}},{"startTime":"2023-06-06T08:00:00Z","values":{"grassIndex":0,"treeIndex":0,"weedIndex":0}},{"startTime":"2023-06-06T09:00:00Z","values":{"grassIndex":0,"treeIndex":0,"weedIndex":0}},{"startTime":"2023-06-06T10:00:00Z","values":{"grassIndex":0,"treeIndex":0,"weedIndex":0}}

Cany anyone please point me the right direction.