I’m in Melbourne and find using Yahoo, Dark Sky and others weather components give really poor weather forecasts for Australian cities.
So I’ve used the scape sensor to pull data from http://www.bom.gov.au/vic/forecasts/melbourne.shtml
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.
Morning notification
Evening notification
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') }}"