Australian Weather Forecast using BOM Public FTP

Thanks for the apology and I’ll take it as a compliment that you thought it was a standard component. All good.

3 Likes

@petro really rocks and he is absolutely awesome with templates and stuff. Can’t speak too highly of him. Misunderstandings abound. Group hug guys!

Awesome work here too Brendan. I’m not blocked on BOM and I changed the scan interval to a couple of hours just in case but if I do get blocked I’ll be using this then. Thanks.

1 Like

So here’s my final script for telling me the weekends weather forecast, thanks to help from the above posts.

Because I have my friendly format set up like this in my config

friendly: True
friendly_state_format: '{min} to {max} degrees. {chance_of_rain} chance of rain. {summary}'

Then I just put this script in my rising/sleep routines to get a weekend forecast from Wed to Fri.

forecast_this_weekend:
  sequence:
  - condition:
    condition: template
    value_template: "{{now().weekday() > 1 and now().weekday() < 5}}"
  - service: notify.google_assistant
    data_template:
      message: On Saturday, the weather summary is {{ states.sensor['bom_forecast_melbourne_{}'.format(5 - now().weekday())].state }} On Sunday, the weather summary is {{ states.sensor['bom_forecast_melbourne_{}'.format(6 - now().weekday())].state }}

I’ve only done some basic testing, coz I’m and in a bit of a rush + testing is a little harder on the weekend, but it seems to be doing the job of announcing the weather over my Google Home (via Google Assistant Webserver).

Thanks again @tom_l & @petro.

1 Like

Jinja has the power to make this work (also easier to read):

  - condition:
    condition: template
    value_template: "{{ 1 < now().weekday() < 5 }}"

Oh yeah, that’s way more concise/elegant. Forgot about that year 10 math syntax! Ta.

1 Like

Hey, I’m starting to tinker with Lovelace UI, and the weather cards are pretty nice. From what I understand your source needs to be be a “weather component” rather than “sensors”. Any thoughts on feasibility/effort/demand/value of changing or forking this as a weather component? I really dunno how that all works, just testing the waters… Lovelace UI Weather Forecast

Edit: Maybe I need to read some of the other threads on the topic a bit more carefully, I think there may be a way… I’ll look closer later, but will leave the post for thought fodder.

Another edit: It didn’t look so straight forward, so I’ve given up on it for the moment.

I’m flat out with work and family for the next 2 months or so (moving house, plus a baby and a toddler running around) so I am going to have to put updates to this custom component on hold for a while.

3 Likes

Hi Brendan, just FYI, my log is being flooded with these errors:

Error doing job: Task exception was never retrieved

Traceback (most recent call last):
  File "/usr/local/lib/python3.6/site-packages/homeassistant/helpers/entity.py", line 312, in async_update_ha_state
    self.entity_id, state, attr, self.force_update, self._context)
  File "/usr/local/lib/python3.6/site-packages/homeassistant/core.py", line 903, in async_set
    context)
  File "/usr/local/lib/python3.6/site-packages/homeassistant/core.py", line 673, in __init__
    "State max length is 255 characters.").format(entity_id))
homeassistant.exceptions.InvalidStateError: Invalid state encountered for entity id: sensor.bom_hobart_tomorrow_detailed_summary_1. State max length is 255 characters.

Might have to limit the length of the scraped data when you get a chance to have a look at this again.

Hey @BrendanMoran that’s fantastic and way better than my scrape version! It worked straight away for me using hassio :grinning:

Any chance you could add fire_danger and uv_alert as additional fields? That’d be ace :sunglasses:

Firstly, a huge kudos to @BrendanMoran for developing this sensor. I’d started something like this a couple of months ago but couldn’t have achieved what Brendan has (as I have no prior Python experience) so thanks for all of your efforts Brendan.

