Australian Weather Forecast using BOM Public FTP

I can if no one else wants too…although I’ve only been teaching myself python recently so there may be more experienced people out there

Yeah uses mostly BOM data for weather just using the Darksky icons for visual.

Thanks for your efforts @jimpower. Finally got it working. Made a few changes to reflect my own personal weather station for the current conditions, but so far it’s working great!!!

1 Like

I’ll start with a disclaimer: I’m a rank amateur at both python and github :open_mouth:

I’ve created a fork/branch (I think) of Brendan’s great code to make a couple of minor changes so I thought I’d let you know in case it is of interest to anyone:

  • I’ve added a mode option (as mentioned earlier by Brendan) for enabling friendly/separate/all generation
  • I’ve added a ‘text_if_no_value’ option to control what is returned if no BOM value is available as ‘n/a’ looked out of place for what I wanted to do
  • I’ve removed the ‘friendly’ option (replaced by mode). This doesn’t seem to break anything but your results might be a little different until you configure mode
  • Limit the length of the detailed_summary to 255 characters

Once Brendan is back on board after house moves, etc. I’ll try and merge my changes back into his project if he thinks they are useful (I might need his help with the merge/etc).

For now, you can find my branch/fork/whatever it’s called at https://github.com/JstnMrshll/bom_forecast
Feel free to ignore if this is of no use to you :slight_smile:

UPDATE: I’ve just:

  • Added monitored conditions for fire_danger and uv_alert (just for you @enzymes). Note that the data only seems to contain these values for the current day forecast so you will need to set ‘rest_of_today: true’
  • Fixed the date/time returned for the issue time. It was returning the expected date/time of the next forecast
5 Likes

@BrendanMoran added me as an owner to the repository on github, actually there was a fix for the 255 character issue that I forgot to merge. This is now merged in the main master branch.

@JustinM Did you want to create a pull request for your other changes and I can review merging them into the master branch?

3 Likes

@JustinM I’ve merged your fork into dev branch of the main project. Just had to resolve a couple conflicts as we both had changes to limit length of detailed_summary to 255 character.

Will test it out and if all good will merge into master branch.

Thanks for your help :slight_smile:

3 Likes

@so3n Thanks for grabbing the changes I made. Hopefully they pass your testing and will make it through.

Glad I was able to contribute to this great addition to HA :+1:

2 Likes

Terrific job! Thanks so much!

1 Like

Great thinking to have the friendly /all output options too :grin:

1 Like

Thought I’d post this small mod I made to the lovelace weather card to get a bit more detail for today and tomorrow. But you could build up whatever you like with a template.

todayTommorrow

In config under sensor:

  - platform: template
    sensors:
      today_tommorrow_weather_summary:
        friendly_name: 'Today & Tommorrow Weather Summary'
        value_template: "Today: {{states.sensor.bom_forecast_melbourne_0.state}} {{-'\n'}} Tomorrow: {{states.sensor.bom_forecast_melbourne_1.state}}"

Then just use in for your entity_daily_summary:

    cards:
      - type: custom:dark-sky-weather-card
        entity_sun: sun.sun
        entity_daily_summary:  sensor.today_tommorrow_weather_summary
        entity_current_conditions: sensor.dark_sky_icon
        entity_humidity: sensor.humidity_158d0001b92424
        entity_pressure: sensor.pressure_158d0001b92424
        entity_temperature: sensor.temperature_158d0001b92424
        entity_visibility: sensor.dark_sky_visibility
        entity_wind_bearing: sensor.bom_wind_bear
        entity_wind_speed: sensor.bom_wind_sp
        entity_forecast_high_temp_1: sensor.bom_melbourne_spilt_max_temp_c_1
        entity_forecast_high_temp_2: sensor.bom_melbourne_spilt_max_temp_c_2
        entity_forecast_high_temp_3: sensor.bom_melbourne_spilt_max_temp_c_3
        entity_forecast_high_temp_4: sensor.bom_melbourne_spilt_max_temp_c_4
        entity_forecast_high_temp_5: sensor.bom_melbourne_spilt_max_temp_c_5
        entity_forecast_low_temp_1: sensor.bom_melbourne_spilt_min_temp_c_1
        entity_forecast_low_temp_2: sensor.bom_melbourne_spilt_min_temp_c_2
        entity_forecast_low_temp_3: sensor.bom_melbourne_spilt_min_temp_c_3
        entity_forecast_low_temp_4: sensor.bom_melbourne_spilt_min_temp_c_4
        entity_forecast_low_temp_5: sensor.bom_melbourne_spilt_min_temp_c_5
        entity_forecast_icon_1: sensor.dark_sky_icon_1
        entity_forecast_icon_2: sensor.dark_sky_icon_2
        entity_forecast_icon_3: sensor.dark_sky_icon_3
        entity_forecast_icon_4: sensor.dark_sky_icon_4
        entity_forecast_icon_5: sensor.dark_sky_icon_5
