Customising the BOM Weather and lovelace - now in HACS

See my post here Customising the BOM Weather and lovelace - now in HACS to add this to HACS.

I finally got sick of having a dark-sky as well as a BOM component and having a mish-mash of cards that incorporated both.
Specifically I am using:

With some modifications… There is an un-documented monitored condition called icon. I also edited the custom component sensor.py file to add the standard BOM conditions according to their ADFD User Guide.pdf file.
My modified custom component can be downloaded from my github page here https://github.com/DavidFW1960/home-assistant/tree/master/custom_components/bom_forecast

I also downloaded the BOM ‘official’ icons and they are all here https://github.com/DavidFW1960/home-assistant/tree/master/www/icons/bom_icons individually or bom_icons.zip in the same location.

Next, I am using the dark-sky weather card from here

But I had to make some edits so it would use the bom weather conditions etc. I did edit the dark-sky-weather-card.js and made my own called bom-weather-card.js which you can find here:
https://github.com/DavidFW1960/home-assistant/tree/master/www/custom_ui

Lastly, I have my weather package here

sensor:
  - platform: bom
    station: !secret my_bom_station
    name: !secret my_bom_name
    monitored_conditions:
      - apparent_t
      - delta_t
      - gust_kmh
      - gust_kt
      - air_temp
      - dewpt
      - rain_trace
      - rel_hum
      - wind_dir
      - wind_spd_kmh
      - wind_spd_kt

  - platform: bom_forecast
    product_id: !secret my_bom_product_id
    name: !secret my_bom_name
    forecast_days: 6
    rest_of_today: true
    friendly: false
    friendly_state_format: '{max}, {summary}'
    monitored_conditions:
      - 'max'
      - 'min'
      - 'chance_of_rain'
      - 'possible_rainfall'
      - 'summary'
      - 'detailed_summary'
      - 'icon'
      bom_current_text:
        value_template: >
            {% set val = states("sensor.bom_gosford_detailed_summary_0") %} 
            {{ val.split('.')[0] | title }}

      bom_forecast_0:
        entity_id:
          - sensor.bom_today_max
          - sensor.bom_today_min
          - sensor.bom_gosford_chance_of_rain_0
          - sensor.bom_gosford_icon_0
        friendly_name: "Today"
        value_template: >
          {{states('sensor.bom_today_max')|round(0)}}°/{{states('sensor.bom_today_min')|round(0)}}°/{{states('sensor.bom_gosford_chance_of_rain_0')|round(0)}}%
        entity_picture_template: >-
          {%- if now().strftime('%H:%M') > '18:00' and (states('sensor.bom_gosford_icon_0') == 'fog' or states('sensor.bom_gosford_icon_0') == 'haze' or states('sensor.bom_gosford_icon_0') == ' light-showers' or states('sensor.bom_gosford_icon_0') == 'partly-cloudy' or states('sensor.bom_gosford_icon_0') == 'showers') -%}
          {{ '/local/icons/bom_icons/' ~ states('sensor.bom_gosford_icon_0') ~ '-night.png' }}
          {%- else -%}
          {{ '/local/icons/bom_icons/' ~ states('sensor.bom_gosford_icon_0') ~ '.png' }}
          {%- endif -%}

      bom_forecast_1:
        entity_id:
          - sensor.bom_gosford_max_temp_c_1
          - sensor.bom_gosford_min_temp_c_1
          - sensor.bom_gosford_chance_of_rain_1
          - sensor.bom_gosford_icon_1
        friendly_name_template: >
          {%- set date = as_timestamp(now()) + (1 * 86400 ) -%}
          {{ date | timestamp_custom("Tomorrow (%d/%m)") | replace("(0", "(") | replace("/0", "/") }}
        value_template: >
          {{states('sensor.bom_gosford_max_temp_c_1')|round(0)}}°/{{states('sensor.bom_gosford_min_temp_c_1')|round(0)}}°/{{states('sensor.bom_gosford_chance_of_rain_1')|round(0)}}%
        entity_picture_template: >-
          {{ '/local/icons/bom_icons/' ~ states('sensor.bom_gosford_icon_1') ~ '.png' }}

      bom_forecast_2:
        entity_id:
          - sensor.bom_gosford_max_temp_c_2
          - sensor.bom_gosford_min_temp_c_2
          - sensor.bom_gosford_chance_of_rain_2
          - sensor.bom_gosford_icon_2
        friendly_name_template: >
          {%- set date = as_timestamp(now()) + (2 * 86400 ) -%}
          {{ date | timestamp_custom("%A (%d/%m)") | replace("(0", "(") | replace("/0", "/") }}
        value_template: >
          {{states('sensor.bom_gosford_max_temp_c_2')|round(0)}}°/{{states('sensor.bom_gosford_min_temp_c_2')|round(0)}}°/{{states('sensor.bom_gosford_chance_of_rain_2')|round(0)}}%
        entity_picture_template: >-
          {{ '/local/icons/bom_icons/' ~ states('sensor.bom_gosford_icon_2') ~ '.png' }}

      bom_forecast_3:
        entity_id:
          - sensor.bom_gosford_max_temp_c_3
          - sensor.bom_gosford_min_temp_c_3
          - sensor.bom_gosford_chance_of_rain_3
          - sensor.bom_gosford_icon_3
        friendly_name_template: >
          {%- set date = as_timestamp(now()) + (3 * 86400 ) -%}
          {{ date | timestamp_custom("%A (%d/%m)") | replace("(0", "(") | replace("/0", "/") }}
        value_template: >
          {{states('sensor.bom_gosford_max_temp_c_3')|round(0)}}°/{{states('sensor.bom_gosford_min_temp_c_3')|round(0)}}°/{{states('sensor.bom_gosford_chance_of_rain_3')|round(0)}}%
        entity_picture_template: >-
          {{ '/local/icons/bom_icons/' ~ states('sensor.bom_gosford_icon_3') ~ '.png' }}

      bom_forecast_4:
        entity_id:
          - sensor.bom_gosford_max_temp_c_4
          - sensor.bom_gosford_min_temp_c_4
          - sensor.bom_gosford_chance_of_rain_4
          - sensor.bom_gosford_icon_4
        friendly_name_template: >
          {%- set date = as_timestamp(now()) + (4 * 86400 ) -%}
          {{ date | timestamp_custom("%A (%d/%m)") | replace("(0", "(") | replace("/0", "/") }}
        value_template: >
          {{states('sensor.bom_gosford_max_temp_c_4')|round(0)}}°/{{states('sensor.bom_gosford_min_temp_c_4')|round(0)}}°/{{states('sensor.bom_gosford_chance_of_rain_4')|round(0)}}%
        entity_picture_template: >-
          {{ '/local/icons/bom_icons/' ~ states('sensor.bom_gosford_icon_4') ~ '.png' }}

      bom_forecast_5:
        entity_id:
          - sensor.bom_gosford_max_temp_c_5
          - sensor.bom_gosford_min_temp_c_5
          - sensor.bom_gosford_chance_of_rain_5
          - sensor.bom_gosford_icon_5
        friendly_name_template: >
          {%- set date = as_timestamp(now()) + (5 * 86400 ) -%}
          {{ date | timestamp_custom("%A (%d/%m)") | replace("(0", "(") | replace("/0", "/") }}
        value_template: >
          {{states('sensor.bom_gosford_max_temp_c_5')|round(0)}}°/{{states('sensor.bom_gosford_min_temp_c_5')|round(0)}}°/{{states('sensor.bom_gosford_chance_of_rain_5')|round(0)}}%
        entity_picture_template: >-
          {{ '/local/icons/bom_icons/' ~ states('sensor.bom_gosford_icon_5') ~ '.png' }}

      bom_forecast_6:
        entity_id:
          - sensor.bom_gosford_max_temp_c_6
          - sensor.bom_gosford_min_temp_c_6
          - sensor.bom_gosford_chance_of_rain_6
          - sensor.bom_gosford_icon_6
        friendly_name_template: >
          {%- set date = as_timestamp(now()) + (6 * 86400 ) -%}
          {{ date | timestamp_custom("%A (%d/%m)") | replace("(0", "(") | replace("/0", "/") }}
        value_template: >
          {{states('sensor.bom_gosford_max_temp_c_6')|round(0)}}°/{{states('sensor.bom_gosford_min_temp_c_6')|round(0)}}°/{{states('sensor.bom_gosford_chance_of_rain_6')|round(0)}}%
        entity_picture_template: >-
          {{ '/local/icons/bom_icons/' ~ states('sensor.bom_gosford_icon_6') ~ '.png' }}

      bom_today_max:
        entity_id:
          - sensor.bom_gosford_max_temp_c_0
          - sensor.today_temp_bom_mean
        value_template: >
          {%- if states('sensor.bom_gosford_max_temp_c_0') == 'n/a' -%} 
            {{ state_attr('sensor.today_temp_bom_mean', 'max_value') }}
          {% else %}
            {{ states('sensor.bom_gosford_max_temp_c_0') }}
          {% endif %}
      bom_today_min:
        entity_id:
          - sensor.bom_gosford_min_temp_c_0
          - sensor.today_temp_bom_mean
        value_template: >
          {%- if states('sensor.bom_gosford_min_temp_c_0') == 'n/a' -%} 
            {{ state_attr('sensor.today_temp_bom_mean', 'min_value') }}
          {% else %}
            {{ states('sensor.bom_gosford_min_temp_c_0') }}
          {% endif %}

  - platform: statistics
    name: today_temp_bom
    sampling_size: 150
    entity_id: sensor.bom_gosford_air_temp_c
    max_age:
      hours: 24

