I’ve been testing it for a couple of weeks and it is working okay. I get
Forecast maximum and minimum
UV forecast (UV index and times to avoid the sun)
Fire danger
I get a notification on my phone in the morning day’s forecast and evening with the evening and next day’s forecast, plus a group on the Home Assistant dashboard.
I haven’t quite figured out all of the ins and outs of scape, there’s no doubt a more sophisticated way to search for specific tags within the HTML. This has been working so far, but would welcome some more input.
Here’s my code, which is split across group.yaml, sensor.yaml and automation.yaml
For local current temperatures, I’ve used Open Weather Map to pick up a nearby weather station, using sensors like sensor.owm_temperature
# Group - in my group.yaml
weather:
name: "Weather"
view: yes
entities:
- sensor.melbourne_maximum
- sensor.melbourne_minimum
- sensor.melbourne_summary
- sensor.melbourne_uv_forecast
- sensor.melbourne_forecast_line3
# Sensor - in my sensor.yaml
# Scrape sensor for BOM weather forecasts
# Using scrape component to grab some HTML and put it in a value
# Follow guide at https://www.crummy.com/software/BeautifulSoup/bs4/doc/#css-selectors
- platform: scrape
resource: http://www.bom.gov.au/vic/forecasts/melbourne.shtml
name: Melbourne maximum
select: '.max'
unit_of_measurement: 'Max °C'
- platform: scrape
resource: http://www.bom.gov.au/vic/forecasts/melbourne.shtml
name: Melbourne minimum
select: '.min'
unit_of_measurement: 'Min °C'
- platform: scrape
resource: http://www.bom.gov.au/vic/forecasts/melbourne.shtml
name: Melbourne summary
select: 'p:nth-of-type(4)'
# unit_of_measurement: 'Nil'
- platform: scrape
resource: http://www.bom.gov.au/vic/forecasts/melbourne.shtml
name: Melbourne UV forecast
select: 'p:nth-of-type(5)'
# unit_of_measurement: 'Nil'
- platform: scrape
resource: http://www.bom.gov.au/vic/forecasts/melbourne.shtml
name: Melbourne forecast line3
select: 'p:nth-of-type(6)'
# unit_of_measurement: 'Nil'
- platform: openweathermap
api_key: !secret openweathermap_api_key
forecast: 0
monitored_conditions:
- weather
- temperature
- wind_speed
- humidity
- pressure
- clouds
- rain
# Automation - in my automation.yaml
- alias: 'Send notification when sun rises'
trigger:
platform: sun
event: sunrise
offset: '+00:30:00'
action:
service: notify.html5
data:
message: "Good morning! Forecast: {{ states('sensor.melbourne_summary') }}, temp {{ states('sensor.melbourne_minimum') }} - {{ states('sensor.melbourne_maximum') }}°c {{ states('sensor.melbourne_uv_forecast') }} Next line: {{ states('sensor.melbourne_forecast_line3') }} Now: {{ states('sensor.owm_temperature') }}°c {{ states('sensor.owm_condition') }}, {{ states('sensor.owm_rain') }}"
- alias: 'Send notification when sun sets'
trigger:
platform: sun
event: sunset
offset: '+00:00:00'
action:
service: notify.html5
data:
message: "The sun has set. Forecast: {{ states('sensor.melbourne_summary') }}, temp {{ states('sensor.melbourne_minimum') }} - {{ states('sensor.melbourne_maximum') }}°c Now: {{ states('sensor.owm_temperature') }}°c {{ states('sensor.owm_condition') }}, {{ states('sensor.owm_rain') }}"
I’m going to have a go at displaying the wind data from bom point wilson aws (no temp avail)
and the temp and wind from the wunderground clifton springs pws as there isnt a sensor close to portarlington. I can let you know if its successful if anyone has an interest
I was hoping someone else would answer because I don’t really know @Will711990, I found that through trial and error and I am guessing it’s the first instance of .pop in the scrape. It seems to be correct for current day. I am sure the guys here who know what they are doing will .pop back in eventually. The 'p:nth-of-type… in the other scrape sensors here seems to be likely scraping through instances of data so I’d probably start googling from there.
By the way, the data returned for chance of rain includes a “%” sign which mucks up the HaDashboard display if your using it. You can get around it with a value template, I also use same sort of thing for converting the temperature to a whole number for TTS purposes so it doesn’t announce the temperature as “twenty six” “seven two” degrees.
I can’t be arsed converting to the thread standard Melbourne config today so straight copy paste.
Hi all, just wondering how you guys are using this method for scraping the summary forecasts now there is a limit on the number of characters in the sensor state? I get errors trying to scrape the longer summaries now in version 0.57. Sensor state is limited to 255 characters (https://github.com/home-assistant/home-assistant/pull/9696)