[Help request] Pollen sensor Dutch hooikoortsradar.nl

Who can help me to get the data from http://hooikoortsradar.nl and Pollennieuws | Pollenkalender

I used the ambee integraton before but since this is no longer free we can’t get get this info anymore.
Hope someone can point me the correct direction. So I (and many with me) can get this data again.
As an alternative or maybe better source we can use: Pollenrader – de pollenprognose bij jou in de buurt | Kleenex®. Kleenex provides this info for more locations so maybe this is the best solution.

Ok, are you confident in solving issues? This one will be tough!.
I made a script, in Python, it is giving a json that contains info from kleenex.

kleenex.py https://www.kleenex.nl/pollenradar?city=Maastricht


"Gras": 0
"Bomen": 11
"Onkruid": 0

The script is the following

from requests_html import HTMLSession
import sys

url = sys.argv[1]

session = HTMLSession()
r = session.get(url)
r.html.render(sleep = 2, timeout = 20)
levels = r.html.find('.ppm-level')

print("\"Gras\": " + levels[0].text.split()[0])
print("\"Bomen\": " + levels[1].text.split()[0])
print("\"Onkruid\": " + levels[2].text.split()[0])

But for this script to work, it will require requests-html to be installed in your environment

python3.10 -m pip install requests-html

If you’re not using an x86-64 machine, chromium installation will fail.
To solve that, you have to follow what is written on this page:

If you managed to go through all those difficulties, it should work and you can run it as a command line in HA.

Good luck!

This is very dependant of the kleenex website.
It is assuming that you’ll always get 3 values, for gras, bomen and onkruid, in that order, with that specific ‘ppm-level’ class.
If the page change, everything will collapse!

EDIT2 Then, you can do gauges with the levels from the kleenex website:

Risiconiveau Boom Gras Onkruid
Laag 0-95 0-29 0-20
Gemiddeld 96-207 30-60 21-77
Hoog 208-703 61-341 78-266
Zeer hoog 704+ 342+ 267+

Go play with it thanks for your quick response and detailed answer

Additional detail, in case you don’t know how to get json values in sensor:

  - platform: command_line
    name: pollen
    command: python3.10 kleenex.py https://www.kleenex.nl/pollenradar?city=Maastricht
      - gras
      - bomen
      - onkruid
    unit_of_measurement: ppm
    unique_id: kleenex_nl_pollenradar

Feel free to replace Maastricht with your location.

Added unit of measurement and unique id

You can also try:

  - resource: https://www.kleenex.nl/api/sitecore/Pollen/GetPollenContentCity
    method: POST
    payload: "city=Amsterdam"
      User-Agent: Home Assistant
      Content-Type: application/x-www-form-urlencoded; charset=UTF-8
    scan_interval: 3600
      - name: Pollen (grass)
        select: "li.day-container:nth-child(1) > button"
        attribute: "data-grass-count"
        unique_id: pollen_grass
        value_template: >-
          {{ value.split(" ")[0] }}
      - name: Pollen (weeds)
        select: "li.day-container:nth-child(1) > button"
        attribute: "data-weeds-count"
        unique_id: pollen_weeds
        value_template: >-
          {{ value.split(" ")[0] }}
      - name: Pollen (trees)
        select: "li.day-container:nth-child(1) > button"
        attribute: "data-trees-count"
        unique_id: pollen_trees
        value_template: >-
          {{ value.split(" ")[0] }}

Does that work now? I tried that in the past but as it is only rendered when javascript is running, it was not working.

EDIT Seems it does work, this is much more easier ! Nice, I’ll have some fun updating my old sensors :slight_smile:

Thanks to both off you, I’ll test it today, i was not able to test it earlier because of illness

Do @mgosselink’s solution first, it is the easiest.
Here is a link to that integration, to put in your configuration.yaml file

Read it carefully because you might need libxml2 for this to work.


        value_template: >-
          {{ value.split(" ")[0] | int(0) }}
        unit_of_measurement: ppm
        state_class: measurement

For the values to be number and generate statistics.