automation:
- alias: 'Update BOM Icons'
  trigger:
    - event: start
      platform: homeassistant
    - platform: time
      at: '18:01:00'
  action:
    - service: homeassistant.update_entity
      entity_id: sensor.bom_forecast_0, sensor.bom_forecast_1, sensor.bom_forecast_2, sensor.bom_forecast_3, sensor.bom_forecast_4, sensor.bom_forecast_5, sensor.bom_forecast_6
	  

Lastly, I have my Lovelace cards for weather here:

      - type: vertical-stack
        cards:
          - type: custom:bom-weather-card
            title: BOM Weather
            entity_current_conditions: sensor.bom_gosford_icon_0
            entity_temperature: sensor.bom_gosford_air_temp_c
            entity_forecast_high_temp_1: sensor.bom_gosford_max_temp_c_1
            entity_forecast_high_temp_2: sensor.bom_gosford_max_temp_c_2
            entity_forecast_high_temp_3: sensor.bom_gosford_max_temp_c_3
            entity_forecast_high_temp_4: sensor.bom_gosford_max_temp_c_4
            entity_forecast_high_temp_5: sensor.bom_gosford_max_temp_c_5
            entity_forecast_icon_1: sensor.bom_gosford_icon_1
            entity_forecast_icon_2: sensor.bom_gosford_icon_2
            entity_forecast_icon_3: sensor.bom_gosford_icon_3
            entity_forecast_icon_4: sensor.bom_gosford_icon_4
            entity_forecast_icon_5: sensor.bom_gosford_icon_5
            entity_forecast_low_temp_1: sensor.bom_gosford_min_temp_c_1
            entity_forecast_low_temp_2: sensor.bom_gosford_min_temp_c_2
            entity_forecast_low_temp_3: sensor.bom_gosford_min_temp_c_3
            entity_forecast_low_temp_4: sensor.bom_gosford_min_temp_c_4
            entity_forecast_low_temp_5: sensor.bom_gosford_min_temp_c_5
            entity_summary_1: sensor.bom_gosford_summary_1
            entity_summary_2: sensor.bom_gosford_summary_2
            entity_summary_3: sensor.bom_gosford_summary_3
            entity_summary_4: sensor.bom_gosford_summary_4
            entity_summary_5: sensor.bom_gosford_summary_5
            entity_sun: sun.sun
