custom-components / weatheralerts

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

Attributes not set correctly #69

Open RRhodesVFX opened 2 years ago

RRhodesVFX commented 2 years ago

Version of the custom_component

V0.1.5 Describe the bug A clear and concise description of what the bug is.

Attributes are not properly set. Alert comes in, but it is one large block of text and isn't parsed into usable attributes.

Log

2022-09-27 14:43:47.593 WARNING (SyncWorker_0) [homeassistant.loader] We found a custom integration weatheralerts which has not been tested by Home Assistant. This component might cause stability problems, be sure to disable it if you experience issues with Home Assistant
2022-09-27 14:43:54.731 WARNING (MainThread) [homeassistant.helpers.template] Template variable warning: 'None' has no attribute 'attributes' when rendering '{% set SENSOR = 'sensor.weatheralerts' -%}
2022-09-27 14:43:54.787 WARNING (MainThread) [homeassistant.helpers.template] Template variable warning: 'None' has no attribute 'attributes' when rendering '{% set SENSOR = 'sensor.weatheralerts' -%}
2022-09-27 14:43:56.888 INFO (SyncWorker_1) [homeassistant.loader] Loaded openweathermap from homeassistant.components.openweathermap
2022-09-27 14:43:57.228 INFO (SyncWorker_1) [homeassistant.loader] Loaded trafikverket_weatherstation from homeassistant.components.trafikverket_weatherstation
2022-09-27 14:43:57.330 INFO (SyncWorker_1) [homeassistant.loader] Loaded accuweather from homeassistant.components.accuweather
2022-09-27 14:43:59.418 INFO (MainThread) [homeassistant.components.sensor] Setting up sensor.weatheralerts
2022-09-27 14:44:12.709 WARNING (MainThread) [homeassistant.components.sensor] Setup of sensor platform weatheralerts is taking over 10 seconds.
2022-09-27 14:44:13.942 INFO (MainThread) [custom_components.weatheralerts.sensor] {'@context': ['https://geojson.org/geojson-ld/geojson-context.jsonld', {'@version': '1.1', 'wx': 'https://api.weather.gov/ontology#', '@vocab': 'https://api.weather.gov/ontology#'}], 'type': 'FeatureCollection', 'features': [{'id': 'https://api.weather.gov/alerts/urn:oid:2.49.0.1.840.0.494f76e78824622ad7107bb7220aef8351c08748.001.1', 'type': 'Feature', 'geometry': None, 'properties': {'@id': 'https://api.weather.gov/alerts/urn:oid:2.49.0.1.840.0.494f76e78824622ad7107bb7220aef8351c08748.001.1', '@type': 'wx:Alert', 'id': 'urn:oid:2.49.0.1.840.0.494f76e78824622ad7107bb7220aef8351c08748.001.1', 'areaDesc': 'Pickens; Dawson; Lumpkin; White; Floyd; Bartow; Cherokee; Forsyth; Hall; Banks; Jackson; Madison; Polk; Paulding; Cobb; North Fulton; Gwinnett; Barrow; Clarke; Oconee; Oglethorpe; Wilkes; Haralson; Carroll; Douglas; South Fulton; DeKalb; Rockdale; Walton; Newton; Morgan; Greene; Taliaferro; Heard; Coweta; Fayette; Clayton; Spalding; Henry; Butts; Jasper; Putnam; Hancock; Warren; Troup; Meriwether; Pike; Upson; Lamar; Monroe; Jones; Baldwin; Washington; Glascock; Jefferson; Harris; Talbot; Taylor; Crawford; Bibb; Twiggs; Wilkinson; Johnson; Emanuel; Muscogee; Chattahoochee; Marion; Schley; Macon; Peach; Houston; Bleckley; Laurens; Treutlen; Stewart; Webster; Sumter; Dooly; Crisp; Pulaski; Wilcox; Dodge; Telfair; Wheeler; Montgomery; Toombs', 'geocode': {'SAME': ['013227', '013085', '013187', '013311', '013115', '013015', '013057', '013117', '013139', '013011', '013157', '013195', '013233', '013223', '013067', '013121', '013135', '013013', '013059', '013219', '013221', '013317', '013143', '013045', '013097', '013089', '013247', '013297', '013217', '013211', '013133', '013265', '013149', '013077', '013113', '013063', '013255', '013151', '013035', '013159', '013237', '013141', '013301', '013285', '013199', '013231', '013293', '013171', '013207', '013169', '013009', '013303', '013125', '013163', '013145', '013263', '013269', '013079', '013021', '013289', '013319', '013167', '013107', '013215', '013053', '013197', '013249', '013193', '013225', '013153', '013023', '013175', '013283', '013259', '013307', '013261', '013093', '013081', '013235', '013315', '013091', '013271', '013309', '013209', '013279'], 'UGC': ['GAZ013', 'GAZ014', 'GAZ015', 'GAZ016', 'GAZ019', 'GAZ020', 'GAZ021', 'GAZ022', 'GAZ023', 'GAZ024', 'GAZ025', 'GAZ027', 'GAZ030', 'GAZ031', 'GAZ032', 'GAZ033', 'GAZ034', 'GAZ035', 'GAZ036', 'GAZ037', 'GAZ038', 'GAZ039', 'GAZ041', 'GAZ042', 'GAZ043', 'GAZ044', 'GAZ045', 'GAZ046', 'GAZ047', 'GAZ048', 'GAZ049', 'GAZ050', 'GAZ051', 'GAZ052', 'GAZ053', 'GAZ054', 'GAZ055', 'GAZ056', 'GAZ057', 'GAZ058', 'GAZ059', 'GAZ060', 'GAZ061', 'GAZ062', 'GAZ066', 'GAZ067', 'GAZ068', 'GAZ069', 'GAZ070', 'GAZ071', 'GAZ072', 'GAZ073', 'GAZ074', 'GAZ075', 'GAZ076', 'GAZ078', 'GAZ079', 'GAZ080', 'GAZ081', 'GAZ082', 'GAZ083', 'GAZ084', 'GAZ085', 'GAZ086', 'GAZ089', 'GAZ090', 'GAZ091', 'GAZ092', 'GAZ093', 'GAZ094', 'GAZ095', 'GAZ096', 'GAZ097', 'GAZ098', 'GAZ102', 'GAZ103', 'GAZ104', 'GAZ105', 'GAZ106', 'GAZ107', 'GAZ108', 'GAZ109', 'GAZ110', 'GAZ111', 'GAZ112', 'GAZ113']}, 'affectedZones': ['https://api.weather.gov/zones/forecast/GAZ013', 'https://api.weather.gov/zones/forecast/GAZ014', 'https://api.weather.gov/zones/forecast/GAZ015', 'https://api.weather.gov/zones/forecast/GAZ016', 'https://api.weather.gov/zones/forecast/GAZ019', 'https://api.weather.gov/zones/forecast/GAZ020', 'https://api.weather.gov/zones/forecast/GAZ021', 'https://api.weather.gov/zones/forecast/GAZ022', 'https://api.weather.gov/zones/forecast/GAZ023', 'https://api.weather.gov/zones/forecast/GAZ024', 'https://api.weather.gov/zones/forecast/GAZ025', 'https://api.weather.gov/zones/forecast/GAZ027', 'https://api.weather.gov/zones/forecast/GAZ030', 'https://api.weather.gov/zones/forecast/GAZ031', 'https://api.weather.gov/zones/forecast/GAZ032', 'https://api.weather.gov/zones/forecast/GAZ033', 'https://api.weather.gov/zones/forecast/GAZ034', 'https://api.weather.gov/zones/forecast/GAZ035', 'https://api.weather.gov/zones/forecast/GAZ036', 'https://api.weather.gov/zones/forecast/GAZ037', 'https://api.weather.gov/zones/forecast/GAZ038', 'https://api.weather.gov/zones/forecast/GAZ039', 'https://api.weather.gov/zones/forecast/GAZ041', 'https://api.weather.gov/zones/forecast/GAZ042', 'https://api.weather.gov/zones/forecast/GAZ043', 'https://api.weather.gov/zones/forecast/GAZ044', 'https://api.weather.gov/zones/forecast/GAZ045', 'https://api.weather.gov/zones/forecast/GAZ046', 'https://api.weather.gov/zones/forecast/GAZ047', 'https://api.weather.gov/zones/forecast/GAZ048', 'https://api.weather.gov/zones/forecast/GAZ049', 'https://api.weather.gov/zones/forecast/GAZ050', 'https://api.weather.gov/zones/forecast/GAZ051', 'https://api.weather.gov/zones/forecast/GAZ052', 'https://api.weather.gov/zones/forecast/GAZ053', 'https://api.weather.gov/zones/forecast/GAZ054', 'https://api.weather.gov/zones/forecast/GAZ055', 'https://api.weather.gov/zones/forecast/GAZ056', 'https://api.weather.gov/zones/forecast/GAZ057', 'https://api.weather.gov/zones/forecast/GAZ058', 'https://api.weather.gov/zones/forecast/GAZ059', 'https://api.weather.gov/zones/forecast/GAZ060', 'https://api.weather.gov/zones/forecast/GAZ061', 'https://api.weather.gov/zones/forecast/GAZ062', 'https://api.weather.gov/zones/forecast/GAZ066', 'https://api.weather.gov/zones/forecast/GAZ067', 'https://api.weather.gov/zones/forecast/GAZ068', 'https://api.weather.gov/zones/forecast/GAZ069', 'https://api.weather.gov/zones/forecast/GAZ070', 'https://api.weather.gov/zones/forecast/GAZ071', 'https://api.weather.gov/zones/forecast/GAZ072', 'https://api.weather.gov/zones/forecast/GAZ073', 'https://api.weather.gov/zones/forecast/GAZ074', 'https://api.weather.gov/zones/forecast/GAZ075', 'https://api.weather.gov/zones/forecast/GAZ076', 'https://api.weather.gov/zones/forecast/GAZ078', 'https://api.weather.gov/zones/forecast/GAZ079', 'https://api.weather.gov/zones/forecast/GAZ080', 'https://api.weather.gov/zones/forecast/GAZ081', 'https://api.weather.gov/zones/forecast/GAZ082', 'https://api.weather.gov/zones/forecast/GAZ083', 'https://api.weather.gov/zones/forecast/GAZ084', 'https://api.weather.gov/zones/forecast/GAZ085', 'https://api.weather.gov/zones/forecast/GAZ086', 'https://api.weather.gov/zones/forecast/GAZ089', 'https://api.weather.gov/zones/forecast/GAZ090', 'https://api.weather.gov/zones/forecast/GAZ091', 'https://api.weather.gov/zones/forecast/GAZ092', 'https://api.weather.gov/zones/forecast/GAZ093', 'https://api.weather.gov/zones/forecast/GAZ094', 'https://api.weather.gov/zones/forecast/GAZ095', 'https://api.weather.gov/zones/forecast/GAZ096', 'https://api.weather.gov/zones/forecast/GAZ097', 'https://api.weather.gov/zones/forecast/GAZ098', 'https://api.weather.gov/zones/forecast/GAZ102', 'https://api.weather.gov/zones/forecast/GAZ103', 'https://api.weather.gov/zones/forecast/GAZ104', 'https://api.weather.gov/zones/forecast/GAZ105', 'https://api.weather.gov/zones/forecast/GAZ106', 'https://api.weather.gov/zones/forecast/GAZ107', 'https://api.weather.gov/zones/forecast/GAZ108', 'https://api.weather.gov/zones/forecast/GAZ109', 'https://api.weather.gov/zones/forecast/GAZ110', 'https://api.weather.gov/zones/forecast/GAZ111', 'https://api.weather.gov/zones/forecast/GAZ112', 'https://api.weather.gov/zones/forecast/GAZ113'], 'references': [], 'sent': '2022-09-27T03:22:00-04:00', 'effective': '2022-09-27T03:22:00-04:00', 'onset': '2022-09-27T03:22:00-04:00', 'expires': '2022-09-27T20:00:00-04:00', 'ends': None, 'status': 'Actual', 'messageType': 'Alert', 'category': 'Met', 'severity': 'Moderate', 'certainty': 'Observed', 'urgency': 'Expected', 'event': 'Special Weather Statement', 'sender': 'w-nws.webmaster@noaa.gov', 'senderName': 'NWS Peachtree City GA', 'headline': 'Special Weather Statement issued September 27 at 3:22AM EDT by NWS Peachtree City GA', 'description': 'Relative Humidities of 25 percent or less can be expected for 4\nor more hours this afternoon into the evening. Winds will be\nnorth-northwest around 10 MPH.\n\nWith dry fuels, high fire danger conditions can be expected.\n\nPlease refer to your local burn permitting authorities\nwhether you may burn outdoors. If you do burn outside,\nuse extreme caution.', 'instruction': None, 'response': 'Execute', 'parameters': {'AWIPSidentifier': ['SPSFFC'], 'WMOidentifier': ['WWUS82 KFFC 270722'], 'NWSheadline': ['HIGH FIRE DANGER CONDITIONS THIS AFTERNOON INTO THE EVENING FOR MUCH OF NORTH AND CENTRAL GEORGIA DUE TO LOW RELATIVE HUMIDITIES'], 'BLOCKCHANNEL': ['EAS', 'NWEM', 'CMAS'], 'EAS-ORG': ['WXR']}}}], 'title': 'current watches, warnings, and advisories for Coweta (GAZ053) GA', 'updated': '2022-09-27T07:23:16+00:00'}
2022-09-27 14:44:13.942 INFO (MainThread) [custom_components.weatheralerts.sensor] Added sensor with name 'Coweta' for feedid 'GAZ053,GAC077'
2022-09-27 14:44:27.485 INFO (SyncWorker_8) [homeassistant.loader] Loaded weather from homeassistant.components.weather
2022-09-27 14:44:28.044 INFO (MainThread) [homeassistant.setup] Setting up weather
2022-09-27 14:44:28.045 INFO (MainThread) [homeassistant.setup] Setup of domain weather took 0.0 seconds
2022-09-27 14:44:40.649 INFO (MainThread) [homeassistant.components.weather] Setting up weather.nws
2022-09-27 14:45:01.283 DEBUG (MainThread) [custom_components.hacs] <Integration custom-components/weatheralerts> Getting repository information
2022-09-27 14:45:01.327 DEBUG (MainThread) [custom_components.hacs] <Plugin kalkih/simple-weather-card> Getting repository information
2022-09-27 14:45:01.807 DEBUG (MainThread) [custom_components.hacs] <Integration custom-components/weatheralerts> Running checks against v0.1.5
2022-09-27 14:45:01.922 DEBUG (MainThread) [custom_components.hacs] <Plugin kalkih/simple-weather-card> Running checks against v0.8.3
drpeppershaker commented 1 year ago

