DurgNomis-drol / DMI_pollen

Pollen tal fra DMI
MIT License
8 stars 1 forks source link

Combine pollen attributes in a list for 'easier' notification push #1

Open htvekov opened 3 years ago

htvekov commented 3 years ago

Hi' Simon.

Spend an entire evening doing complicated regex filtering on exact same DMI API output, just to find your cc two days later 🙄😁😉

Works like a charm, lovely work 👍

It's a bit tricky, at least for me (I gave up on a for/endfor template loop) to combine all the pollen attributes in one string. Ended up using this regex filter to get the output I need for Pushover notifications (combined with time of sensor update and forecast).

{{ expand ('sensor.dmi_pollen_viborg') | regex_findall_index (";(.+?), severity", index=0) | regex_replace(find='=', replace=':') }}

to get me this string: birk:0, bynke:0, el:56, elm:0, græs:0, hassel:4

It could most likely be solved more elegantly from the cc I guess. Haven't found a way filtering out the zero value attributes completely. Will most likely need a template loop to do that.

Anyway, once again thank you for the component 😎👏

Ciao !

DurgNomis-drol commented 3 years ago

Thanks for the feedback and that you find it useful 😄

Actually my plan is at some point to write a DMI weather integration for HA with pollen and other sensors as DMI are rolling out its open data API. But not everything has been opened up yet and i am currently working on other projects. So i have put it on hold for now.

The API actually gives me the information in a list as you want, i just format it into a python dict/json format as this was what i was looking for. It should not be difficult to add a simple option to just get the list instead. 😄

htvekov commented 3 years ago

I'll probably look into your code and see if I can rewrite a bit. Not at all a Python guy, but I don't believe that it can be that difficult. Would be much easier for me, if HA had an XML parser available 😉

Anyway I have what I need, and can tweak output. Just looked for a more elegant solution.

So this issue is not really an issue - more just to say thank you for the component 😁

DurgNomis-drol commented 3 years ago

Remember to share your result. 🚀