New custom component DWD Pollen sensor (Deutscher Wetterdienst, German Weather Service)

DWD pollen sensor 0.1 V0.1 (05/16/2019)

I have written a component which creates sensors for pollen pollution information in certain areas of Germany. You can configure the area for which you need the information, for which days you need this information (today, tomorrow, day after tomorrow) and which pollen you want to cover (e.g. “Birke”, “Gräser”).

The benefits over using the REST component to directly retrieve the data from DWD are

  • additional sensors for statistical data (maximum, minimum and average)
  • values are normalized: values from 0-6 instead of e.g. “0”, “0-1”, “1”
  • the sensors always shows the correct values for the selected day, i.e. when moving to a new day at 0:00h “tomorrow” will be “today”
  • parsing of pollen data is done by the component

Let me know what you think. I am thinking about creating additonal components for the other open data files the DWD is delivering.

Find the sensor and all required information about it at https://github.com/marcschumacher/dwd_pollen.

Enjoy
Marc

9 Likes

Hello Marc,

thank you for creating this component. I’m using since a few weeks and I like it very much! I only noticed that the forecast for the day after tomorrow was unknown, but I think this was a problem of the data from DWD and not of your component.

Thanks a lot for the component! Very much appreciated.

I already had the rest code for dwd_pollen, and wasn’t aware of your component. I just installed it, works like a charm.

Thanks for sharing and don’t get dissatisfied or annoyed about the response! :slight_smile:

As noted above, I installed the component yesterday and as far as it goes, it works great.

But, I have a short question, why are you querying the api so often? If I understand the DWD right, the json file will be published (and therefore changed) only once a day, at around 11:00 o’clock. Would it be possible, to set a specific query time, like 12:30?

Thanks again, it’s a great component!

EDIT: I changed the timedelta in my files to every 12 hours, works great.

Hi Marc,
great approach.
Maybe some can give me a hint, why my HA is going to safe mode with error log
Pollen-error

My config looks like this - I am sure the fault is on me.
I am still a newby trying to get familiar with yaml.

Line 41 marks the “partregion_ids:” line.

sensor:
  - platform: dwd_pollen
      partregion_ids:
        - 41
        - 42
      include_pollen:
        - birke
        - erle
      include_days:
        - today

Best regards,
Joerg

ok, figured it out :slight_smile:

sensor:
  - platform: dwd_pollen
    partregion_ids:
      - 10
      - 11
    include_pollen:
      - birke
      - erle
    include_days:
      - today

Now fine tuning is on the schedule :slight_smile:

Regards and Respect for the good and helpful component!
Joerg

Fine Tuning done :slight_smile:
Just a short very final THANKS :slight_smile:Vertical-Stack-Pollen

@jackeroo_marc Thanks for this sensor. Exactly what I was looking for! Unfortunately I have a hard time implementing this sensor. I followed your instructions, downloaded the newest version from github, installed it in my coustom components, run the command sucessfully and added the following lines to my config.yaml. Restarted HA. Did I missed something? Unfortunately there is no sensor to be found if I search for “pollen”. Shouldnt there be a sensor, eventhough the value is =0? Thanks for your help!

  - platform: dwd_pollen
    partregion_ids:
      - 110
    include_pollen:
      - birke
      - graeser
      - esche 
      - erle
      - hasel
      - beifuss
      - ambrosia
      - roggen
    include_days:
      - today
      - tomorrow

Do you restarted HA between adding the custom_component and adding the lines to your config.yaml?

Unfortunately @jackeroo_marc’s custom integration is broken for some time now.
While Marc will surely get to it when spring approaches, here is an alternative for all those who use Node RED in HA. It is purely based on DWD’s REST API.

This flow uses JSONPath to address the region object in the API response.
So before you install it you have to add the contrib node-red-contrib-jsonpath to Node RED:
Open NODE Red –> Hamburger icon menu –> Manage Palette –> Install –> Search for “node-red-contrib-jsonpath”…