#           entity_visibility: sensor.dark_sky_visibility
            entity_daytime_high: sensor.bom_today_max
            entity_wind_bearing: sensor.bom_gosford_wind_direction
            entity_wind_speed: sensor.bom_gosford_wind_speed_kmh
            entity_humidity: sensor.bom_gosford_relative_humidity
#           entity_pressure: sensor.dark_sky_pressure
            entity_apparent_temp: sensor.bom_gosford_feels_like_c
            entity_daily_summary: sensor.bom_gosford_detailed_summary_0
            entity_pop: sensor.bom_gosford_chance_of_rain_0
            entity_pop_intensity: sensor.bom_gosford_rain_today
            entity_pop_1: sensor.bom_gosford_chance_of_rain_1
            entity_pop_2: sensor.bom_gosford_chance_of_rain_2
            entity_pop_3: sensor.bom_gosford_chance_of_rain_3
            entity_pop_4: sensor.bom_gosford_chance_of_rain_4
            entity_pop_5: sensor.bom_gosford_chance_of_rain_5
            entity_current_text: sensor.bom_current_text
            locale: en
            sunset: true
            static_icons: false
            tooltip_bg_color: 'rgb( 75,155,239)'
            tooltip_border_color: 'rgb(255,161,0)'
            tooltip_border_width: 1
            tooltip_caret_size: 5
            tooltip_fg_color: '#fff'
            tooltip_left_offset: -12
            tooltip_width: 110
            tooltips: true
            old_daily_format: false
            time_format: 12
            show_beaufort: false
            refresh_interval: 60
            show_separator: false
            temp_top_margin: -0.3em         #default -0.3em px or em
            temp_font_weight: 300           #default 300 numeric
            temp_font_size: 4em             #default 4em em
            temp_right_pos: 0.85em          #default .85em px or em
            temp_uom_top_margin: -9px       #default -9px px or em
            temp_uom_right_margin: 7px      #default 7px px or em
            apparent_top_margin: 45px       #default 45px px or em
            apparent_right_pos: 1em         #default 1em px or em
            apparent_right_margin: 1em      #default 1em px or em
            current_text_top_margin: 39px   #default 39px px or em
            current_text_left_pos: 5em      #default 5em px or em
            current_text_font_size: 1.5em   #default 1.5em em
            current_data_top_margin: 7em    #default 7em px or em
            large_icon_top_margin: -3.5em   #default -3.5em px or em
            large_icon_left_position: 0em   #default 0em px or em
            separator_top_margin: 6em       #default 6em px or em
            slot_l1: daytime_high
            slot_l2: wind
            slot_l3: remove                 #visibility but BOM has no visibility reported
            slot_l4: sun_next
            slot_r1: pop
            slot_r2: humidity
            slot_r3: remove                 #pressure but BOM has no visibility reported
            slot_r4: sun_following
          - type: history-graph
            title: Weather BOM Gosford
            hours_to_show: 72
            refresh_interval: 300
            entities:
              - sensor.bom_gosford_air_temp_c
              - sensor.bom_gosford_feels_like_c
              - sensor.bom_gosford_dew_point_c
              - sensor.bom_gosford_rain_today
              - sensor.bom_gosford_relative_humidity
              - sensor.bom_gosford_wind_gust_kmh
              - sensor.bom_gosford_wind_speed_kmh
          - type: entities
            title: BOM Forecast
            show_header_toggle: false
            entities:
              - sensor.bom_forecast_0
              - sensor.bom_forecast_1
              - sensor.bom_forecast_2
              - sensor.bom_forecast_3
              - sensor.bom_forecast_4
              - sensor.bom_forecast_5
              - sensor.bom_forecast_6
          - type: entities
            title: Weather from BOM Australia
            show_header_toggle: false
            entities:
              - sensor.bom_forecast_0
              - sensor.bom_gosford_air_temp_c
              - sensor.bom_gosford_delta_temp_c
              - sensor.bom_gosford_dew_point_c
              - sensor.bom_gosford_feels_like_c
              - sensor.bom_gosford_rain_today
              - sensor.bom_gosford_relative_humidity
              - sensor.bom_gosford_wind_direction
              - sensor.bom_gosford_wind_gust_kmh
              - sensor.bom_gosford_wind_gust_kt
              - sensor.bom_gosford_wind_speed_kmh
              - sensor.bom_gosford_wind_speed_kt

