[Essentials] Severe Weather and Natural Disaster Warning

I have a bash script for Canadian weather alerts that will interrupt mycroft and speak weather warning and display weather alerts on my version of Mycroft local/remote TFT display

it gets it’s info from environment Canada RSS feed

https://weather.gc.ca/warnings/index_e.html just edit the zone to match the RSS zone for your region

#!/bin/bash

ZONE="mb19_e.xml"    # enviroment Canada rss zone
#ZONE="nt16_e.xml"

prev="$(cat prev)"
OUTPUT="$(curl -s  https://weather.gc.ca/rss/battleboard/${ZONE} | sed -n 's:.*<title>\(.*\)</title>.*:\1:p' | sed  '1d' | sed  's/in effect//gI' | cut -d',' -f1)"
echo "${OUTPUT}"
NO_WHITESPACE="$(echo -e "${OUTPUT}" | tr -d '[:space:]')"

if [ $NO_WHITESPACE == 'Noalerts' ]
then
 if [ $prev == 'Noalerts'  ]
 then
     echo " "
 else
      echo 'cmd_9(clear)' > /dev/ttyS2  #send command to serial to display on local TFT screen
      mosquitto_pub -h 192.168.168.150 -t '/ai/clear' -m '1' #sends command to remote wifi connected TFT screen
 fi
   echo "${NO_WHITESPACE}" > prev
   echo  all is good
elif [ $NO_WHITESPACE == 'FrostWarning' ]   #silent Alarm just display warning on TFT Screen
 then
 echo 'cmd_5(Frost Warning)' > /dev/ttyS2
 mosquitto_pub -h 192.168.168.150 -t '/ai/clear' -m '1'
 mosquitto_pub -h 192.168.168.150 -t '/ai/station' -m 'Frost Warning'
 echo  "frost warning"
else                                       # full alarm   speech and display
/home/ai/mycroft-core/bin/mycroft-say-to stop
mpv Alarm.wav
echo 'cmd_5(Weather Alert)' > /dev/ttyS2
mosquitto_pub -h 192.168.168.150 -t '/ai/station' -m 'Weather Alert'
echo 'cmd_6($OUTPUT)' > /dev/ttyS2
mosquitto_pub -h 192.168.168.150 -t '/ai/artist' -m "${OUTPUT}"
/home/ai/mycroft-core/bin/mycroft-speak  weather alert     ${OUTPUT}
echo  ${OUTPUT}
echo "${NO_WHITESPACE}" > prev
fi

is just runs every 10 minutes to get alarm data

2 Likes

Check this out for NOAA weather alerts: https://github.com/domcross/noaa-alerts-skill.git - WARNING: work in progress…

(Meteoalarm’s AtomPub API turned out to be quite unstable, e.g. the endpoint for Germany does not work at all, so I change plans and started implementing the NOAA skill first…)

2 Likes

Just found out that there is such thing as Common Alerting Protocol - at least NOAA and Meteoalert APIs return their alerts in this format, which makes parsing the messages much easier…

2 Likes

I made my bash script into a skill for environment Canada

I made it work with both mycroft and my TFT remote mqtt displays for mycroft ( will work still if you do not have a screen) . for extreme weather such as tornado, hurricane wreckhouse winds, it will stop mycroft current operation beep a alarm and read out the warning… for milder severe conditions such as lighting and heavy rainfall it will play either a thunderstorm or rain noise in the background. in an attempt to be less intrusive… for other milder severe weather it will have a simple bleep ( about a 1 second tone ) . to interact with it in mycroft just say “weather Alerts”, “any weather alerts” and then it will read out the current weather alerts, and the current condition and near future forecast . since I do not know every weather condition. i asked evcan development team for transcript of a there possible condition they never got back to me. so if it beeps out warning on conditions that you wish not to beep out a loud warning just edit ALERT2 and add in another elif for that condition. it very easy to do. it just the warning fully capitalize with out white spaces.