[{"id":"f386895a.cb5ad","type":"tab","label":"DWD Pollen","disabled":false,"info":""},{"id":"2711d836.be6dc8","type":"http request","z":"f386895a.cb5ad","name":"Open Data vom DWD abfragen","method":"GET","ret":"obj","paytoqs":"ignore","url":"https://opendata.dwd.de/climate_environment/health/alerts/s31fg.json","tls":"","persist":false,"proxy":"","authType":"basic","x":430,"y":80,"wires":[["803126c5.a88428","884e0659.058ab8"]]},{"id":"cd8de1db.bed78","type":"inject","z":"f386895a.cb5ad","name":"Täglich um 11:23","props":[{"p":"payload"},{"p":"topic","vt":"str"}],"repeat":"","crontab":"23 11 * * *","once":false,"onceDelay":0.1,"topic":"","payload":"","payloadType":"date","x":170,"y":80,"wires":[["2711d836.be6dc8"]]},{"id":"4f7477d5.340cc8","type":"comment","z":"f386895a.cb5ad","name":"DWD Pollenflug-Gefahrenindex ...","info":"https://www.dwd.de/DE/leistungen/gefahrenindizespollen/gefahrenindexpollen.html\nhttps://opendata.dwd.de/climate_environment/health/alerts/Beschreibung_pollen_s31fg.pdf\n \n \n----------\nBelastung\n----------\n\"0\"   = \"keine Belastung\"\n\"0-1\" = \"keine bis geringe Belastung\"\n\"1\"   = \"geringe Belastung\"\n\"1-2\" = \"geringe bis mittlere Belastung\"\n\"2\"   = \"mittlere Belastung\"\n\"2-3\" = \"mittlere bis hohe Belastung\"\n\"3\"   = \"hohe Belastung\"\n\n\n----------\nZuordnungen der region_id, bzw. partregion_id\n----------\nHauptgebiete (region_id) werden in Zehnerschritten unterteilt, \nTeilbereiche in Einerschritten.\n----------\n\n10=Schleswig-Holstein und Hamburg\n11=Inseln und Marschen\n12=Geest,Schleswig-Holstein und Hamburg\n\n20=Mecklenburg-Vorpommern\n\n30=Niedersachsen und Bremen\n31=Westl. Niedersachsen/Bremen\n32=Östl. Niedersachsen\n\n40=Nordrhein-Westfalen\n41=Rhein.-Westfäl. Tiefland\n42=Ostwestfalen\n43=Mittelgebirge NRW\n\n50=Brandenburg und Berlin\n\n60=Sachsen-Anhalt\n61=Tiefland Sachsen-Anhalt\n62=Harz\n\n70=Thüringen\n71=Tiefland Thüringen\n72=Mittelgebirge Thüringen\n\n80=Sachsen\n81=Tiefland Sachsen\n82=Mittelgebirge Sachsen\n\n90=Hessen\n91=Nordhessen und hess. Mittelgebirge\n92=Rhein-Main\n\n100=Rheinland-Pfalz und Saarland\n101=Rhein, Pfalz, Nahe und Mosel\n102=Mittelgebirgsbereich Rheinland-Pfalz\n103=Saarland\n110=Baden-Württemberg\n111=Oberrhein und unteres Neckartal\n112=Hohenlohe/mittlerer Neckar/Oberschwaben\n113=Mittelgebirge Baden-Württemberg\n\n120=Bayern\n121=Allgäu/Oberbayern/Bay. Wald\n122=Donauniederungen\n123=Bayern nördl. der Donau, o. Bayr. Wald, o. Mainfranken\n124=Mainfranken\n\n","x":200,"y":40,"wires":[]},{"id":"803126c5.a88428","type":"jsonpath","z":"f386895a.cb5ad","expression":"$..content[?(@.partregion_id==103)]","split":false,"name":"Selektiere Saarland (partregion_id==103)","x":460,"y":140,"wires":[["5a4b1214.49176c","bd3f25f3.2b2b78"]]},{"id":"5a4b1214.49176c","type":"debug","z":"f386895a.cb5ad","name":"","active":false,"tosidebar":true,"console":false,"tostatus":false,"complete":"false","statusVal":"","statusType":"auto","x":730,"y":140,"wires":[]},{"id":"fe97990e.baa188","type":"ha-entity","z":"f386895a.cb5ad","name":"dwd_pollen_esche","server":"cb38d2a3.10198","version":1,"debugenabled":false,"outputs":1,"entityType":"sensor","config":[{"property":"name","value":"Pollen Esche"},{"property":"device_class","value":""},{"property":"icon","value":"hass:flower"},{"property":"unit_of_measurement","value":""}],"state":"payload[0].Pollen.Esche.today_num","stateType":"msg","attributes":[{"property":"plain_text","value":"payload[0].Pollen.Esche.today_text","valueType":"msg"},{"property":"publish_date","value":"payload[0].publish_date","valueType":"msg"}],"resend":true,"outputLocation":"","outputLocationType":"none","inputOverride":"allow","x":750,"y":380,"wires":[[]]},{"id":"3ae05cbf.63e3c4","type":"ha-entity","z":"f386895a.cb5ad","name":"dwd_pollen_hasel","server":"cb38d2a3.10198","version":1,"debugenabled":false,"outputs":1,"entityType":"sensor","config":[{"property":"name","value":"Pollen Hasel"},{"property":"device_class","value":""},{"property":"icon","value":"hass:flower"},{"property":"unit_of_measurement","value":""}],"state":"payload[0].Pollen.Hasel.today_num","stateType":"msg","attributes":[{"property":"plain_text","value":"payload[0].Pollen.Hasel.today_text","valueType":"msg"},{"property":"publish_date","value":"payload[0].publish_date","valueType":"msg"}],"resend":true,"outputLocation":"","outputLocationType":"none","inputOverride":"allow","x":750,"y":680,"wires":[[]]},{"id":"50d0ee1f.ce0b","type":"ha-entity","z":"f386895a.cb5ad","name":"dwd_pollen_regionname","server":"cb38d2a3.10198","version":1,"debugenabled":false,"outputs":1,"entityType":"sensor","config":[{"property":"name","value":"Region"},{"property":"device_class","value":""},{"property":"icon","value":"hass:flower"},{"property":"unit_of_measurement","value":""}],"state":"payload[0].partregion_name","stateType":"msg","attributes":[],"resend":true,"outputLocation":"","outputLocationType":"none","inputOverride":"allow","x":770,"y":320,"wires":[[]]},{"id":"bd3f25f3.2b2b78","type":"function","z":"f386895a.cb5ad","name":"Daten erhalten?","func":"if(typeof msg.payload === \"object\" && msg.payload.length>0){\n    return msg;\n}\n","outputs":1,"noerr":0,"initialize":"","finalize":"","x":380,"y":200,"wires":[["94ce6d4b.813bb"]]},{"id":"884e0659.058ab8","type":"debug","z":"f386895a.cb5ad","name":"","active":false,"tosidebar":true,"console":false,"tostatus":false,"complete":"false","statusVal":"","statusType":"auto","x":730,"y":80,"wires":[]},{"id":"a74c40c7.58118","type":"ha-entity","z":"f386895a.cb5ad","name":"dwd_pollen_erle","server":"cb38d2a3.10198","version":1,"debugenabled":false,"outputs":1,"entityType":"sensor","config":[{"property":"name","value":"Pollen Erle"},{"property":"device_class","value":""},{"property":"icon","value":"hass:flower"},{"property":"unit_of_measurement","value":""}],"state":"payload[0].Pollen.Erle.today_num","stateType":"msg","attributes":[{"property":"plain_text","value":"payload[0].Pollen.Erle.today_text","valueType":"msg"},{"property":"publish_date","value":"payload[0].publish_date","valueType":"msg"}],"resend":true,"outputLocation":"","outputLocationType":"none","inputOverride":"allow","x":740,"y":440,"wires":[[]]},{"id":"6ecd2a38.cb1594","type":"ha-entity","z":"f386895a.cb5ad","name":"dwd_pollen_roggen","server":"cb38d2a3.10198","version":1,"debugenabled":false,"outputs":1,"entityType":"sensor","config":[{"property":"name","value":"Pollen Roggen"},{"property":"device_class","value":""},{"property":"icon","value":"hass:flower"},{"property":"unit_of_measurement","value":""}],"state":"payload[0].Pollen.Roggen.today_num","stateType":"msg","attributes":[{"property":"plain_text","value":"payload[0].Pollen.Roggen.today_text","valueType":"msg"},{"property":"publish_date","value":"payload[0].publish_date","valueType":"msg"}],"resend":true,"outputLocation":"","outputLocationType":"none","inputOverride":"allow","x":750,"y":500,"wires":[[]]},{"id":"453fd9c.a193728","type":"ha-entity","z":"f386895a.cb5ad","name":"dwd_pollen_beifuss","server":"cb38d2a3.10198","version":1,"debugenabled":false,"outputs":1,"entityType":"sensor","config":[{"property":"name","value":"Pollen Beifuß"},{"property":"device_class","value":""},{"property":"icon","value":"hass:flower"},{"property":"unit_of_measurement","value":""}],"state":"payload[0].Pollen.Beifuss.today_num","stateType":"msg","attributes":[{"property":"plain_text","value":"payload[0].Pollen.Beifuss.today_text","valueType":"msg"},{"property":"publish_date","value":"payload[0].publish_date","valueType":"msg"}],"resend":true,"outputLocation":"","outputLocationType":"none","inputOverride":"allow","x":760,"y":560,"wires":[[]]},{"id":"145f24fe.6f2cfb","type":"ha-entity","z":"f386895a.cb5ad","name":"dwd_pollen_birke","server":"cb38d2a3.10198","version":1,"debugenabled":false,"outputs":1,"entityType":"sensor","config":[{"property":"name","value":"Pollen Birke"},{"property":"device_class","value":""},{"property":"icon","value":"hass:flower"},{"property":"unit_of_measurement","value":""}],"state":"payload[0].Pollen.Birke.today_num","stateType":"msg","attributes":[{"property":"plain_text","value":"payload[0].Pollen.Birke.today_text","valueType":"msg"},{"property":"publish_date","value":"payload[0].publish_date","valueType":"msg"}],"resend":true,"outputLocation":"","outputLocationType":"none","inputOverride":"allow","x":750,"y":620,"wires":[[]]},{"id":"914cd902.eec3e8","type":"ha-entity","z":"f386895a.cb5ad","name":"dwd_pollen_ambrosia","server":"cb38d2a3.10198","version":1,"debugenabled":false,"outputs":1,"entityType":"sensor","config":[{"property":"name","value":"Pollen Ambrosia"},{"property":"device_class","value":""},{"property":"icon","value":"hass:flower"},{"property":"unit_of_measurement","value":""}],"state":"payload[0].Pollen.Ambrosia.today_num","stateType":"msg","attributes":[{"property":"plain_text","value":"payload[0].Pollen.Ambrosia.today_text","valueType":"msg"},{"property":"publish_date","value":"payload[0].publish_date","valueType":"msg"}],"resend":true,"outputLocation":"","outputLocationType":"none","inputOverride":"allow","x":760,"y":740,"wires":[[]]},{"id":"d64dfea6.e635e","type":"ha-entity","z":"f386895a.cb5ad","name":"dwd_pollen_graeser","server":"cb38d2a3.10198","version":1,"debugenabled":false,"outputs":1,"entityType":"sensor","config":[{"property":"name","value":"Pollen Gräser"},{"property":"device_class","value":""},{"property":"icon","value":"hass:flower"},{"property":"unit_of_measurement","value":""}],"state":"payload[0].Pollen.Graeser.today_num","stateType":"msg","attributes":[{"property":"plain_text","value":"payload[0].Pollen.Graeser.today_text","valueType":"msg"},{"property":"publish_date","value":"payload[0].publish_date","valueType":"msg"}],"resend":true,"outputLocation":"","outputLocationType":"none","inputOverride":"allow","x":760,"y":800,"wires":[[]]},{"id":"94ce6d4b.813bb","type":"function","z":"f386895a.cb5ad","name":"today-Werte in Num und Text wandeln","func":"var convertValues = {\n    \"0\"   : [0  , \"keine Belastung\"],\n    \"0-1\" : [0.5, \"keine bis geringe Belastung\"],\n    \"1\"   : [1  , \"geringe Belastung\"],\n    \"1-2\" : [1.5, \"geringe bis mittlere Belastung\"],\n    \"2\"   : [2  , \"mittlere Belastung\"],\n    \"2-3\" : [2.5, \"mittlere bis hohe Belastung\"],\n    \"3\"   : [3  , \"hohe Belastung\"]\n};\n\n// create float values and text representations\nObject.values(msg.payload[0].Pollen).forEach(\n    function(msgSubObj){\n        msgSubObj.today_num  = convertValues[msgSubObj.today][0];\n        msgSubObj.today_text = convertValues[msgSubObj.today][1];\n    }\n);\n\n// add publish date/time\nmsg.payload[0].publish_date = new Date(msg.headers[\"last-modified\"]);\n\nreturn msg;\n","outputs":1,"noerr":0,"initialize":"","finalize":"","x":450,"y":260,"wires":[["cb8af39.6580b1","50d0ee1f.ce0b","fe97990e.baa188","a74c40c7.58118","6ecd2a38.cb1594","453fd9c.a193728","145f24fe.6f2cfb","3ae05cbf.63e3c4","914cd902.eec3e8","d64dfea6.e635e"]]},{"id":"cb8af39.6580b1","type":"debug","z":"f386895a.cb5ad","name":"","active":false,"tosidebar":true,"console":false,"tostatus":false,"complete":"true","targetType":"full","statusVal":"","statusType":"auto","x":710,"y":260,"wires":[]},{"id":"cb38d2a3.10198","type":"server","name":"Home Assistant"}]
1 Like

Hi @jackeroo_marc,
is there any update from your side?
Pollen issues have started…

Hope you do not have more serious problems.
Stay healthy.

Regards
Jörg

I created a new custom component which is accessible via HACS and can be completely configured from the Web UI:

Enjoy.

3 Likes

Thank you for this. The nodered solution which was made by @Jpsy (and thank you for that! Works great) was the last remaining nodered item I had in my setup. Your integration (via Hacs) works like a charm and I have already updated my cards to use it. So (for now at least) now I can sunset my nodered integration ;-).

1 Like

How did you ever do that? The number of my Node Red flows keeps growing and growing! :joy:

Something tells me that my setup is way more basic than yours :slight_smile: . And I must admit that it has become a lot easier to create automations straight in HA. NR still has a very nice elegance to it though. I am not ruling out that somewhere down the line I may need NR again for something.

1 Like