All this is on my above github as well.

Which looks like this:

10 Likes

Champion! Thanks for this. Mashing the darkshy card and BoM sensors together has been in my ‘too hard’ basket for a while.

Just check the chrome console - With beta 0.95 and latest frontend I’m getting a Roboto font error - but everything displays correctly and it seems to be getting that error just with the old dark-sky card as well…

Same error in firefox:
downloadable font: download failed (font-family: "Roboto" style:italic weight:400 stretch:100 src index:2): status=2147746065 source: http://ipaddress:8123/static/fonts/roboto/Roboto-Italic.woff2
I can’t seem to work out how to fix it.

EDIT Actually - Balloob has confirmed there was a typo in polymer and has fixed it and merged the fix.

Hi David,

nice! borrowing your set of forecast templates :wink: thanks!

changed them a bit, to show the forecast in the friendly_name:

      dark_sky_forecast_1:
#          entity_id:
#            - sensor.dark_sky_forecast_daytime_high_temperature_1d
#            - sensor.dark_sky_forecast_overnight_low_temperature_1d
#            - sensor.dark_sky_forecast_precip_probability_1d
        friendly_name_template: >
          {% set date = as_timestamp(now()) + (1 * 86400 ) %}
          {{ date | timestamp_custom('%a %-d %b') }}: {{states('sensor.dark_sky_forecast_icon_1d').replace('-',' ')|capitalize}}
        value_template: >
          {{states('sensor.dark_sky_forecast_daytime_high_temperature_1d')|round(0)}}°/{{states('sensor.dark_sky_forecast_overnight_low_temperature_1d')|round(0)}}°/{{states('sensor.dark_sky_forecast_precip_probability_1d')|round(0)}}%
        entity_picture_template: >
          {{ '/local/weather/icons/' ~ states('sensor.dark_sky_forecast_icon_1d') ~ '.png'}}