Additional information:

# Weather Alerts
  - platform: weatheralerts
    state: GA
    zone: 53
    county: 77

It appears that everything goes into the Alert attribute, and no other attributes are available to view/call within HA.

{{states['sensor.weatheralerts'].attributes}} gives the following result:

{'alerts': [{'area': 'Forsyth; Hall; Banks; Jackson; Madison; Paulding; Cobb; North Fulton; Gwinnett; Barrow; Clarke; Oconee; Oglethorpe; Wilkes; Carroll; Douglas; South Fulton; DeKalb; Rockdale; Walton; Newton; Morgan; Greene; Taliaferro; Heard; Coweta; Fayette; Clayton; Spalding; Henry; Butts; Jasper; Putnam; Hancock; Warren; Troup; Meriwether; Pike; Upson; Lamar; Monroe; Jones; Baldwin; Washington; Glascock; Jefferson; Harris; Talbot; Taylor; Crawford; Bibb; Twiggs; Wilkinson; Johnson; Emanuel; Muscogee; Chattahoochee; Marion; Schley; Macon; Peach; Houston; Bleckley; Laurens; Treutlen; Stewart; Webster; Sumter; Dooly; Crisp; Pulaski; Wilcox; Dodge; Telfair; Wheeler; Montgomery; Toombs', 'certainty': 'Observed', 'description': 'Relative Humidities of 25 percent or less can be expected for 4\nor more hours this afternoon and early evening. Winds will be\nsouthwest at 5 to 10 MPH. With dry fuels, high fire danger\nconditions can be expected.\n\nPlease refer to your local burn permitting authorities whether\nyou may burn outdoors. If you do burn outside, use extreme\ncaution.', 'ends': None, 'event': 'Special Weather Statement', 'instruction': None, 'response': 'Execute', 'sent': '2022-10-15T11:08:00-04:00', 'severity': 'Moderate', 'title': 'Special Weather Statement issued October 15 at 11:08AM EDT', 'urgency': 'Expected', 'NWSheadline': ['HIGH FIRE DANGER CONDITIONS THIS AFTERNOON AND EARLY EVENING FOR PORTIONS OF NORTH GEORGIA AND MUCH OF CENTRAL GEORGIA DUE TO LOW RELATIVE HUMIDITIES AND DRY FUELS'], 'hailSize': 'null', 'windGust': 'null', 'waterspoutDetection': 'null', 'effective': '2022-10-15T11:08:00-04:00', 'expires': '2022-10-15T20:00:00-04:00', 'endsExpires': '2022-10-15T20:00:00-04:00', 'onset': '2022-10-15T11:08:00-04:00', 'status': 'Actual', 'messageType': 'Alert', 'category': 'Met', 'sender': 'w-nws.webmaster@noaa.gov', 'senderName': 'NWS Peachtree City GA', 'id': 'urn:oid:2.49.0.1.840.0.c842dc6a55018f5d087f462be41bd42cad0347d1.001.1', 'zoneid': 'GAZ053,GAC077'}], 'integration': 'weatheralerts', 'state': 'GA', 'zone': 'GAZ053,GAC077', 'unit_of_measurement': 'Alerts', 'icon': 'mdi:alert-octagram', 'friendly_name': 'Weather Alerts'}

{{state_attr('sensor.weatheralerts', 'alerts')}} returns everything within the above [brackets]

{{state_attr('sensor.weatheralerts', 'NWSheadline')}} returns None

EDIT: The issue here, is I'm using a Meteo Alarm Card but it can't pick up any info beyond there is a yellow alert.

Coolie1101 commented 1 year ago

This is standard behavior, one work around is to apply the following which works exceptionally well, unfortunately, I currently don't have any alerts, so I am unable to show you what it looks like.

https://github.com/custom-components/weatheralerts/tree/a2e08c94d4ba92a22f4a6e9ed80ad127ab2db5cd/packages