One of the main things I wanted to achieve was to see if there was rainfall predicted in the next few days so that I could prevent my HA controlled sprinklers from coming on.
When I first tried Brendan’s sensor, it allows a great display with the friendly sensors but to use the min_max sensor to get the highest level of predicted rainfall, I needed easy access to the chance_of_rain value which is difficult as an attribute. So I made a mod to this sensor to allow both the friendly and separate sensors to be created at the same time rather than having one or the other.

If it is of use to anyone else, I’ll try and figure out how to submit the change to GitHub for inclusion in Brendan’s sensor.

HI Justin,

Sounds like a really useful addition. Now what are you like at pulling out the uv_alert and fire_danger fields?

:smile:

Good news every body, I have some free time over the next few days so will look at releasing:

  • uv index forecast
  • fire danger rating forecast (I feel like @enzymes life may be in danger if I don’t do this before fire season :smile:)
  • mode: friendly | sensor | all (will be a breaking change)
  • fix oversized string length for detailed forecast
  • fix formatting of attributes to not have spaces
6 Likes

Hey Brendan - awesome to hear you are doing more with this - thanks!

really enjoying the active development on this one, Brendan…

would be awesome to see it added in as a core component!

1 Like

Thank you @BrendanMoran very exciting :grinning:

I can help you with this if you are still interested

Yes @jimpower I’m still dead keen.

I don’t know if you can do something like attempted in this thread:

I don’t have any python skills, so converting the whole thing from a sensor to a weather entity is currently well out of my league (if that is a valid approach?). If it could be done with templates like in the link, I could help with leg-work.

@Mahko_Mahko

To get this

image

you will need to add the following to your config.

  1. Custom Darksky Animated Weather Card

  2. Bom Weather Component

     weather:
       - platform: bom
         station: IDQ60801.94592
         name: Gold Coast
         monitored_conditions:
           - apparent_t
           - cloud
           - cloud_base_m
           - cloud_oktas
           - cloud_type_id
           - cloud_type
           - delta_t
           - gust_kmh
           - gust_kt
           - air_temp
           - dewpt
           - press
           - press_qnh
           - press_msl
           - press_tend
           - rain_trace
           - rel_hum
           - sea_state
           - swell_dir_worded
           - swell_height
           - swell_period
           - vis_km
           - weather
           - wind_dir
           - wind_spd_kmh
           - wind_spd_kt
    
  3. Breakout the Attributes of the above weather component with some templates

       - platform: template
         sensors:
           bom_temp:
             friendly_name: "Gold Coast Temperature"
             value_template: "{{ states.weather.bom_gold_coast.attributes.temperature }}"
             device_class: temperature
             unit_of_measurement: °C
             
           bom_humd:
             friendly_name: "Gold Coast Humidity"
             value_template: "{{ states.weather.bom_gold_coast.attributes.humidity }}"
             #device_class: humidity
             unit_of_measurement: '%'
             
           bom_wind_sp:
             friendly_name: "Gold Coast Wind Speed"
             value_template: "{{ states.weather.bom_gold_coast.attributes.wind_speed }}"
             #device_class: temperature
             unit_of_measurement: km
             
           bom_wind_bear:
             friendly_name: "Gold Coast Wind Bearing"
             value_template: "{{ states.weather.bom_gold_coast.attributes.wind_bearing }}"
             #device_class: temperature
             #unit_of_measurement: km
             
           bom_pres:
             friendly_name: "Gold Coast Pressure"
             value_template: "{{ states.weather.bom_gold_coast.attributes.pressure }}"
             #device_class: temperature
             unit_of_measurement: hPa
    
  4. Add this to your lovelace configuration for the Custom Darksky Weather

     -  type: custom:dark-sky-weather-card
        entity_sun: sun.sun
        entity_daily_summary: sensor.bom_gc_forecast_detailed_summary_0
        entity_current_conditions: sensor.dark_sky_icon
        entity_humidity: sensor.bom_humd
        entity_pressure: sensor.bom_pres
        entity_temperature: sensor.bom_temp
        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_gc_forecast_max_temp_c_1
        entity_forecast_high_temp_2: sensor.bom_gc_forecast_max_temp_c_2
        entity_forecast_high_temp_3: sensor.bom_gc_forecast_max_temp_c_3
        entity_forecast_high_temp_4: sensor.bom_gc_forecast_max_temp_c_4
        entity_forecast_high_temp_5: sensor.bom_gc_forecast_max_temp_c_5
        entity_forecast_low_temp_1: sensor.bom_gc_forecast_min_temp_c_1
        entity_forecast_low_temp_2: sensor.bom_gc_forecast_min_temp_c_2
        entity_forecast_low_temp_3: sensor.bom_gc_forecast_min_temp_c_3
        entity_forecast_low_temp_4: sensor.bom_gc_forecast_min_temp_c_4
        entity_forecast_low_temp_5: sensor.bom_gc_forecast_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
    