btw you can use:

{{ date | timestamp_custom("%A (%-d/%-m)") }}

instead of

{{ date | timestamp_custom("%A (%d/%m)") | replace("(0", "(") | replace("/0", "/") }}

makes it just that bit shorter :wink: I also left out the entity_id’s and up to now have seen no issues rendering the templates. Left them in the config for easy fixing if needed…

noticed the you use the forecast on all monitored conditions. That should render you with heaps of unused sensors?

I’ve mitigated that by creating a dark_sky forecast sensor like this and use only the conditions I want a forecast for. All the other conditions are in my regular sensor:

  - platform: darksky
    api_key: !secret darksky_key
    language: nl
    scan_interval:
    # At least one of these must be specified:
      minutes: 30
    monitored_conditions:
      - hourly_summary
      - daily_summary
      - summary
      - icon
      - temperature
#      - temperature_high
#      - temperature_low
      - precip_type
      - precip_intensity
      - precip_probability
      - precip_accumulation
      - apparent_temperature
#      - apparent_temperature_high
#      - apparent_temperature_low
      - dew_point
      - wind_speed
      - wind_gust
      - wind_bearing
      - cloud_cover
      - humidity
      - pressure
      - visibility
      - ozone
      - precip_intensity_max
      - uv_index

  - platform: darksky
    api_key: !secret darksky_key
    language: nl
    name: dark_sky_forecast
    scan_interval:
    # At least one of these must be specified:
      hours: 1
    forecast:
      - 0
      - 1
      - 2
      - 3
      - 4
      - 5
    monitored_conditions:
      - summary
      - icon
