Skip to content

Different icons for each alert type #50

@gridlockjoe

Description

@gridlockjoe

Is your feature request related to a problem? Please describe.
Not a problem, an enhancement

Describe the solution you'd like
I have manually edited the weatheralerts_1.yaml file to provide distinct icons for the different alert types. Hope you'll be able to include these in the default code.

Under each of the alerts I replaced

icon_template: hass:alert-rhombus

with:

        icon_template: >-
          {% set mapper =  {
              '911 Telephone Outage Emergency' : 'hass:phone-alert',
              'Administrative Message' : 'hass:message-text',
              'Air Quality Alert' : 'hass:blur',
              'Air Stagnation Advisory' : 'hass:blur',
              'Arroyo And Small Stream Flood Advisory' : 'hass:water-alert',
              'Ashfall Advisory' : 'hass:cloud-alert',
              'Ashfall Warning' : 'hass:cloud-alert',
              'Avalanche Advisory' : 'hass:alert',
              'Avalanche Warning' : 'hass:alert',
              'Avalanche Watch' : 'hass:alert',
              'Beach Hazards Statement' : 'hass:beach',
              'Blizzard Warning' : 'hass:snowflake-alert',
              'Blizzard Watch' : 'hass:snowflake-alert',
              'Blowing Dust Advisory' : 'hass:blur',
              'Blowing Dust Warning' : 'hass:blur',
              'Brisk Wind Advisory' : 'hass:weather-windy',
              'Child Abduction Emergency' : 'hass:human-male-child',
              'Civil Danger Warning' : 'hass:image-filter-hdr',
              'Civil Emergency Message' : 'hass:image-filter-hdr',
              'Coastal Flood Advisory' : 'hass:waves',
              'Coastal Flood Statement' : 'hass:waves',
              'Coastal Flood Warning' : 'hass:waves',
              'Coastal Flood Watch' : 'hass:waves',
              'Dense Fog Advisory' : 'hass:weather-fog',
              'Dense Smoke Advisory' : 'hass:smoke',
              'Dust Advisory' : 'hass:blur',
              'Dust Storm Warning' : 'hass:blur',
              'Earthquake Warning' : 'hass:alert',
              'Evacuation - Immediate' : 'hass:exit-run',
              'Excessive Heat Warning' : 'hass:thermometer-plus',
              'Excessive Heat Watch' : 'hass:thermometer-plus',
              'Extreme Cold Warning' : 'hass:thermometer-minus',
              'Extreme Cold Watch' : 'hass:thermometer-minus',
              'Extreme Fire Danger' : 'hass:fire-alert',
              'Extreme Wind Warning' : 'hass:weather-windy',
              'Fire Warning' : 'hass:fire-alert',
              'Fire Weather Watch' : 'hass:fire-alert',
              'Flash Flood Statement' : 'hass:water-alert',
              'Flash Flood Warning' : 'hass:water-alert',
              'Flash Flood Watch' : 'hass:water-alert',
              'Flood Advisory' : 'hass:water-alert',
              'Flood Statement' : 'hass:water-alert',
              'Flood Warning' : 'hass:water-alert',
              'Flood Watch' : 'hass:water-alert',
              'Freeze Warning' : 'hass:thermometer-minus',
              'Freeze Watch' : 'hass:thermometer-minus',
              'Freezing Fog Advisory' : 'hass:snowflake-alert',
              'Freezing Rain Advisory' : 'hass:snowflake-alert',
              'Freezing Spray Advisory' : 'hass:snowflake-alert',
              'Frost Advisory' : 'hass:snowflake-alert',
              'Gale Warning' : 'hass:weather-windy',
              'Gale Watch' : 'hass:weather-windy',
              'Hard Freeze Warning' : 'hass:thermometer-minus',
              'Hard Freeze Watch' : 'hass:thermometer-minus',
              'Hazardous Materials Warning' : 'hass:radioactive',
              'Hazardous Seas Warning' : 'hass:sail-boat',
              'Hazardous Seas Watch' : 'hass:sail-boat',
              'Hazardous Weather Outlook' : 'hass:message-alert',
              'Heat Advisory' : 'hass:thermometer-plus',
              'Heavy Freezing Spray Warning' : 'hass:snowflake-alert',
              'Heavy Freezing Spray Watch' : 'hass:snowflake-alert',
              'High Surf Advisory' : 'hass:surfing',
              'High Surf Warning' : 'hass:surfing',
              'High Wind Warning' : 'hass:weather-windy',
              'High Wind Watch' : 'hass:weather-windy',
              'Hurricane Force Wind Warning' : 'hass:weather-hurricane',
              'Hurricane Force Wind Watch' : 'hass:weather-hurricane',
              'Hurricane Local Statement' : 'hass:weather-hurricane',
              'Hurricane Warning' : 'hass:weather-hurricane',
              'Hurricane Watch' : 'hass:weather-hurricane',
              'Hydrologic Advisory' : 'hass:message-text',
              'Hydrologic Outlook' : 'hass:message-text',
              'Ice Storm Warning' : 'hass:snowflake-alert',
              'Lake Effect Snow Advisory' : 'hass:snowflake-alert',
              'Lake Effect Snow Warning' : 'hass:snowflake-alert',
              'Lake Effect Snow Watch' : 'hass:snowflake-alert',
              'Lake Wind Advisory' : 'hass:weather-windy',
              'Lakeshore Flood Advisory' : 'hass:waves-arrow-up',
              'Lakeshore Flood Statement' : 'hass:waves-arrow-up',
              'Lakeshore Flood Warning' : 'hass:waves-arrow-up',
              'Lakeshore Flood Watch' : 'hass:waves-arrow-up',
              'Law Enforcement Warning' : 'hass:car-emergency',
              'Local Area Emergency' : 'hass:alert',
              'Low Water Advisory' : 'hass:wave',
              'Marine Weather Statement' : 'hass:sail-boat',
              'Nuclear Power Plant Warning' : 'hass:radioactive',
              'Radiological Hazard Warning' : 'hass:biohazard',
              'Red Flag Warning' : 'fire-alert',
              'Rip Current Statement' : 'hass:surfing',
              'Severe Thunderstorm Warning' : 'hass:weather-lightning',
              'Severe Thunderstorm Watch' : 'hass:weather-lightning',
              'Severe Weather Statement' : 'hass:message-text',
              'Shelter In Place Warning' : 'hass:account-box',
              'Short Term Forecast' : 'hass:message-text',
              'Small Craft Advisory' : 'hass:sail-boat',
              'Small Craft Advisory For Hazardous Seas' : 'hass:sail-boat',
              'Small Craft Advisory For Rough Bar' : 'hass:sail-boat',
              'Small Craft Advisory For Winds' : 'hass:sail-boat',
              'Small Stream Flood Advisory' : 'hass:water-alert',
              'Snow Squall Warning' : 'hass:snowflake-alert',
              'Special Marine Warning' : 'hass:sail-boat',
              'Special Weather Statement' : 'hass:message-alert',
              'Storm Surge Warning' : 'hass:waves-arrow-up',
              'Storm Surge Watch' : 'hass:waves-arrow-up',
              'Storm Warning' : 'hass:weather-lightning',
              'Storm Watch' : 'hass:weather-lightning',
              'Test' : 'hass:message-text',
              'Tornado Warning' : 'hass:weather-tornado',
              'Tornado Watch' : 'hass:weather-tornado',
              'Tropical Depression Local Statement' : 'hass:weather-hurricane',
              'Tropical Storm Local Statement' : 'hass:weather-hurricane',
              'Tropical Storm Warning' : 'hass:weather-hurricane',
              'Tropical Storm Watch' : 'hass:weather-hurricane',
              'Tsunami Advisory' : 'hass:waves-arrow-up',
              'Tsunami Warning' : 'hass:waves-arrow-up',
              'Tsunami Watch' : 'hass:waves-arrow-up',
              'Typhoon Local Statement' : 'hass:weather-hurricane',
              'Typhoon Warning' : 'hass:weather-hurricane',
              'Typhoon Watch' : 'hass:weather-hurricane',
              'Urban And Small Stream Flood Advisory' : 'hass:home-flood',
              'Volcano Warning' : 'hass:image-filter-hdr',
              'Wind Advisory' : 'hass:weather-windy',
              'Wind Chill Advisory' : 'hass:thermometer-minus',
              'Wind Chill Warning' : 'hass:thermometer-minus',
              'Wind Chill Watch' : 'hass:thermometer-minus',
              'Winter Storm Warning' : 'hass:snowflake-alert',
              'Winter Storm Watch' : 'hass:snowflake-alert',
              'Winter Weather Advisory' : 'hass:snowflake-alert' } %}
          {% set state =  states['sensor.weatheralerts_1_alert_1'].attributes.alert_event %}
          {{ mapper[state] if state in mapper else 'hass:alert-rhombus' }}

repeating the same code in each alert block, substituting the alert number.

Describe alternatives you've considered
I'm sure there's a more elegant way to do this.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions