Customising the BOM Weather and lovelace - now in HACS

Hi Tom, thanks for jumping in. My weather card is working fine, I’m actually interested in using the current animated icon elsewhere but unsure how to grab it

they are all in this directory: /usr/share/hassio/homeassistant/www/icons in weather_icons directory in an animated or static directory

image

so if you use it elsewhere remember www=local so you woud use /local/icons/weather_icons/animated etc

One other thing to bear in mind is that the animated icons use a bit of CPU to display. I see Firefox’s CPU use increase 10% when switching from static to animated.

Thankyou both, I can see the icon location etc, but its there an entity already available that actually gets updated with the current icon? I can only see entities with static icons as attributes

No there isn’t. There are icon description entities, like sensor.hobart_icon_descriptor_0 that then gets decoded by this \config\www\community\bom-weather-card\bom-weather-card.js

this bit of the file specifically:

// #####
// ##### weatherIcons: returns icon names based on current conditions text
// #####

  get weatherIcons() {
    var iconStyle = (this.config.old_icon ==="hybrid") ? `hybrid` : (this.config.old_icon ==="false") ? `false` : `true`;
    var sunny_icon = (iconStyle ==="true") ? `${this.dayOrNight}` : (iconStyle ==="hybrid") ? `sunny-${this.dayOrNight}` : `sunny-${this.dayOrNight}`;
    var clear_icon = (iconStyle ==="true") ? `${this.dayOrNight}` : (iconStyle ==="hybrid") ? `sunny-${this.dayOrNight}` : `clear-${this.dayOrNight}`;
    var mostly_sunny_icon = (iconStyle ==="true") ? `fair-${this.dayOrNight}` : (iconStyle ==="hybrid") ? `fair-${this.dayOrNight}` : `fair-${this.dayOrNight}`;
    var partly_cloudy_icon = (iconStyle ==="true") ? `cloudy-${this.dayOrNight}-3` : (iconStyle ==="hybrid") ? `cloudy-${this.dayOrNight}-3` : `partly-cloudy-${this.dayOrNight}`;
    var cloudy_icon = (iconStyle ==="true") ? `cloudy-original` : (iconStyle ==="hybrid") ? `cloudy-original` : `cloudy`;
    var hazy_icon = (iconStyle ==="true") ? `cloudy-${this.dayOrNight}-1` : (iconStyle ==="hybrid") ? `haze` : `haze`;
    var frost_icon = (iconStyle ==="true") ? `cloudy-${this.dayOrNight}-1` : (iconStyle ==="hybrid") ? `cloudy-${this.dayOrNight}-1` : `cloudy-${this.dayOrNight}-1`;
    var light_rain_icon = (iconStyle ==="true") ? `rainy-1` : (iconStyle ==="hybrid") ? `rainy-1-${this.dayOrNight}` : `rainy-1-${this.dayOrNight}` ;
    var windy_icon = (iconStyle ==="true") ? `cloudy-original` : (iconStyle ==="hybrid") ? `wind` : `wind`;
    var fog_icon = (iconStyle ==="true") ? `cloudy-original` : (iconStyle ==="hybrid") ? `fog` : `fog`;
    var showers_icon = (iconStyle ==="true") ? `rainy-1` : (iconStyle ==="hybrid") ? `rainy-1-${this.dayOrNight}` : `rainy-1-${this.dayOrNight}`;
    var rain_icon = (iconStyle ==="true") ? `rainy-5` : (iconStyle ==="hybrid") ? `rainy-5` : `rain`;
    var dust_icon = (iconStyle ==="true") ? `cloudy-${this.dayOrNight}-1` : (iconStyle ==="hybrid") ? `haze` : `haze`;
    var snow_icon = (iconStyle ==="true") ? `snowy-6` : (iconStyle ==="hybrid") ? `snowy-6` : `snow`;
    var snow_rain_icon = (iconStyle ==="true") ? `snowy-6` : (iconStyle ==="hybrid") ? `rain-and-snow-mix` : `rain-and-snow-mix`;
    var storm_icon = (iconStyle ==="true") ? `scattered-thunderstorms` : (iconStyle ==="hybrid") ? `scattered-thunderstorms` : `scattered-thunderstorms`;
    var light_showers_icon = (iconStyle ==="true") ? `rainy-2` : (iconStyle ==="hybrid") ? `rainy-2` : `rainy-2`;
    var heavy_showers_icon = (iconStyle ==="true") ? `rainy-6` : (iconStyle ==="hybrid") ? `rainy-6` : `rainy-6`;
    var cyclone_icon = (iconStyle ==="true") ? `tornado` : (iconStyle ==="hybrid") ? `tornado` : `tornado`;
    var clear_day_icon = (iconStyle ==="true") ? `day` : (iconStyle ==="hybrid") ? `day` : `clear-day`;
    var clear_night_icon = (iconStyle ==="true") ? `night` : (iconStyle ==="hybrid") ? `night` : `clear-night`;
    var sleet_icon = (iconStyle ==="true") ? `rainy-2` : (iconStyle ==="hybrid") ? `rain-and-sleet-mix` : `rain-and-sleet-mix`;
    var partly_cloudy_day_icon = (iconStyle ==="true") ? `cloudy-day-3` : (iconStyle ==="hybrid") ? `cloudy-day-3` : `partly-cloudy-day`;
    var partly_cloudy_night_icon = (iconStyle ==="true") ? `cloudy-night-3` : (iconStyle ==="hybrid") ? `cloudy-night-3` : `partly-cloudy-night`;
    var hail_icon = (iconStyle ==="true") ? `rainy-7` : (iconStyle ==="hybrid") ? `rainy-7` : `rainy-7`;
    var lightning_icon = (iconStyle ==="true") ? `thunder` : (iconStyle ==="hybrid") ? `thunder` : `thunder`;
    var windy_variant_icon = (iconStyle ==="true") ? `cloudy-${this.dayOrNight}-3` : (iconStyle ==="hybrid") ? `cloudy-${this.dayOrNight}-3` : `cloudy-${this.dayOrNight}-3`;
    return {
      'sunny': sunny_icon,
      'clear': clear_icon,
      'mostly-sunny': mostly_sunny_icon,
      'partly-cloudy': partly_cloudy_icon,
      'mostly_sunny': mostly_sunny_icon,
      'partly_cloudy': partly_cloudy_icon,
      'partlycloudy': partly_cloudy_icon,
      'cloudy': cloudy_icon,
      'hazy': hazy_icon,
      'hazey': hazy_icon,
      'haze': hazy_icon,
      'frost': frost_icon,
      'light-rain': light_rain_icon,
      'light_rain': light_rain_icon,
      'wind': windy_icon,
      'windy': windy_icon,
      'fog': fog_icon,
      'foggy': fog_icon,
      'showers': showers_icon,
      'shower': showers_icon,
      'rain': rain_icon,
      'rainy': rain_icon,
      'dust': dust_icon,
      'dusty': dust_icon,
      'snow': snow_icon,
      'snowy': snow_icon,
      'snowy-rainy': snow_rain_icon,
      'snowy_rainy': snow_rain_icon,
      'snowyrainy': snow_rain_icon,
      'storm': storm_icon,
      'stormy': storm_icon,
      'light-showers': light_showers_icon,
      'light-shower': light_showers_icon,
      'heavy-showers': heavy_showers_icon,
      'heavy-shower': heavy_showers_icon,
      'light_showers': light_showers_icon,
      'light_shower': light_showers_icon,
      'heavy_showers': heavy_showers_icon,
      'heavy_shower': heavy_showers_icon,
      'pouring': heavy_showers_icon,
      'tropical-cyclone': cyclone_icon,
      'tropical_cyclone': cyclone_icon,
      'tropicalcyclone': cyclone_icon,
      'clear-day': clear_day_icon,
      'clear-night': clear_night_icon,
      'clear_day': clear_day_icon,
      'clear_night': clear_night_icon,
      'sleet': sleet_icon,
      'partly-cloudy-day': partly_cloudy_day_icon,
      'partly-cloudy-night': partly_cloudy_night_icon,
      'partly_cloudy_day': partly_cloudy_day_icon,
      'partly_cloudy_night': partly_cloudy_night_icon,
      'hail': hail_icon,
      'lightning': lightning_icon,
      'lightning-rainy': lightning_icon,
      'lightning_rainy': lightning_icon,
      'thunderstorm': lightning_icon,
      'windy-variant': windy_variant_icon,
      'windy_variant': windy_variant_icon,
      'exceptional': '!!',
    }
  }

