custom-components / weatheralerts

A sensor that gives you weather alerts from alerts.weather.gov.
MIT License
123 stars 15 forks source link

Template Variable Error #53

Closed esmoyer closed 2 years ago

esmoyer commented 2 years ago

Version of the custom_component

0.1.5

Describe the bug Getting a template error in the logs. I am sure I am missing something stupid but can't figure it out. I even started from scratch but still get this filling up my logs. Appreciate any insight!

Log

Template variable error: 'None' has no attribute 'attributes' when rendering '{% 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' }}'
jlverhagen commented 2 years ago

Thanks for the report. I'm working on an update to the yaml package now that will hopefully address those logged errors. Essentially, it's not a real problem and the errors can be ignored. The error is logged because the template can be processed before the Weatheralerts integration is fully loaded and working. It may also log these errors if the National Weather Service Alerts API web site is experiencing slowness or an API outage.

esmoyer commented 2 years ago

Ok cool. I was wondering if it was more "cosmetic". Appreciate it!

jlverhagen commented 2 years ago

I have updated the yaml packages. If the template errors persist, or if new template errors pop up, they can be reported here. I'll keep this issue open for a week or two to allow for more testing and reporting of template errors.

adam-olson commented 2 years ago

Seems to have fixed the errors I was getting, so far.

esmoyer commented 2 years ago

Appears to be working for me now as well. Thank you!

stale[bot] commented 2 years ago

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.