Customising the BOM Weather and lovelace - now in HACS

# Download the BOM icons from https://github.com/DavidFW1960/bom_forecast/blob/161fbcf5a6876f7d60e6d66bfa0f6fc76dabbf61/bom_icons.zip
# and save them under /www/icons/bom_icons/

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'

  - platform: template
    sensors:
      bom_current_text:
        value_template: >
            {% set val = states('sensor.bom_redcliffe_summary_0').split('.')[0] %} 
            {{ val | title }}

      bom_forecast_0:
        entity_id:
          - sensor.bom_today_max
          - sensor.bom_today_min
          - sensor.bom_redcliffe_chance_of_rain_0
          - sensor.bom_redcliffe_icon_0
        friendly_name: "Today"
        value_template: >
          {{states('sensor.bom_today_max')|round(0)}}Ā°/{{states('sensor.bom_today_min')|round(0)}}Ā°/{{states('sensor.bom_redcliffe_chance_of_rain_0')|round(0)}}%
        entity_picture_template: >-
          {%- if states('sun.sun') == 'below_horizon' and (states('sensor.bom_redcliffe_icon_0') == 'fog' or states('sensor.bom_redcliffe_icon_0') == 'haze' or states('sensor.bom_redcliffe_icon_0') == 'light-showers' or states('sensor.bom_redcliffe_icon_0') == 'partly-cloudy' or states('sensor.bom_redcliffe_icon_0') == 'showers') -%}
          {{ '/local/icons/bom_icons/' ~ states('sensor.bom_redcliffe_icon_0') ~ '-night.png' }}
          {%- else -%}
          {{ '/local/icons/bom_icons/' ~ states('sensor.bom_redcliffe_icon_0') ~ '.png' }}
          {%- endif -%}

      bom_forecast_1:
        entity_id:
          - sensor.bom_redcliffe_max_temp_c_1
          - sensor.bom_redcliffe_min_temp_c_1
          - sensor.bom_redcliffe_chance_of_rain_1
          - sensor.bom_redcliffe_icon_1
        friendly_name_template: >
          {%- set date = as_timestamp(now()) + (1 * 86400 ) -%}
          {{ date | timestamp_custom('Tomorrow (%-d/%-m)') }}
        value_template: >
          {{states('sensor.bom_redcliffe_max_temp_c_1')|round(0)}}Ā°/{{states('sensor.bom_redcliffe_min_temp_c_1')|round(0)}}Ā°/{{states('sensor.bom_redcliffe_chance_of_rain_1')|round(0)}}%
        entity_picture_template: >-
          {{ '/local/icons/bom_icons/' ~ states('sensor.bom_redcliffe_icon_1') ~ '.png' }}

      bom_forecast_2:
        entity_id:
          - sensor.bom_redcliffe_max_temp_c_2
          - sensor.bom_redcliffe_min_temp_c_2
          - sensor.bom_redcliffe_chance_of_rain_2
          - sensor.bom_redcliffe_icon_2
        friendly_name_template: >
          {%- set date = as_timestamp(now()) + (2 * 86400 ) -%}
          {{ date | timestamp_custom('%A (%-d/%-m)') }}
        value_template: >
          {{states('sensor.bom_redcliffe_max_temp_c_2')|round(0)}}Ā°/{{states('sensor.bom_redcliffe_min_temp_c_2')|round(0)}}Ā°/{{states('sensor.bom_redcliffe_chance_of_rain_2')|round(0)}}%
        entity_picture_template: >-
          {{ '/local/icons/bom_icons/' ~ states('sensor.bom_redcliffe_icon_2') ~ '.png' }}

      bom_forecast_3:
        entity_id:
          - sensor.bom_redcliffe_max_temp_c_3
          - sensor.bom_redcliffe_min_temp_c_3
          - sensor.bom_redcliffe_chance_of_rain_3
          - sensor.bom_redcliffe_icon_3
        friendly_name_template: >
          {%- set date = as_timestamp(now()) + (3 * 86400 ) -%}
          {{ date | timestamp_custom('%A (%-d/%-m)') }}
        value_template: >
          {{states('sensor.bom_redcliffe_max_temp_c_3')|round(0)}}Ā°/{{states('sensor.bom_redcliffe_min_temp_c_3')|round(0)}}Ā°/{{states('sensor.bom_redcliffe_chance_of_rain_3')|round(0)}}%
        entity_picture_template: >-
          {{ '/local/icons/bom_icons/' ~ states('sensor.bom_redcliffe_icon_3') ~ '.png' }}

      bom_forecast_4:
        entity_id:
          - sensor.bom_redcliffe_max_temp_c_4
          - sensor.bom_redcliffe_min_temp_c_4
          - sensor.bom_redcliffe_chance_of_rain_4
          - sensor.bom_redcliffe_icon_4
        friendly_name_template: >
          {%- set date = as_timestamp(now()) + (4 * 86400 ) -%}
          {{ date | timestamp_custom('%A (%-d/%-m)') }}
        value_template: >
          {{states('sensor.bom_redcliffe_max_temp_c_4')|round(0)}}Ā°/{{states('sensor.bom_redcliffe_min_temp_c_4')|round(0)}}Ā°/{{states('sensor.bom_redcliffe_chance_of_rain_4')|round(0)}}%
        entity_picture_template: >-
          {{ '/local/icons/bom_icons/' ~ states('sensor.bom_redcliffe_icon_4') ~ '.png' }}

      bom_forecast_5:
        entity_id:
          - sensor.bom_redcliffe_max_temp_c_5
          - sensor.bom_redcliffe_min_temp_c_5
          - sensor.bom_redcliffe_chance_of_rain_5
          - sensor.bom_redcliffe_icon_5
        friendly_name_template: >
          {%- set date = as_timestamp(now()) + (5 * 86400 ) -%}
          {{ date | timestamp_custom('%A (%-d/%-m)') }}
        value_template: >
          {{states('sensor.bom_redcliffe_max_temp_c_5')|round(0)}}Ā°/{{states('sensor.bom_redcliffe_min_temp_c_5')|round(0)}}Ā°/{{states('sensor.bom_redcliffe_chance_of_rain_5')|round(0)}}%
        entity_picture_template: >-
          {{ '/local/icons/bom_icons/' ~ states('sensor.bom_redcliffe_icon_5') ~ '.png' }}

      bom_forecast_6:
        entity_id:
          - sensor.bom_redcliffe_max_temp_c_6
          - sensor.bom_redcliffe_min_temp_c_6
          - sensor.bom_redcliffe_chance_of_rain_6
          - sensor.bom_redcliffe_icon_6
        friendly_name_template: >
          {%- set date = as_timestamp(now()) + (6 * 86400 ) -%}
          {{ date | timestamp_custom('%A (%-d/%-m)') }}
        value_template: >
          {{states('sensor.bom_redcliffe_max_temp_c_6')|round(0)}}Ā°/{{states('sensor.bom_redcliffe_min_temp_c_6')|round(0)}}Ā°/{{states('sensor.bom_redcliffe_chance_of_rain_6')|round(0)}}%
        entity_picture_template: >-
          {{ '/local/icons/bom_icons/' ~ states('sensor.bom_redcliffe_icon_6') ~ '.png' }}

      bom_today_max:
        entity_id:
          - sensor.bom_redcliffe_max_temp_c_0
          - sensor.today_temp_bom
        value_template: >
          {%- if states('sensor.bom_redcliffe_max_temp_c_0') == 'n/a' -%} 
            {{ state_attr('sensor.today_temp_bom', 'max_value') }}
          {% else %}
            {{ states('sensor.bom_redcliffe_max_temp_c_0') }}
          {% endif %}

      bom_today_min:
        entity_id:
          - sensor.bom_redcliffe_min_temp_c_0
          - sensor.today_temp_bom
        value_template: >
          {%- if states('sensor.bom_redcliffe_min_temp_c_0') == 'n/a' -%} 
            {{ state_attr('sensor.today_temp_bom', 'min_value') }}
          {% else %}
            {{ states('sensor.bom_redcliffe_min_temp_c_0') }}
          {% endif %}

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

