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;)
I think you were close. I think this works. Give it a go…
multiscrape:
- resource: https://www.melbournepollen.com.au/
scan_interval: 3600 #3600 sec = 1 hr
name: Pollen Forecast
sensor:
- unique_id: northern_country_forecast_today
name: Pollen Forecast Today
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(6) > div:nth-child(2) > div'
value_template: '{{ value| trim}}'
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 %}
You do it like this…
that worked! thank you!
Thanks I thought I was doing something wrong but it was as simple as making it
select: ‘#plevel’
If anyone wants to test my new custom integration, PM me for details once you’ve read the Github details. Cheers.
I have tried to install on my test system and as the doco states the api is optional I left it blank and I get this error:
What should I put here ??
I suspect you need to remove the whole url_api rather than leave it blank. If you can confirm that is the case I’ll either clarfiy in the docs or make the code more forgiving.
Edit: I’ve updated the docs for now as I’m relatively sure that’s what’s happened…
I commented out that line and it passes the config check but I get this in the log:
My config is:
sensor:
- platform: oz_poll
url_website: https://www.canberrapollen.com.au/
# url_api:
i_subscribe_and_support: false
2023-11-05 19:55:12.911 ERROR (MainThread) [homeassistant.components.sensor] Error while setting up oz_poll platform for sensor
Traceback (most recent call last):
File "/usr/src/homeassistant/homeassistant/helpers/entity_platform.py", line 359, in _async_setup_platform
await asyncio.shield(task)
File "/usr/local/lib/python3.11/concurrent/futures/thread.py", line 58, in run
result = self.fn(*self.args, **self.kwargs)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/config/custom_components/oz_poll/sensor.py", line 40, in setup_platform
add_entities([OzPollSensor(url_website, url_api, i_subscribe_and_support)])
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/config/custom_components/oz_poll/sensor.py", line 52, in __init__
self.update()
File "/config/custom_components/oz_poll/sensor.py", line 68, in update
).get_text(strip=True)
^^^^^^^^
AttributeError: 'NoneType' object has no attribute 'get_text'
OK, I think I missed a step in the installation but when I try to add the oz Poll integration I get this error:
I think it may be due to you using the Canberra site. I didn’t actually do any testing for Canberra yet.
Could you please confirm if this works ok for you?
That should help confirm it’s just a related Canberra issue and then I’ll see what I can do.
sensor:
- platform: oz_poll
url_website: https://www.melbournepollen.com.au/
# url_api:
i_subscribe_and_support: false
I think it’s because it’s looking for some info that doesn’t exist on the Canberra page and it doesn’t handle that properly.
The Melbourne site works fine.
Ok I think I know what’s going on. Just my crappy error handling. I should have time tommorrow or Tue to take a look at it. I’ll do more testing for Canberra. I’ll do a new release and ping you when it’s available.
OK thanks. The scrape version is working so no rush.
Hi
New release is out with Canberra fixes (issue actually would have affected other locations too).
Let me know how you get on.
I’ll also PM you about api options.
Great HACS integration. Love it. I use this sensor in my config.yaml and it works fine with Melbourne. I’m not really a coder so I don’t know how to create a sensor the astha warnings? Any advice would be greatly appreciate. Cheers.
You can create your own sensors as required by navigating down the attribute tree to specific values (admittedly the example below is a little complex with the use of selectattr() and map().
Paste this into Developer Tools > Template
{{
(states['sensor.oz_poll_allergy_forecast'].attributes.allergy_forecast_web.asthma_data_regional_today.regional_data| selectattr('region', 'equalto', 'Central') | map(attribute='value') | first)
}}
Have a play around…
(states['sensor.oz_poll_allergy_forecast'].attributes.allergy_forecast_web.asthma_data_regional_today.regional_data[1])
{
"region": "East Gippsland",
"value": "Low"
}
Then you can use it in a sensor like this:|
sensor:
- platform: template
sensors:
central_asthma_risk:
friendly_name: Central Asthma Risk
value_template: >-
{{
(states['sensor.oz_poll_allergy_forecast'].attributes.allergy_forecast_web.asthma_data_regional_today.regional_data| selectattr('region', 'equalto', 'Central') | map(attribute='value') | first)
}}
What is the best way to update ??
Do you get a little update banner when you head into HACS? Follow that.