currently it suppose to make a configuration page on mycroft.ai but it not for something reason, maybe I did some wrong with that. but i also can not communicate with mycroft servers either at the moment . that started about noon today for me - actually it went bonkers today . some python section got corrupt in mycroft after a OS software update and forced me to delete mycroft-core and install again… but it seamed to be something in .mycroft folder as on my first install the same problem still existed after the new install. then I deleted .mycroft , deleted the core and skills folders again and it installed properly after that. but it will not pair or communicate with mycroft servers. but it working with out the pairing at the moment for some reason never even asked to pair like it usually does either - weird anyways
here the error on that

 ~~: /v1/device/ (Caused by ConnectTimeoutError(<urllib3.connection.VerifiedHTTPSConnection object at 0x7fee8046d048>, 'Connection to api.mycroft.ai timed out. (connect timeout=3.05)'))"))

~

2 Likes

environment Canada sent me a link to their warning criteria that includes their watch and warning ( which is unusual as it was Sunday) , so i updated the skill with all of them, so in its current form on low level events and air quality it will only display on the screen and accessible via mycroft … on mid level events it has a bleep every 10 minutes . for thunderstorms and rainfall I gave them special sounds as they can develop fast and deadly… Tsunami and tornado have full alarm (PLUS any event that pops up that environment Canada did not send me info on .)

2 Likes

Updated the NOAA alert skill - basic functionality is now working. You can set desired levels for urgency, severity and certainty. Filtering to alerts with sent-date or expiry-date >= the current day.

what is on my to-do list: scheduled retrieval of new/updated alerts and automatic announcement of severe immediate alerts that are nearby.

Any test results and suggestions/features requests are welcome…

2 Likes

That’s awesome, thanks for the excellent work as always Dominik!!

My NOAA alerts skill is now available for testing: NOAA Alerts skill

And for the european community members here is the beta-version of meteoalert-skill which uses meteoalarm.eu

NOTE: the API/ATOM-service of meteoalarm.eu is broken and fails for some countries, e.g. Germany: http://meteoalarm.eu/ATOM/DE.xml - you can try your country-code (instead of “DE”), if you don’t get a “404” error the skill will work for your country…

The “meteoalertapi” library from pypi.org which I use is not as comprehensive as the noaa-sdk that i use for the noaa-skill. It looks like only the latest alert is returned in case there are multiple alerts and some attributes are already filtered (sent-date, status, messagetype).

seams like the german one breaks it down to provinces/states/counties/ but you can extract every thing from the rss feed to for that region… similar to how i do my Evcan as it also breaks the country down in 100’s of different regions too

but clicking around it would seam rss feed would be better as that cover most countries other then France and Belgium… atom only seams to does about +50% of the countries only way I see getting every country to work is scraping the counties web page for weather warning and then break it down to regions looks like lynx could do it easy enough- all you need is country webpage and the region and using the image as the trigger as they use the same image no mater what the language is used … I think I could write a bash script to process the alert - for the heck i give it try

On a first glance the RSS feeds from meteoalarm.eu seem to have far less information than the ATOM feeds (RSS lacks CAP meta-tagging, so you can’t filter by severity, etc.)

Turns out there is the World Meteorological Organization which has a “live map of severe weather” and a listing of CAP feeds for many countries. I will have a deeper look into this in the next days, maybe a lot more services than NOAA and Meteoalarm can be included in a skill… :thinking:

1 Like

seams lynx worked easy enough

calling a the progam test then passing the weblink

#!/bin/bash
 lynx -dump $1  | sed -n '/^Weather warnings/,/^   Display/p' | sed '1d;$d'

example
./test http://meteoalarm.eu/en_UK/0/0/LT005-Panevėžio%20apskritis.html

gives you this as result :

[aw102.jpg]
valid from 16.07.2019 00:00 CET Until 16.07.2019 23:59 CET
Rain Awareness Level: Yellow
lietuviu:
dieną vietomis gausus lietus

english:
BY DAY LOCALLY HEAVY RAIN.