automation:
- alias: 'Update BOM Icons'
  trigger:
    - event: start
      platform: homeassistant
    - entity_id: sun.sun
      platform: state
      to: 'above_horizon'
    - entity_id: sun.sun
      platform: state
      to: 'below_horizon'
  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

There is a template you need for the min and max as well as current conditions. Itā€™s in the package as well.
Reason: current conditions comes from the summary and the max and min disappear during the day after the min/maximum has been reached. So I use a template with the statistics sensor to populate that value when the forecast value is unavailable.

Also, the predicted rain today (in some areas) will always be 0mm (it is here for me for the current day) So no point showing thatā€¦

Can someone point me in the right direction on how to use:
style:
left: 10%
top: 37%
width: 15%
height: 40%

On this card pleaseā€¦

What exactly are you trying to move?

What offends thy eye?

Depends what youā€™re trying to styleā€¦ but itā€™s highly customizable and if itā€™s not a native option you can use card-mod but depending on what you actually want I might be able to provide the option if it doesnā€™t already exist.

Is there currently a UV sensor from BOM? The Open UV sensor is rubbish and not that accurate.
image
For some reason BOM donā€™t include the UV Index (bottom line of pic) in their detailed summary.

Was hoping there could be a current UV as well as predicted.
Thanks

Looking at this it is in the XML file returned by the component. Iā€™m trying to see if I can extract that and the fire_danger too a sensorā€¦

