Figured out my own question (solution on the bottom of this reply) and also yours:
in ‘Source/Bron’ add https://www.kleenex.nl/api/sitecore/Pollen/GetPollenContentCity?city=CITYNAME
or postal code with the four numbers first, then %20
then the two letters (%20
being a space) So something like 1234%20AB
Method should be POST
Authentication should be basic
Skip username and password
Headers should be this:
User-Agent: Home Assistant
Content-Type: application/x-www-form-urlencoded;
leave the rest and continue to the next page
This one configures specific sensors. You should do this part three times if you want to add all three sensors, and seventeen times if you want to add detailed sensors (specific pollen types) too. I’ll explain how that works further on. For now:
Give it a name like Pollen (grass)
to specify which sensor this will be.
Selector should be li.day-container:nth-child(1) > button
Leave index at zero
Attribute should be data-grass-count
for grass, data-trees-count
for trees, data-weeds-count
for weeds, data-grass-detail
for detailed grass pollen (1 type, Poaceae), data-tree-detail
for detailed tree pollen (9 types, Hazelaar, Iep, Pijnboom, Els, Populier, Eik, Plataan, Berk, Cipres), data-weeds-count
for detailed weed pollen (4 types, Bijvoet, Ganzevoet, Ambrosia, Brandnetel).
Template should be {{ value.split(" ")[0] }}
for the count types (grass, trees, weeds) and {{ value.split(" ,)[1] }}
for the detailed pollen types. The number 1 should go up by two for each type in the list (Eg: for Poaceae it should be 1, for Hazelaar also 1 but for Iep 3. If you don’t want to use all detailed ones but just a few, their indexes still go up. So Populier will always be index 9)
You can choose a device class and state class of your own liking. Same goes for the last setting.
If you have saved this, go to settings → integrations → scrape, click on ‘configure’ and click on ‘add sensor’ to add extra sensors.
A way quicker method is to use yaml:
scrape:
- resource: https://www.kleenex.nl/api/sitecore/Pollen/GetPollenContentCity
method: POST
payload: "city=YOUR CITYNAME OR POSTAL CODE"
headers:
User-Agent: Home Assistant
Content-Type: application/x-www-form-urlencoded; charset=UTF-8
scan_interval: 3600
sensor:
- name: Pollen (gras)
select: "li.day-container:nth-child(1) > button"
attribute: "data-grass-count"
unique_id: pollen_gras
unit_of_measurement: ppm
value_template: >-
{{ value.split(" ")[0] }}
- name: Pollen (Poaceae)
select: "li.day-container:nth-child(1) > button"
attribute: "data-grass-detail"
unique_id: pollen_poaceae
unit_of_measurement: ppm
value_template: >-
{{ value.split(",")[1] }}
- name: Pollen (kruiden)
select: "li.day-container:nth-child(1) > button"
attribute: "data-weeds-count"
unique_id: pollen_kruiden
unit_of_measurement: ppm
value_template: >-
{{ value.split(" ")[0] }}
- name: Pollen (Bijvoet)
select: "li.day-container:nth-child(1) > button"
attribute: "data-weed-detail"
unique_id: pollen_bijvoet
unit_of_measurement: ppm
value_template: >-
{{ value.split(",")[1] }}
- name: Pollen (Ganzevoet)
select: "li.day-container:nth-child(1) > button"
attribute: "data-weed-detail"
unique_id: pollen_ganzevoet
unit_of_measurement: ppm
value_template: >-
{{ value.split(",")[3] }}
- name: Pollen (Ambrosia)
select: "li.day-container:nth-child(1) > button"
attribute: "data-weed-detail"
unique_id: pollen_ambrosia
unit_of_measurement: ppm
value_template: >-
{{ value.split(",")[5] }}
- name: Pollen (Brandnetel)
select: "li.day-container:nth-child(1) > button"
attribute: "data-weed-detail"
unique_id: pollen_brandnetel
unit_of_measurement: ppm
value_template: >-
{{ value.split(",")[7] }}
- name: Pollen (bomen)
select: "li.day-container:nth-child(1) > button"
attribute: "data-trees-count"
unique_id: pollen_bomen
unit_of_measurement: ppm
value_template: >-
{{ value.split(" ")[0] }}
- name: Pollen (Hazelaar)
select: "li.day-container:nth-child(1) > button"
attribute: "data-tree-detail"
unique_id: pollen_hazelaar
unit_of_measurement: ppm
value_template: >-
{{ value.split(",")[1] }}
- name: Pollen (Iep)
select: "li.day-container:nth-child(1) > button"
attribute: "data-tree-detail"
unique_id: pollen_iep
unit_of_measurement: ppm
value_template: >-
{{ value.split(",")[3] }}
- name: Pollen (Pijnboom)
select: "li.day-container:nth-child(1) > button"
attribute: "data-tree-detail"
unique_id: pollen_pijnboom
unit_of_measurement: ppm
value_template: >-
{{ value.split(",")[5] }}
- name: Pollen (Els)
select: "li.day-container:nth-child(1) > button"
attribute: "data-tree-detail"
unique_id: pollen_els
unit_of_measurement: ppm
value_template: >-
{{ value.split(",")[7] }}
- name: Pollen (Populier)
select: "li.day-container:nth-child(1) > button"
attribute: "data-tree-detail"
unique_id: pollen_populier
unit_of_measurement: ppm
value_template: >-
{{ value.split(",")[9] }}
- name: Pollen (Eik)
select: "li.day-container:nth-child(1) > button"
attribute: "data-tree-detail"
unique_id: pollen_eik
unit_of_measurement: ppm
value_template: >-
{{ value.split(",")[11] }}
- name: Pollen (Plataan)
select: "li.day-container:nth-child(1) > button"
attribute: "data-tree-detail"
unique_id: pollen_plataan
unit_of_measurement: ppm
value_template: >-
{{ value.split(",")[13] }}
- name: Pollen (Berk)
select: "li.day-container:nth-child(1) > button"
attribute: "data-tree-detail"
unique_id: pollen_berk
unit_of_measurement: ppm
value_template: >-
{{ value.split(",")[15] }}
- name: Pollen (Cipres)
select: "li.day-container:nth-child(1) > button"
attribute: "data-tree-detail"
unique_id: pollen_cipres
unit_of_measurement: ppm
value_template: >-
{{ value.split(",")[17] }}
edited to add unit_of_measurement: ppm
to each sensor so it shows as a graph instead of numbers.