#      - precip_type
      - precip_intensity
      - precip_probability
#      - precip_accumulation
#      - apparent_temperature
#      - dew_point
#      - wind_speed
#      - wind_gust
#      - wind_bearing
#      - cloud_cover
#      - humidity
#      - pressure
#      - visibility
#      - ozone
#      - minutely_summary
#      - hourly_summary
#      - daily_summary
      - temperature_high
      - temperature_low
#      - apparent_temperature_high
#      - apparent_temperature_low
#      - precip_intensity_max
#      - uv_index
#      - moon_phase
#      - nearest_storm_distance
#      - nearest_storm_bearing

22* 6 less sensors to take processor attention…

anyways, thanks for sharing, always keen to learn from your experience.

1 Like

Actually, I just deleted all my darksky stuff completely so you must have grabbed that a few hours ago. Glad it’s of some use to you and I’m going to try your template revision

well, no, tbh, I only clicked your post half hour or so ago ;-)) might be transatlantic delay’s…glad I was just i time then;-)

fwiw, this is the outcome
(didn’t round on the today template purposely, thought it best to be precise on the todays prediction…just so you don’t think I fluked)

22

Actually I think the - doesn’t work on Hass.io… I’ll need to restart HA to check that. It does work in the template editor but I do remember all kinds of grief with the ‘-’ flag…

really? not here, I use it all the time, 2 hassio systems
see the bottom sensor for Monday.

Yeah it works fine. Must have been something else like that or maybe they changed it. I’m almost 100% certain it was that though but it’s working now. If you click on my graphic, (it cut off the bottom) you can see I have a different date format set to you but it’s working fine. Thanks.

yes, I changed it because otherwise the friendly_name_template wouldn’t fit and show all on 1 line.
cool.

now trying to find this in your repo:

51

the graphics are in /www/icons/firedanger and it’s a custom component that gets the data and then lovelace applies the right graphic (there’s 7 in that directory)

got it.
thanks. now trying to find a server using the geolocation in my surroundings to be of any use. We don’t have a lot of earthquakes or fires, but when we do, I need to know…

For anyone paying attention to this, I just added Today’s minimum temperature to use one of the empty slots created by the pressure and visibility being missing. Check out my customised bom-weather-card.js file and the ui-lovelace.yaml as well for the config changes I made. I also changed one of the icons definitions.
image

Pressure is available from the bom sensor.

- platform: bom
  station: 
  name: 
  monitored_conditions:
  - press

It is only available for very specific sites… definitely not available for most regional sites.

Oh and if you are lucky enough to have pressure and/or visibility, you can still show them by setting the option in lovelace for the card just as before. My github lovelace config shows the defaults as a comment… so the minimum temp was added but nothing has been removed.

Ah, I see.

I am one of the lucky ones.

I haven’t actually gotten around to this yet. So much stuff going on. Cinema rewiring, Tuya converting, DHT to BME replacements, outdoor pir wiring, half a dozen more sensors to build and install and lots more… the list is never ending. I have to get it all done before my house sitter arrives in December and I bugger off to Antarctica for a year.

1 Like

In the config I posted, I only include monitored conditions that are available to my location.

Wow! Can’t wait to hear about how HA performs in the cold :slight_smile:
Sounds like a great adventure!

Considering I’m only allowed to take 1m3 of cargo I think I’ll have to leave the house behind. Remote administering it for a year could be a challenge. Getting off topic. Let’s not mess up David’s topic.

1 Like