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

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.

I found the values used by Accuweather: AccuWeather APIs | Daily Index Categories and Level Values

Couple of things to try…

You’ve set it to do 1h timesteps. Could it be there is literally no pollen for the next few hours? Try change to 1d and see if you get the same result

Secondly, are you positive that your location latitude and longitude are the correct way around? Previously I’ve entered mine the wrong way around and ended up at sea, which explains the no pollen, and isn’t too unusual with 70% of the Earth being water??

Yes I would also try changing the timesteps to 1d to get a better idea if that’s the issue, as well as checking the lat/long is definitely correct as Craig has suggested. Here’s the code I use which is slightly different, as I include a startTime and an endTime due to the 1d timestep:

https://api.tomorrow.io/v4/timelines?location=Redacted,-Redacted&timesteps=1d&units=metric&fields=treeIndex,grassIndex,weedIndex&startTime=now&endTime=nowPlus5d&apikey=Redacted

This is working fine for me currently

can you share the code?

can you share the code? (sensor)

I can confirm that by using the URL with your correct lat, long and API key that you can receive the correct pollen count. I then use that URL with this example to obtain a template that works - GitHub - Xorfor/HA-tomorrow.io-Pollen: Get information about pollen in the air at your current location from tomorrow.io.

Test the url first, obtain the results correctly and then use that URL in the example.

This has been working correctly for a while now. It only seems to generate an error if the rest API cannot return the expected number of days worth of data - if they are throttling the free API service for example. This is the template sensor setup that I use and that works currently:

- name: Pollen - Grass
      unique_id: sensor.pollen_grass
      state: "{{ states('sensor.pollen_grass_index_day_0') }}"
      icon: "mdi:grass"
      attributes:
        Today: "{{ states('sensor.pollen_grass_index_day_0') }}"
        Tomorrow: "{{ states('sensor.pollen_grass_index_day_1') }}"
        Today + 2: "{{ states('sensor.pollen_grass_index_day_2') }}"
        Today + 3: "{{ states('sensor.pollen_grass_index_day_3') }}"
        Today + 4: "{{ states('sensor.pollen_grass_index_day_4') }}"

    - name: Pollen - Tree
      unique_id: sensor.pollen_tree
      state: "{{ state_attr('sensor.pollen_grass_index_day_0', 'treeIndex') }}"
      icon: "mdi:tree"
      attributes:
        Today: "{{ state_attr('sensor.pollen_grass_index_day_0', 'treeIndex') }}"
        Tomorrow: "{{ state_attr('sensor.pollen_grass_index_day_1', 'treeIndex') }}"
        Today + 2: "{{ state_attr('sensor.pollen_grass_index_day_2', 'treeIndex') }}"
        Today + 3: "{{ state_attr('sensor.pollen_grass_index_day_3', 'treeIndex') }}"
        Today + 4: "{{ state_attr('sensor.pollen_grass_index_day_4', 'treeIndex') }}"

    - name: Pollen - Weed
      unique_id: sensor.pollen_weed
      state: "{{ state_attr('sensor.pollen_grass_index_day_0', 'weedIndex') }}"
      icon: "mdi:spa"
      attributes:
        Today: "{{ state_attr('sensor.pollen_grass_index_day_0', 'weedIndex') }}"
        Tomorrow: "{{ state_attr('sensor.pollen_grass_index_day_1', 'weedIndex') }}"
        Today + 2: "{{ state_attr('sensor.pollen_grass_index_day_2', 'weedIndex') }}"
        Today + 3: "{{ state_attr('sensor.pollen_grass_index_day_3', 'weedIndex') }}"
        Today + 4: "{{ state_attr('sensor.pollen_grass_index_day_4', 'weedIndex') }}"

    - name: "Pollen Grass Description"
      state: >
        {% if is_state('sensor.pollen_grass', '0') %}
          Zero
        {% elif is_state('sensor.pollen_grass', '1') %}
          Very Low
        {% elif is_state('sensor.pollen_grass', '2') %}
          Low
        {% elif is_state('sensor.pollen_grass', '3') %}
          Medium
        {% elif is_state('sensor.pollen_grass', '4') %}
          High
        {% elif is_state('sensor.pollen_grass', '5') %}
          Very High
        {% endif %}

    - name: "Pollen Tree Description"
      state: >
        {% if is_state('sensor.pollen_tree', '0') %}
          Zero
        {% elif is_state('sensor.pollen_tree', '1') %}
          Very Low
        {% elif is_state('sensor.pollen_tree', '2') %}
          Low
        {% elif is_state('sensor.pollen_tree', '3') %}
          Medium
        {% elif is_state('sensor.pollen_tree', '4') %}
          High
        {% elif is_state('sensor.pollen_tree', '5') %}
          Very High
        {% endif %}

    - name: "Pollen Weed Description"
      state: >
        {% if is_state('sensor.pollen_weed', '0') %}
          Zero
        {% elif is_state('sensor.pollen_weed', '1') %}
          Very Low
        {% elif is_state('sensor.pollen_weed', '2') %}
          Low
        {% elif is_state('sensor.pollen_weed', '3') %}
          Medium
        {% elif is_state('sensor.pollen_weed', '4') %}
          High
        {% elif is_state('sensor.pollen_weed', '5') %}
          Very High
        {% endif %}