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

I signed up for a free plan and added my Secret Key into the ClimaCell integration in Home Assistant but it seems that Pollen is either not supported in my area or not supported by the free plan any longer. Can someone please confirm?

Its in the disabled entities, just enable them and away you go

1 Like

Hello everybody,
in the end I created a card myself.
The result seems pleasant to me.

Below you will find the yaml code to create the card.

type: glance
entities:
  - entity: sensor.pollen_grass
    icon: mdi:grass
    card_mod: null
    style: |

      :host {
            {% if states(config.entity) | int <= 1 %} 
            --card-mod-icon: mdi:grass;
            --card-mod-icon-color: green;
            {% elif states(config.entity) | int <= 3 %}
            --card-mod-icon: mdi:grass;
            --card-mod-icon-color: orange;
            {% elif states(config.entity) | int <= 5 %}
            --card-mod-icon: mdi:grass;
            --card-mod-icon-color: red;
            {% endif %}
            ;
      }

        :host {
          color:
            {% if states(config.entity) | int <= 1 %} 
              green
            {% elif states(config.entity) | int <= 3 %}
              orange
            {% elif states(config.entity) | int <= 5 %}
              red
            {% endif %}
            ;
        }
  - entity: sensor.pollen_tree
    icon: mdi:tree
    card_mod: null
    style: |

      :host {
            {% if states(config.entity) | int <= 1 %} 
            --card-mod-icon: mdi:tree;
            --card-mod-icon-color: green;
            {% elif states(config.entity) | int <= 3 %}
            --card-mod-icon: mdi:tree;
            --card-mod-icon-color: orange;
            {% elif states(config.entity) | int <= 5 %}
            --card-mod-icon: mdi:tree;
            --card-mod-icon-color: red;
            {% endif %}
            ;
      }

        :host {
          color:
            {% if states(config.entity) | int <= 1 %} 
              green
            {% elif states(config.entity) | int <= 3 %}
              orange
            {% elif states(config.entity) | int <= 5 %}
              red
            {% endif %}
            ;
        }
  - entity: sensor.pollen_weed
    icon: mdi:spa
    card_mod: null
    style: |

      :host {
            {% if states(config.entity) | int <= 1 %} 
            --card-mod-icon: mdi:spa;
            --card-mod-icon-color: green;
            {% elif states(config.entity) | int <= 3 %}
            --card-mod-icon: mdi:spa;
            --card-mod-icon-color: orange;
            {% elif states(config.entity) | int <= 5 %}
            --card-mod-icon: mdi:spa;
            --card-mod-icon-color: red;
            {% endif %}
            ;
      }

        :host {
          color:
            {% if states(config.entity) | int <= 1 %} 
              green
            {% elif states(config.entity) | int <= 3 %}
              orange
            {% elif states(config.entity) | int <= 5 %}
              red
            {% endif %}
            ;
        }
title: Pollen index

Again thanks to @Craig_McGowan, the author of this thread

2 Likes

If I use the V4 api I get unsupported messages like this:

"type":"Time Bounded Field","message":"The following field is not supported for a time range: 'weedIndex'"

This is my test curl:

curl --request GET --url
https://api.tomorrow.io/v4/timelines?location=xxxx,xxxx&timesteps=1d&units=metric&apikey=xxxxxx&fields=weedIndex
{“data”:{“timelines”:[{“timestep”:“1d”,“endTime”:“2022-05-23T04:00:00Z”,“startTime”:“2022-05-18T04:00:00Z”,“intervals”:[{“startTime”:“2022-05-18T04:00:00Z”,“values”:{“weedIndex”:0}},{“startTime”:“2022-05-19T04:00:00Z”,“values”:{“weedIndex”:0}},{“startTime”:“2022-05-20T04:00:00Z”,“values”:{“weedIndex”:0}},{“startTime”:“2022-05-21T04:00:00Z”,“values”:{“weedIndex”:0}},{“startTime”:“2022-05-22T04:00:00Z”,“values”:{“weedIndex”:0}},{“startTime”:“2022-05-23T04:00:00Z”,“values”:{“weedIndex”:0}}]}]},“warnings”:[{“code”:246001,“type”:“Time Bounded Field”,“message”:“The following field is not supported for a time range: ‘weedIndex’”,“meta”:{“field”:“weedIndex”,“from”:“2022-05-18T02:30:00Z”,“to”:“2022-05-23T09:36:00Z”}}]}%

From documentation:

In any cases where a field is not available in a requested timestep, the request will result in a Timestep Bounded Field warning.

[…] Data availability beyond -6H in the past and beyond 4.5 days in the future is available for paid plans as an add-on only.

May 23rd goes beyond 4.5 days. Do you have a paid plan?

Got this working today. Configured for my home address. Such a shame:

Met Office prediction:

Chocolate teapot comes to mind :frowning:

Try again now? My integration has been working fine up until this morning - appears to be some sort of widespread CDN / Cloudflare issue. I’ve just started to receive correct pollen data again in my dashboard so hopefully it’s OK again now…

This looks awesome and just what what I’m ater, however I’ve tinkered and can’t find where to add rest sensor etc (only been playing with HA for a week)

Anybody willing to lay out step by step process for getting this into HA? I’ve already signed up for an account with tomorrow.io

1 Like

@e4kenndr There’s an official integration for Tomorrow.io since 2022.4, so I think you might not have to use rest sensors:
Tomorrow.io - Home Assistant

It might be that the rest sensors provide more detailed information than the official integration, I’ve not done a data comparison. If you do end up wanting to use a custom REST sensor, you can find some documentation here: RESTful Sensor - Home Assistant

I had a quick look and its missing the forecast values which is what I’m specifically interested in with the pollen counts specifically. I have installed the service to see what other features it offers. Thanks for sharing…

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