OzPoll - Australian Pollen Forecast (Integration)

Actually I think you may just need to switch from app=1 to app=2. You may need to try different version= too.

https://api.pollenforecast.com.au/app/json/app_data.php?app=2&version=4

Apparently I’d figured this out before but had forgotten!)

OK, thanks, I’ll have a play.

1 Like

I seem to be seeing differences between the api and the app/website.

Not sure if it is really working this season. Need to investigate. Would be good if others confirm too.

I changed up the code to match latest HA standards:

    - name: Melbourne Pollen Forecast via API
      state: ''
      attributes:
        melbourne_6day_pollen_forecast: >-
          {% set forecastpageHTML = states.sensor.melbourne_pollen_api_html.attributes.forecastpage %}
          {% set LowerForecastpageHTML = forecastpageHTML|lower  %}
          {{ 
          '{\n' +
          LowerForecastpageHTML
          |replace('monday', 'Mon')
          |replace('tuesday', 'Tue')
          |replace('wednesday', 'Wed')
          |replace('thursday', 'Thu')
          |replace('friday', 'Fri')
          |replace('saturday', 'Sat')
          |replace('sunday', 'Sun')
          |replace('melbourne pollen forecast', '"days": [')
          |replace('<h2 ', '*nl*{*nl*"day_short_name":"<h1 ')
          |replace('</h2>', '</h2>",*nl* ')
          |replace('<p', '"date":"<p')
          |replace('p>', '<\/p>",*nl* ')
          |replace('<div class="pollen-forecast-level', '"pollen_level":"<<div class="pollen-forecast-level')
          |replace('low', 'Low"},')
          |replace('moderate', 'Moderate"},')
          |replace('high', 'High"},')
          |replace('extreme', 'Extreme"},')
          |striptags
          |replace('*nl*', '\n') + ']\n}'
          }} 

The sensor is showing LOW for Wednesday even though its HIGH:

The only LOW reading is east gippsland:

Is there a way to make the state of the sensor TODAY’s forecast only

1 Like

Looks like it might be broken again.

Hopefully I’ll have some time on the weekend to work on a fix.

So the unoffcial API these sensors use no longer appears to be being updated.
So it’s an API issue beyond my control rather than a code issue.

I’m digging around for alternative data sources but haven’t been able to find anything yet.

For those that are keen you could try to resurrect the webpage scraper approach to get just today’s info from the webpage (code may need modifications).

Validating the API results against the app show that the api results appear to be incorrect (always showing “Low”.

FYI @oneseventhree

Ahh thats a shame. I did see there is a version 6 now:
https://api.pollenforecast.com.au/app/json/app_data.php?app=2&version=6

I was using this:

 scan_interval: 3600 #3600 sec = hr
  name: Pollen Forecast
  sensor:
    - unique_id: melbourne_pollen_count
      name: Pollen Count
      select: '#district-pollen-div > div > div > div > div > div > div.uk-grid-match.uk-child-width-1-2\@s.uk-text-center.uk-grid-collapse.uk-grid > div:nth-child(2) > div:nth-child(1) > div:nth-child(2) > div'
      value_template: '{{ value| trim}}'
      attributes:
        - name: Website Last Updated
          select: '#district-pollen-div > div > div > div > div > div > div.uk-grid-match.uk-child-width-1-2\@s.uk-text-center.uk-grid-collapse.uk-grid > div:nth-child(1) > div.ta-notice'
          value_template: "{{ value| replace('Last updated:', '')}}"
      icon: >-
        {% if value == 'Low' %}
          mdi:emoticon-happy
        {% elif value == 'Moderate' %}
          mdi:emoticon-neutral
        {% elif value == 'High' %}
          mdi:emoticon-sad
        {% elif value == 'Extreme' %}
          mdi:emoticon-angry
        {% else %}
          mdi:help-circle
        {% endif %}

but its showing central and not:

Is there anyway to scrape that section instead?
I tried and couldn’t figure it out when trying to put it in the code above

Yeah I looked at version 6 too but same story.

I’ll probably look at getting the Melbourne scrape running for myself over the coming days, so I’ll keep you posted.

that would be great! thank you. The website hasn’t changed in a while so it should last :slight_smile:

Had to fiddle with the select but think I’ve got the following data fields.

multiscrape:
############################################################################
#Melbourne Pollen Forecast
###########################################################################
  - resource: https://www.melbournepollen.com.au/
    scan_interval: 3600 #3600 sec = 1 hr
    name: Pollen Forecast
    sensor:
      - unique_id: pollen_forecast_today_melbourne_grass
        name: Pollen Forecast Today Melbourne Grass 
        select: '#plevel'
        value_template: '{{ value| trim}}'
        attributes:
          - name: Forecast Date
            select: '#pdate.pollen-date'
            value_template: '{{ value| trim}}'
            # value_template: "{{ value| replace('Last updated:', '')}}"
          - name: Website Last Updated 
            select: '#district-pollen-div > div > div > div > div > div > div.uk-grid-match.uk-child-width-1-2\@s.uk-text-center.uk-grid-collapse.uk-grid > div:nth-child(1) > div.ta-notice'
            value_template: "{{ value| replace('Last updated:', '')}}"
        icon: >-
          {% if value == 'Low' %}
            mdi:emoticon-happy
          {% elif value == 'Moderate' %}
            mdi:emoticon-neutral
          {% elif value == 'High' %}
            mdi:emoticon-sad
          {% elif value == 'Extreme' %}
            mdi:emoticon-angry
          {% else %}
            mdi:help-circle
          {% endif %}

Seems to work for me! Thanks for the quick response. Hopefully we can test it out soon when the warmer weather comes!

1 Like

The “card” for this still seems to work too. Just adjust the sensor and attribute names in the Lovelace config.

1 Like

Edit: in reference to the screen scraping approach

Since the Melbourne area has its own little carve out and isn’t in that large table, how would I grab the values from the first tile that appears on the page? I think it’s represented there?

Did you have a crack at this for it?

I have a whole new approach cooking but it probably won’t be ready to share for a few weeks.

Oh hang on, did you see this?

1 Like

Hey Guys, really well done on figuring this out!

Is there any chance you could please help me with scrapping data for Northern Country?

Thank you,

Sure. What have you tried so far?

well, I couldn’t figure out how
I’m not a web dev but to me, I thought this page was dynamic with js code to load first the city in the widget.

this is what I tried but I cant get it to work from the image to the side of the NORTHERN COUNTRY

sensor:
  - platform: rest
    resource: https://www.melbournepollen.com.au/ 
    name: Northern Country Pollen Level
    scan_interval: 3600 
    value_template: '{{ value_json.pollen_level }}'
    json_attributes:
      - pollen_level
    selector: "#district-pollen-div > div > div > div > div > div > div.uk-grid-match.uk-child-width-1-2\@s.uk-text-center.uk-grid-collapse.uk-grid > div:nth-child(2) > div:nth-child(6)"

Canberra version is working with just a change to resource, the site does not have a ‘last updated’ entry so I have commented that out.

I should have something fancy for you in the next few weeks. Stay tuned;)