entire package can be found here Weather Package

5 Likes

Awesome. Thankyou very much @jimpower. I’ll probably implement in the next few days and confirm it’s working for me.

1 Like

@jimpower , I’m struggling a bit…

I get this error when I try to load the lovelace ui:

2018-11-04 15:56:57 ERROR (MainThread) [frontend.js.latest.201810264] https://192.168.1.117:8123/local/dist/dark-sky-weather-card.js:17:43 Uncaught TypeError: Cannot read property ‘unit_system’ of undefined

From what I understand, this means the card probably isn’t “seeing” all the entities it is expecting? I did test that each card reference is returning data in the template tool, and they all seem to be operational. Here’s the steps I’ve taken.

Copied the .js straight from here ( Custom Dark Sky Animated Weather Card) and dropped it here
\HASSIO\config\www\dist\dark-sky-weather-card.js

That’s worked fine for another custom card I have, so I assume that’s working ok…

Added bom under weather like this (seems to be working fine)

weather:
  - platform: bom
    station: IDV60901.95936
    name: Melbourne
    monitored_conditions:
       - apparent_t
       - cloud
       - cloud_base_m
       - cloud_oktas
       - cloud_type_id
       - cloud_type
       # - delta_t
       - gust_kmh
       - gust_kt
       - air_temp
       - dewpt
       - press
       - press_qnh
       - press_msl
       - press_tend
       - rain_trace
       - rel_hum
       - sea_state
       - swell_dir_worded
       - swell_height
       - swell_period
       - vis_km
       - weather
       - wind_dir
       - wind_spd_kmh
       - wind_spd_kt

added darksky under sensor like this (seems to be working fine)

sensor:
  - platform: darksky
    api_key: !secret darksky
    forecast:
      - 1
      - 2
      - 3
      - 4
      - 5
    monitored_conditions:
      - icon
      - summary
      - nearest_storm_distance
      - nearest_storm_bearing
      - humidity
      - temperature
      - temperature_high
      - temperature_low
      - apparent_temperature
      - apparent_temperature_high
      - apparent_temperature_low
      - wind_speed
      - wind_bearing
      - precip_type
      - precip_probability
      - precip_accumulation
      - precip_intensity
      - precip_intensity_max
      - uv_index
      - daily_summary
      - pressure
      - visibility
    update_interval:
      minutes: 60

While I also tried splitting out the attributes like you suggested, I’m trying to use data from my local xiaomi sensors for current conditions (the xiaomi sensors are working fine) in place of the template sensors.

So in my ui-lovelace.yaml I have:

added a resource:

resources:
  - url: /local/dist/dark-sky-weather-card.js
    type: js

and added a card like this:

  - id: 3  # Automatically created id
    title: Climate
    icon: mdi:thermometer-lines
    cards:
      - type: custom:dark-sky-weather-card
        entity_sun: sun.sun
        entity_daily_summary: sensor.bom_melbourne_spilt_summary_0
        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

Does anything immediately jump out as overlooked or an issue? Any suggestions?
Greatly appreciated.