Yeah Tom is right… the card parses through the state of the icon_descriptor (the weather condition) to the card and the js then uses that to select the icon to display. You could maybe do that with a picture_template or something else where it can select the icon depending on the state.

Thanks fellas

Hey David,

upgraded to 2021.10.2 - getting this error from my copy of your package:

2021-10-09 15:23:59 WARNING (MainThread) [homeassistant.helpers.template] Template warning: 'round' got invalid input 'unknown' when rendering template '{% if states('sensor.pymble_temp_min_0') == 'unknown' %} {% set min = states('sensor.bom_today_min') %} {% else %} {% set min = states('sensor.pymble_temp_min_0') %} {% endif %} {% if states('sensor.pymble_temp_max_0') == 'unknown' %} {% set max = states('sensor.bom_today_max') %} {% else %} {% set max = states('sensor.pymble_temp_max_0') %} {% endif %} {{ max|round(0)}}°/{{ min|round(0)}}°/{{states('sensor.pymble_rain_chance_0')|round(0)}}%' but no default was specified. Currently 'round' will return 'unknown', however this template will fail to render in Home Assistant core 2021.12

something broken my end, a quirk of just restarting and an entity not populated, or something broken in the template now seen with the new warnings?

Replace round(0) with round(0, default=none) in your min/max bom templates.