[aw32.jpg]
valid from 16.07.2019 00:00 CET Until 16.07.2019 23:59 CET
Thunderstorms Awareness Level: Yellow
lietuviu:
Dieną perkūnija

english:
At day thunderstorm

[aw12.jpg]
valid from 16.07.2019 00:00 CET Until 16.07.2019 23:59 CET
Wind Awareness Level: Yellow
lietuviu:
dieną vietomis škvalas, 15-20 m/s

english:
BY DAY LOCALLY SQUALL.

or passing this to it http://meteoalarm.eu/en_UK/0/0/IT018-Sicilia.html gives you

[aw33.jpg]
valid from 16.07.2019 01:00 CET Until 17.07.2019 00:59 CET
Thunderstorms Awareness Level: Orange
english:
No Special Awareness Required BE PREPARED. Take precautions and keep up
to date with the latest weather forecast. Expect some disruption to
daily routines and BE PREPARED for disruption to outdoor activities.

italiano:
Nessun Avviso ESSERE PREPARATI. Prendere le dovute precauzioni e
tenersi aggiornati con le ultime previsioni del tempo. Aspettarsi
qualche interruzione delle normali attività quotidiane ed essere pronti
per interruzione delle attività all’aria aperta.

[aw103.jpg]
valid from 16.07.2019 01:00 CET Until 17.07.2019 00:59 CET
Rain Awareness Level: Orange
english:
No Special Awareness Required BE PREPARED. Take precautions and keep up
to date with the latest weather forecast. Expect some disruption to
daily routines and BE PREPARED for disruption to outdoor activities.

italiano:
Nessun Avviso ESSERE PREPARATI. Prendere le dovute precauzioni e
tenersi aggiornati con le ultime previsioni del tempo. Aspettarsi
qualche interruzione delle normali attività quotidiane ed essere pronti
per interruzione delle attività all’aria aperta.

[aw12.jpg]
valid from 16.07.2019 01:00 CET Until 16.07.2019 18:59 CET
Wind Awareness Level: Yellow
english:
No Special Awareness Required BE AWARE, keep up to date with the latest
weather forecast. Expect some minor disruption to outdoor activities

italiano:
Nessun Avviso STARE (RIMANERE) ATTENTI. Tenersi aggiornati con le
previsioni del tempo più recenti. Aspettarsi alcuni disagi minori per
le attività all’aria aperta.

which you can process farther easy enough for severity – oh well just a thought

update; tried a few different countries one country seams to a slightly different format so this works for all that I tried

  lynx -dump $1  | sed -n '/Weather warnings/,/Display/p' | sed '1,/Caption:/!d'  | sed '1d;$d'

Update 2
and if you want to process in any European language use this

#!/bin/bash
lynx -dump $1 | sed -n “/$2/,/Display/p” | sed “1,/$3:/!d” | sed ‘1d;$d’

and the command format is
./test http://meteoalarm.eu/li_LT/0/0/IT017-Basilicata.html ‘Perspejimai: Basilicata’ Caption

the commandline argument --web address the --alert section title , what they call the legend on the countries page ( only necessary if very small county with no provinces/states or counties listed)

1 Like

there you go a simple bash script probably could do it in python i guess if I knew how :blush: … but it should process any page or language for alarms from meteoalarm.eu

#!/bin/bash

########### get alert Data##############

lynx -dump $1  | sed -n "/$2/,/Display/p" | sed "1,/$3:/!d"  | sed '1d;$d'  > w.buf
# lynx -dump $1  | sed -n '/Weather warnings/,/Display/p' | sed '1,/Caption:/!d'  | sed '1d;$d' > w.buf
input="$(cat w.buf | grep .jpg )"
#echo $input

################## Split alerts ################
while IFS= read -r LINE
do

SPLIT="$(echo $LINE | tr -d '[]' | tr -d '[:space:]')"

cat w.buf | sed -n "/$SPLIT/, $ p" | head -3 | sed '1d' > tmp.w  