2 Likes

OKā€¦ I got this working.

This is a TEST VERSION for right now. If you download it, you will need to rename sensor.py in custom_components/bom_forecast/ and then rename this one to sensor.py (make sure you download in raw mode)

Then in your configuration for the sensorā€¦
Add uv_alert and fire_danger to monitored conditions.

    monitored_conditions:
      - 'max'
      - 'min'
      - 'chance_of_rain'
      - 'possible_rainfall'
      - 'summary'
      - 'detailed_summary'
      - 'icon'
      - 'uv_alert'
      - 'fire_danger'

This will then create, in my caseā€¦ 2 sensors:


Now unfortunately, itā€™s for TOMORROW but Iā€™m almost 100% sure, it will switch from today to tomorrow after the ā€˜peakā€™ has come and gone.

So the uv_alert will be either sensor.bom_gosford_uv_alert_0 or sensor.bom_gosford_uv_alert_1

Now provided this sensor behaves over the next few days, I will add the uv_alert as text to the bottom of the card (I will test if today=unknown and then select tomorrow) and I will make the fire_danger one an option in the lists (like min/max temp) again presenting only either today or tomorrow.

Anyway, please test the new sensor and provide feedback.

Thanks.

EDIT:::: VERY IMPORTANTā€¦ DONā€™T add the yaml above to your config until you load the new custom component, restart home assistant THEN edit yaml and restart againā€¦

Seems to be working but getting a lot of log errorsā€¦

Hi David, noticed the same with the logs - also found the ā€œfire dangerā€ did not have a state to report? Probably a Perth thing with how it is displayed compared to Gosford? No big dealā€¦

image

Thanks for your effort thus far

Syntax used to create a simple string from the UV state

      {% set val = states('sensor.bom_perth_uv_alert_0').split('[')[1].split(']')[0]%}{{ val | title }}

Ok I have a solution for this. Just need to verify tomorrow before releasing the update in HACS. Iā€™ll post more details then after I test it.

OK I have pushed a new release with this updated code. Iā€™m working on the lovelace card now.
I have decided to just add the uv alert text to the summary at the bottom and the fire danger as well. Template sensors will be needed as the available entity changes during the day (today or tomorrow) Anywayā€¦ it will take me a while to work on this.

@grantc @tom_l How do you like this?

2 Likes

Looks great Dave, well done.

1 Like

THANKS for the update!

Not sure if this is something from your side or HACs side. Restart required came up in white on white.
Iā€™d assume its HACs side, however this is the only time I have noticed white on white. Its black text on red background for HACs updates.

RestartPending

Could be your themeā€¦ itā€™s not this card/component. I very much doubt itā€™s HACS. Did you try refreshing the browser/clearing cache?

I didnā€™t try a cache clear, but I had updated HACs minutes before and it came up in black on red. no big deal I was restarting anyway. my theme is just the stock hassio theme.

So now youā€™ve updated HACS and this component, does it show correctly in HACS now?

yeah it disappeared as expected when I restarted. To be clear. I had updated HACs prior to updating this. HACs had shown the same notification except in the expected colors. I restarted hassio and then updated both boms, and noticed the notification as per the screenshot. I restarted after that and all was normal.

1 Like

I like it but canā€™t get it to display.

Iā€™ve updated the card and integration, added the uv and fire template sensors, restarted and refreshed my browser cache but all I see is:


ā€¦