I am not seeing that and I use the same sensor. I can’t see how it would even be possible for max or min to ever be unknowns… maybe @tom_l has a thought about this

Thanks Tom. I don’t see how it would be possible for that min or max to ever return unknown

I’m not seeing it either. It would be interesting to see what the state of the following sensors are:

sensor.bom_today_min
sensor.bom_today_max
sensor.pymble_temp_min_0
sensor.pymble_temp_max_0

Maybe they have a mangled template?

The min_0 and max_0 CAN be unknown as BOM removes those at ~4pm and 10pm respectively bit the min and max are created by the average or statistics integration… I guess if the temperature for today didn’t have any history that could happen…

EDIT: Or they dont have the average sensor?

1 Like

Average or Stats… could be missing… would explain it.

1 Like

I have the average integration as per David config,

sensor.bom_today_min = 17.4
sensor.bom_today_max = 17.5
sensor.pymble_temp_min_0 = unknown
sensor.pymble_temp_max_0 = 27

for min_0:

|response_timestamp: 2021-10-10T05:50:51Z issue_time: 2021-10-10T05:26:22Z forecast_region: Sydney forecast_type: metropolitan attribution: Data provided by the Australian Bureau of Meteorology date: 2021-10-09T13:00:00Z unit_of_measurement: °C friendly_name: Pymble Temp Min 0 device_class: temperature hide_attributes: templates|

Right so what happens if you put the template in the dev-yools template tool? It should use the bom_today_min. BOM removes the min temp ~4pm as mentioned above which is the whole point of using the template.

cut and paste from the error into dev tools…

{% if states('sensor.pymble_temp_min_0') == 'unknown' %} {% set min = states('sensor.bom_today_min') %} {% else %} {% set min = states('sensor.pymble_temp_min_0') %} {% endif %} {% if states('sensor.pymble_temp_max_0') == 'unknown' %} {% set max = states('sensor.bom_today_max') %} {% else %} {% set max = states('sensor.pymble_temp_max_0') %} {% endif %} {{ max|round(0)}}°/{{ min|round(0)}}°/{{states('sensor.pymble_rain_chance_0')|round(0)}}%

gives

27°/16°/95%

and no errors.
sensor.pymble_temp_min_0 is still unknown.

I only see this at restart …

And will be until midnight.
I haven’t seen that error… it’s likely a timing thing maybe. Have you excluded the bom_today_min/max sensor from history? You can add a default as Tom described above or just ignore the error.