input2="$(cat tmp.w)"
if [ -z "$input2" ]
then
  echo "No Alerts Founds"
else
############## process alerts further  ################
############## or simply allow it to feed back into the skill######
  echo $input2 
fi
done  <<< "$input"

feel free to use it or adapt to python if you like–

it outputs this

from — http://meteoalarm.eu/en_UK/0/0/IT018-Sicilia.html current weather ( i did not extract the language just the alerts)

valid from 16.07.2019 09:00 CET Until 16.07.2019 20:59 CET Thunderstorms Awareness Level: Orange
valid from 16.07.2019 09:00 CET Until 16.07.2019 20:59 CET Rain Awareness Level: Orange
valid from 16.07.2019 09:00 CET Until 16.07.2019 19:59 CET Wind Awareness Level: Yellow

update :
oh well waiting for my tractor battery to charge —
if you want language: just add to

########### get alert Data##############
declare -i cnt=0

############## process alerts further ################
if [ $cnt == 0 ]
then
((cnt++))
cat w.buf | sed -n “/$4/,/^ *$/p” | awk ‘!seen[$1,$2]++’
fi

and stipulate the language ie from the above example

./test http://meteoalarm.eu/en_UK/0/0/IT018-Sicilia.html 'Weather warnings' Caption italiano: 

to print out italian weather warning - english: for english version

./test  http://meteoalarm.eu/en_UK/0/0/GR010-Ionion%20Islands.html 'Weather warnings' Caption english:

   english:
   SEVERE THUNDERSTORMS ACCOMPANIED BY HAIL IN PLACES AND GUSTY WINDS.

valid from 16.07.2019 13:00 CET Until 16.07.2019 23:59 CET Thunderstorms Awareness Level: Red

if you want to trim timestamp edit this
cat w.buf | sed -n “/$SPLIT/, $ p” | head -3 | sed ‘1d’ > tmp.w
to
cat w.buf | sed -n “/$SPLIT/, $ p” | head -3 | sed ‘1d;2d’ > tmp.w

1 Like

Update: i am now able to parse CAP data from most of the national warning services that are listed by the Severe Weather Information Center. (Some of the services do not respond properly or provide only test messages.)

Right now i am working on geolocation filtering (turns out there a lot of different schematics for that), as you most likely don’t want to hear warnings about regions that are hundreds of miles away from your own location.

When everything works out as i want my NOAA and Meteoalert skills will become obsolete…

So here it is Severe Weather Information Skill

Currently local weather services for 24 countries are supported, the list will be updated and extended in the future.

Scheduled updates and automatic notification is not implemented yet. My NOAA and Meteoalert skills are now obsolete, i will archive the Github repos soon.

2 Likes

I literally made an account to say, well done on this! Without pulling out the soap box, this sort of thing is proof positive that AI assistants can truly offer something of significant (and potentially life-saving) value to humans, not just make our lives slightly easier.

In theory, would something like this be connectable to an RPi weather station that is pushing readings over a local wifi network? I live in the Alps where storm systems come in fast and hard, but a sharp increase in wind speed is usually the first reliable sign that a storm is on its way. A few extra minutes or warning could make all the difference (bringing kids/pets inside, locking down shutters etc.).

I’ve only just started dabbling in Python, but seeing you make something like this is great motivation to spend a good few hours on my Udemy course this weekend!

1 Like

I think you could use a sharp drop in air pressure. that would happen several minutes before the winds start to increase dramatically … yeah it easily do able to your RPI or esp weather station

1 Like

Testing season for the severe weather information skill has begun…

Nothing says we couldn’t just do
weather_data = subprocess.run(‘your bash’, capture_output=True)

I love pure python though, but this seams easier.

Hi Guys,

I am working on my final year BSc dissertation.

Topic: Implementing Mycroft to read (announce) the water level in the occurrence of flood alerts.
Hardware and software requirement: Raspberry pi, Ultrasonic sensor,
Is there anyone who has a broad knowledge of how I can go about this, please?