4 Likes

Hi All,

Can someone please help me to extract the possible_rainfall for a specific day from the forecast entity?

I tried the below but it doesn’t work and templates are not my strong point by any means.

value_template: "{{ states.sensor.bom_forecast_perth_weather_forecast_0.attributes.possible_rainfall }}"

Hi there, just update your code and for some reason only getting the current day showing, days 2-5 don’t show now. Dropped it back to show 3 days and still the same issue. Just the current day showing. Anything obvious I could be missing?.. Thanks!
Untitled

Example of what is in the logs

2018-12-04 11:01:20 ERROR (MainThread) [homeassistant.core] Error doing job: Task exception was never retrieved
Traceback (most recent call last):
File “/srv/homeassistant/lib/python3.6/site-packages/homeassistant/helpers/entity_platform.py”, line 352, in _async_add_entity
await entity.async_update_ha_state()
File “/srv/homeassistant/lib/python3.6/site-packages/homeassistant/helpers/entity.py”, line 232, in async_update_ha_state
state = self.state
File “/home/homeassistant/.homeassistant/custom_components/sensor/bom_forecast.py”, line 354, in state
friendly_state = friendly_state.replace(’{{{}}}’.format(condition), self._bom_forecast_data.get_reading(condition, self._index))
File “/home/homeassistant/.homeassistant/custom_components/sensor/bom_forecast.py”, line 398, in get_reading
detailed_summary = self._data.find(_FIND_QUERY_2.format(index, SENSOR_TYPES[condition][0])).text
AttributeError: ‘NoneType’ object has no attribute ‘text’

@sparkydave This should work:

"{{ state_attr('sensor.bom_forecast_perth_weather_forecast_0', 'Possible Rainfall') | replace("mm", "") | float }}"

If you’re using the dev branch from github, you will need to update your configuration.yaml file as per the readme.

Off memory you need to replace friendly configuration item with mode and pick one of the 3 options.

@tom_l champion! that seems to work in my template dev tool so I’ll give it a try in my code. Thanks

Thanks for the response. So the friendly mode only creates the current sensor for that day? Not up to five as it was before? I prefer the friendly view, but this is no good if it is just one day at a time. Cheers

No you still should get the number of days you specify in configuration.yaml

Here’s mine as an example, although for mode I’m using all (both friendly and separated sensors)

- platform: bom_forecast
  product_id: IDV10450
  name: Melbourne
  forecast_days: 5
  rest_of_today: True
#   friendly: False
  mode: all
  friendly_state_format: '{max}, {summary}'
  text_if_no_value: 'N/A'
  monitored_conditions:
    - 'max'
    - 'min'
    - 'chance_of_rain'
    - 'possible_rainfall'
    - 'summary'
    - 'detailed_summary'

conf

Unusual then

Not sure, only thing I would suggest is having a look in ‘states’ under developer tools in home assistant frontend to check if the sensor names got renamed

I just tried it. Works for me with this config:

- platform: bom_forecast
  product_id: IDT13600
  name: Hobart
  forecast_days: 6
  rest_of_today: True
  mode: friendly
  friendly_state_format: '{min} to {max}, {summary}, {chance_of_rain} chance of {possible_rainfall} rain'
  text_if_no_value: '-'
  monitored_conditions:
    - 'max'
    - 'min'
    - 'chance_of_rain'
    - 'possible_rainfall'
    - 'summary'
    - 'detailed_summary'

@grantc, check the contents of your \config\custom_components\sensor\bom_forecast.py file. Depending on how you downloaded it from github the format can be messed up. Best way is to use the green clone or download button and download a zip archive.

@so3n, any idea how I can get a line feed in my friendly state format?