finity69x2 / nws_alerts

An updated version of the nws_alerts custom integration for Home Assistant
84 stars 29 forks source link

Expiration processing / removal of outdated and cancelled alerts. #45

Closed rct closed 1 year ago

rct commented 1 year ago

I was looking into duplicated alerts again. While looking the alerts that were duplicated because updated alerts were issued, an alert cancellation was issued. The cancellation removed all current alerts from the NWS forecast page for my area. Home Assistant is currently showing 6 alerts, (3 x 2) because the integration is set up to look for alerts for county NYC103 and zone NYZ081.

I believe this is related to the discussion in #8.

I wanted to capture the data in case it is helpful for figuring this out.

At first glance it looks like `.features[n].parameters.expiredReferences[] contains IDs of previous alerts that should be considered expired/replaced.

"expiredReferences": [
  "
 w-nws.webmaster@noaa.gov,urn:oid:2.49.0.1.840.0.4688160938185b3b61ccc50f1d56ed5d0d33a948.005.1,2022-10-02T08:15:00-04:00
 w-nws.webmaster@noaa.gov,urn:oid:2.49.0.1.840.0.4688160938185b3b61ccc50f1d56ed5d0d33a948.004.1,2022-10-02T08:15:00-04:00
 w-nws.webmaster@noaa.gov,urn:oid:2.49.0.1.840.0.9586416e336141a79ccdbec3e789ec5afc45b378.004.1,2022-10-02T02:40:00-04:00
 w-nws.webmaster@noaa.gov,urn:oid:2.49.0.1.840.0.9586416e336141a79ccdbec3e789ec5afc45b378.003.1,2022-10-02T02:40:00-04:00
 w-nws.webmaster@noaa.gov,urn:oid:2.49.0.1.840.0.acbfc7b3a49ccd7490e1c9e1e7366841b1fe0315.004.1,2022-10-02T04:20:00-04:00 
 w-nws.webmaster@noaa.gov,urn:oid:2.49.0.1.840.0.acbfc7b3a49ccd7490e1c9e1e7366841b1fe0315.003.1,2022-10-02T04:20:00-04:00
 w-nws.webmaster@noaa.gov,urn:oid:2.49.0.1.840.0.46e51765ce159f09a54f1155df6ae93315e3a5a7.004.1,2022-10-01T17:10:00-04:00
 w-nws.webmaster@noaa.gov,urn:oid:2.49.0.1.840.0.46e51765ce159f09a54f1155df6ae93315e3a5a7.003.1,2022-10-01T17:10:00-04:00"

(Somewhat tangential note: It also looks like the ID could be used to coalesce duplicates between the county alerts and zone alerts.)

Just looking at zone NYZ081, the count API says there are 3 active alerts. If I look at https://alerts.weather.gov/cap/wwaatmget.php?x=NYZ081&y=1 it now shows "There are no active ..."

Raw json returned for "https://api.weather.gov/alerts/active?zone=NYZ081"

{
    "@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.21ca73679d00b1d530bd0b88dfdf7b73ba58959b.003.1",
            "type": "Feature",
            "geometry": null,
            "properties": {
                "@id": "https://api.weather.gov/alerts/urn:oid:2.49.0.1.840.0.21ca73679d00b1d530bd0b88dfdf7b73ba58959b.003.1",
                "@type": "wx:Alert",
                "id": "urn:oid:2.49.0.1.840.0.21ca73679d00b1d530bd0b88dfdf7b73ba58959b.003.1",
                "areaDesc": "Northwest Suffolk; Northeast Suffolk; Southeast Suffolk",
                "geocode": {
                    "SAME": [
                        "036103"
                    ],
                    "UGC": [
                        "NYZ078",
                        "NYZ079",
                        "NYZ081"
                    ]
                },
                "affectedZones": [
                    "https://api.weather.gov/zones/forecast/NYZ078",
                    "https://api.weather.gov/zones/forecast/NYZ079",
                    "https://api.weather.gov/zones/forecast/NYZ081"
                ],
                "references": [],
                "sent": "2022-10-02T17:47:00-04:00",
                "effective": "2022-10-02T17:47:00-04:00",
                "onset": "2022-10-02T17:47:00-04:00",
                "expires": "2022-10-02T18:02:36-04:00",
                "ends": "2022-10-02T20:00:00-04:00",
                "status": "Actual",
                "messageType": "Alert",
                "category": "Met",
                "severity": "Minor",
                "certainty": "Observed",
                "urgency": "Past",
                "event": "Coastal Flood Advisory",
                "sender": "w-nws.webmaster@noaa.gov",
                "senderName": "NWS Upton NY",
                "headline": "The Coastal Flood Advisory has been cancelled.",
                "description": "The Coastal Flood Advisory has been cancelled and is no longer in effect.",
                "instruction": null,
                "response": "AllClear",
                "parameters": {
                    "AWIPSidentifier": [
                        "CFWOKX"
                    ],
                    "WMOidentifier": [
                        "WHUS41 KOKX 022147"
                    ],
                    "NWSheadline": [
                        "COASTAL FLOOD ADVISORY IS CANCELLED"
                    ],
                    "BLOCKCHANNEL": [
                        "EAS",
                        "NWEM",
                        "CMAS"
                    ],
                    "VTEC": [
                        "/O.CAN.KOKX.CF.Y.0016.000000T0000Z-221003T0000Z/"
                    ],
                    "eventEndingTime": [
                        "2022-10-03T00:00:00+00:00"
                    ],
                    "expiredReferences": [
                        "w-nws.webmaster@noaa.gov,urn:oid:2.49.0.1.840.0.4688160938185b3b61ccc50f1d56ed5d0d33a948.005.1,2022-10-02T08:15:00-04:00 w-nws.webmaster@noaa.gov,urn:oid:2.49.0.1.840.0.4688160938185b3b61ccc50f1d56ed5d0d33a948.004.1,2022-10-02T08:15:00-04:00 w-nws.webmaster@noaa.gov,urn:oid:2.49.0.1.840.0.9586416e336141a79ccdbec3e789ec5afc45b378.004.1,2022-10-02T02:40:00-04:00 w-nws.webmaster@noaa.gov,urn:oid:2.49.0.1.840.0.9586416e336141a79ccdbec3e789ec5afc45b378.003.1,2022-10-02T02:40:00-04:00 w-nws.webmaster@noaa.gov,urn:oid:2.49.0.1.840.0.acbfc7b3a49ccd7490e1c9e1e7366841b1fe0315.004.1,2022-10-02T04:20:00-04:00 w-nws.webmaster@noaa.gov,urn:oid:2.49.0.1.840.0.acbfc7b3a49ccd7490e1c9e1e7366841b1fe0315.003.1,2022-10-02T04:20:00-04:00 w-nws.webmaster@noaa.gov,urn:oid:2.49.0.1.840.0.46e51765ce159f09a54f1155df6ae93315e3a5a7.004.1,2022-10-01T17:10:00-04:00 w-nws.webmaster@noaa.gov,urn:oid:2.49.0.1.840.0.46e51765ce159f09a54f1155df6ae93315e3a5a7.003.1,2022-10-01T17:10:00-04:00"
                    ]
                }
            }
        },
        {
            "id": "https://api.weather.gov/alerts/urn:oid:2.49.0.1.840.0.4688160938185b3b61ccc50f1d56ed5d0d33a948.004.1",
            "type": "Feature",
            "geometry": null,
            "properties": {
                "@id": "https://api.weather.gov/alerts/urn:oid:2.49.0.1.840.0.4688160938185b3b61ccc50f1d56ed5d0d33a948.004.1",
                "@type": "wx:Alert",
                "id": "urn:oid:2.49.0.1.840.0.4688160938185b3b61ccc50f1d56ed5d0d33a948.004.1",
                "areaDesc": "Northeast Suffolk; Southwest Suffolk; Southeast Suffolk",
                "geocode": {
                    "SAME": [
                        "036103"
                    ],
                    "UGC": [
                        "NYZ079",
                        "NYZ080",
                        "NYZ081"
                    ]
                },
                "affectedZones": [
                    "https://api.weather.gov/zones/forecast/NYZ079",
                    "https://api.weather.gov/zones/forecast/NYZ080",
                    "https://api.weather.gov/zones/forecast/NYZ081"
                ],
                "references": [
                    {
                        "@id": "https://api.weather.gov/alerts/urn:oid:2.49.0.1.840.0.9586416e336141a79ccdbec3e789ec5afc45b378.003.1",
                        "identifier": "urn:oid:2.49.0.1.840.0.9586416e336141a79ccdbec3e789ec5afc45b378.003.1",
                        "sender": "w-nws.webmaster@noaa.gov",
                        "sent": "2022-10-02T02:40:00-04:00"
                    },
                    {
                        "@id": "https://api.weather.gov/alerts/urn:oid:2.49.0.1.840.0.acbfc7b3a49ccd7490e1c9e1e7366841b1fe0315.003.1",
                        "identifier": "urn:oid:2.49.0.1.840.0.acbfc7b3a49ccd7490e1c9e1e7366841b1fe0315.003.1",
                        "sender": "w-nws.webmaster@noaa.gov",
                        "sent": "2022-10-02T04:20:00-04:00"
                    }
                ],
                "sent": "2022-10-02T08:15:00-04:00",
                "effective": "2022-10-02T08:15:00-04:00",
                "onset": "2022-10-02T15:00:00-04:00",
                "expires": "2022-10-02T16:15:00-04:00",
                "ends": "2022-10-02T20:00:00-04:00",
                "status": "Actual",
                "messageType": "Update",
                "category": "Met",
                "severity": "Minor",
                "certainty": "Likely",
                "urgency": "Expected",
                "event": "Coastal Flood Advisory",
                "sender": "w-nws.webmaster@noaa.gov",
                "senderName": "NWS Upton NY",
                "headline": "Coastal Flood Advisory issued October 2 at 8:15AM EDT until October 2 at 8:00PM EDT by NWS Upton NY",
                "description": "* WHAT...Up to one foot of inundation above ground level\nexpected in vulnerable areas near the waterfront and shoreline.\n\n* WHERE...Northeast Suffolk, Southwest Suffolk and Southeast\nSuffolk Counties.\n\n* WHEN...From 3 PM this afternoon to 8 PM EDT this evening.\n\n* IMPACTS...Minor flooding is expected in the more vulnerable\nlocations near the waterfront and shoreline. Some roads and\nlow lying properties including parking lots, parks, lawns, and\nhomes and businesses with basements near the waterfront will\nexperience minor flooding.\n\n* ADDITIONAL DETAILS...Minor to localized moderate flooding may\nbe possible with the Monday afternoon and early evening high\ntide cycle.",
                "instruction": "If travel is required, allow extra time as some roads may be\nclosed. Do not drive around barricades or through water of\nunknown depth. Take the necessary actions to protect flood-prone\nproperty.",
                "response": "Monitor",
                "parameters": {
                    "AWIPSidentifier": [
                        "CFWOKX"
                    ],
                    "WMOidentifier": [
                        "WHUS41 KOKX 021215"
                    ],
                    "NWSheadline": [
                        "COASTAL FLOOD ADVISORY REMAINS IN EFFECT FROM 3 PM THIS AFTERNOON TO 8 PM EDT THIS EVENING"
                    ],
                    "BLOCKCHANNEL": [
                        "EAS",
                        "NWEM",
                        "CMAS"
                    ],
                    "VTEC": [
                        "/O.CON.KOKX.CF.Y.0016.221002T1900Z-221003T0000Z/"
                    ],
                    "eventEndingTime": [
                        "2022-10-03T00:00:00+00:00"
                    ],
                    "expiredReferences": [
                        "w-nws.webmaster@noaa.gov,urn:oid:2.49.0.1.840.0.46e51765ce159f09a54f1155df6ae93315e3a5a7.003.1,2022-10-01T17:10:00-04:00"
                    ]
                }
            }
        },
        {
            "id": "https://api.weather.gov/alerts/urn:oid:2.49.0.1.840.0.46e51765ce159f09a54f1155df6ae93315e3a5a7.003.1",
            "type": "Feature",
            "geometry": null,
            "properties": {
                "@id": "https://api.weather.gov/alerts/urn:oid:2.49.0.1.840.0.46e51765ce159f09a54f1155df6ae93315e3a5a7.003.1",
                "@type": "wx:Alert",
                "id": "urn:oid:2.49.0.1.840.0.46e51765ce159f09a54f1155df6ae93315e3a5a7.003.1",
                "areaDesc": "Northeast Suffolk; Southwest Suffolk; Southeast Suffolk",
                "geocode": {
                    "SAME": [
                        "036103"
                    ],
                    "UGC": [
                        "NYZ079",
                        "NYZ080",
                        "NYZ081"
                    ]
                },
                "affectedZones": [
                    "https://api.weather.gov/zones/forecast/NYZ079",
                    "https://api.weather.gov/zones/forecast/NYZ080",
                    "https://api.weather.gov/zones/forecast/NYZ081"
                ],
                "references": [],
                "sent": "2022-10-01T17:10:00-04:00",
                "effective": "2022-10-01T17:10:00-04:00",
                "onset": "2022-10-02T15:00:00-04:00",
                "expires": "2022-10-02T01:15:00-04:00",
                "ends": "2022-10-02T20:00:00-04:00",
                "status": "Actual",
                "messageType": "Alert",
                "category": "Met",
                "severity": "Minor",
                "certainty": "Likely",
                "urgency": "Expected",
                "event": "Coastal Flood Advisory",
                "sender": "w-nws.webmaster@noaa.gov",
                "senderName": "NWS Upton NY",
                "headline": "Coastal Flood Advisory issued October 1 at 5:10PM EDT until October 2 at 8:00PM EDT by NWS Upton NY",
                "description": "* WHAT...Up to one half foot of inundation above ground level\nexpected in vulnerable areas near the waterfront and shoreline.\n\n* WHERE...Northeast Suffolk, Southwest Suffolk and Southeast\nSuffolk Counties.\n\n* WHEN...From 3 PM to 8 PM EDT Sunday.\n\n* IMPACTS...Minor flooding is expected in the more vulnerable\nlocations near the waterfront and shoreline. Some roads and low\nlying properties including parking lots, parks, lawns, and homes\nand businesses with basements near the waterfront will\nexperience minor flooding.\n\n* ADDITIONAL DETAILS...Minor to localized moderate flooding may be\npossible with the Monday afternoon and early evening high tide\ncycle.",
                "instruction": "If travel is required, allow extra time as some roads may be\nclosed. Do not drive around barricades or through water of\nunknown depth. Take the necessary actions to protect flood-prone\nproperty.",
                "response": "Monitor",
                "parameters": {
                    "AWIPSidentifier": [
                        "CFWOKX"
                    ],
                    "WMOidentifier": [
                        "WHUS41 KOKX 012110"
                    ],
                    "NWSheadline": [
                        "COASTAL FLOOD ADVISORY IN EFFECT FROM 3 PM TO 8 PM EDT SUNDAY"
                    ],
                    "BLOCKCHANNEL": [
                        "EAS",
                        "NWEM",
                        "CMAS"
                    ],
                    "VTEC": [
                        "/O.NEW.KOKX.CF.Y.0016.221002T1900Z-221003T0000Z/"
                    ],
                    "eventEndingTime": [
                        "2022-10-03T00:00:00+00:00"
                    ]
                }
            }
        }
    ],
    "title": "current watches, warnings, and advisories for Southeast Suffolk (NYZ081) NY",
    "updated": "2022-10-02T21:47:42+00:00"
}
finity69x2 commented 1 year ago

Sorry I'm so late to this but I'm not having any issues with cancelled/expired alerts not being removed.

Is this still an issue?