jdemaeyer / brightsky

JSON API for DWD's open weather data.
https://brightsky.dev/
MIT License
281 stars 19 forks source link

Strip test alerts from default alerts response #166

Open antonanders opened 2 months ago

antonanders commented 2 months ago

Hi @jdemaeyer,
first of all, thank you for providing this gread piece of software!

Today at 09:20 DWD issued a test warning which got fetched into the database.

As far, as I understand the CAP-Format, there is a "status" field, which can be either "Actual" or "Test". This particular warning had the status "Test". The CAP1.2 standard tells us, any status=Test message must be dropped. Can we implement a logic to drop these messages?

This is part of the CAP message:

<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<alert xmlns="urn:oasis:names:tc:emergency:cap:1.2">
  <identifier>2.49.0.0.276.0.DWD.PVW.1713860400000.2958b7b3-b872-4c5c-b71d-b7341a5b7912.MUL</identifier>
  <sender>opendata@dwd.de</sender>
  <sent>2024-04-23T10:20:00+02:00</sent>
  <status>Test</status>
  <msgType>Alert</msgType>
  <source>PVW</source>
  <scope>Public</scope>
  <code>id:2.49.0.0.276.0.DWD.PVW.1713860400000.2958b7b3-b872-4c5c-b71d-b7341a5b7912</code>
  <info>
    <language>de-DE</language>
    <category>Met</category>
    <event>TEST-WARNUNG</event>
    <responseType>Prepare</responseType>
    <urgency>Immediate</urgency>
    <severity>Minor</severity>
    <certainty>Likely</certainty>

This is the warning you would get from brightsky API.

{
      "id": 41754,
      "alert_id": 41754,
      "effective": "2024-04-23T08:20:00+00:00",
      "onset": "2024-04-23T09:00:00+00:00",
      "expires": "2024-04-23T11:00:00+00:00",
      "category": "met",
      "response_type": "prepare",
      "urgency": "immediate",
      "severity": "minor",
      "certainty": "likely",
      "event_code": 98,
      "event_en": "moderate test warning",
      "event_de": "TEST-WARNUNG",
      "headline_en": "MODERATE TEST WARNING",
      "headline_de": "Amtliche TEST-WARNUNG",
      "description_en": "Test! Test: unclouded moon.\n",
      "description_de": "Test: Test: Heute scheint der Mond.",
      "instruction_en": "NOTE: Be aware of the following possible dangers: barking dogs in the neighborhood.",
      "instruction_de": "ACHTUNG!  TEST  TEST",
      ///...

Best regards, Anton

jdemaeyer commented 2 months ago

Hi @antonanders, thanks for the report and the details! I'll try to add this tomorrow :)

jdemaeyer commented 2 months ago

So much for "I'll try to add this tomorrow"... :sweat_smile:

As a first step, the status field is now (as of v2.1.9) being stored and contained in the Bright Sky response, so at least clients can detect/filter test warnings by themselves. I'm keeping this issue open to track removing test alerts from Bright Sky's default response, only returning them when an include_tests=1 parameter is passed.

Thanks again for the effort over in dwdparse @antonanders