Page 1 of 1

Python Weather Alert Script

Posted: Tuesday 16 January 2018 4:30
by moengiant
The script pulls data from NOAA's rss feeds and checks to see if there is an active alert for the giving area. it will generate an mp3 file that will be played to a Chromecast device or group on the network. There are as well on/off scripts to use with a dummy switch. The script is executed via a lua time script. The scripts as well additional information can be found on my Github:

https://github.com/moengiant/DomoWeatherAlert

Fairly simply to get this up and running - all you need is a Chromecast device and know how to install python modules. Give it a spin and let me know what you like don't like.

Windows 10 | Domoticz Version: 3.8153 | Nest/z-wave/milights/Kodi/LMS/Google Home

Re: Python Weather Alert Script

Posted: Tuesday 16 January 2018 7:19
by Derik
dear..
Thanks for this...

Is there a option for different country's?
And why do i need a cast?

Re: Python Weather Alert Script

Posted: Tuesday 16 January 2018 9:21
by moengiant
Thanks,
It could work with any rss feed however the script will need to be adjusted for the rss feed selected. I created this using the NOAA site as they have an rss feeds for weather alerts in my area as well designed to only work when bad weather coming my way. As for the Chromecast, this script uses a chromecast device or group to play the mp3 in my home. Again the script could be adjusted to play on other players that have an API or python module.

Re: Python Weather Alert Script

Posted: Tuesday 16 January 2018 20:30
by Derik
mmm
do you think i can use the rss from this dutch site?
http://www.knmi.nl/kennis-en-datacentru ... n-het-knmi
last part f the page..

This a great dutch weather site,

Re: Python Weather Alert Script

Posted: Wednesday 17 January 2018 6:24
by moengiant
Derik - Yes this rss could work - http://projects.knmi.nl/RSSread/rss_KNM ... wingen.php. It has some text in the <title> element that looks like there would be a way to determine the severity of the weather - Code (some color) - At the time I looked it the weather condition was Code geel - Code yellow. As such I would bet there is a Code rood or Code red condition.

Editing the script to something like this -

import feedparser

d = feedparser.parse('http://projects.knmi.nl/RSSread/rss_KNM ... wingen.php')

# Need to edit this part to grab the text from the Dutch weather rss elements

# Get the title and entry
title = d.channel.item.title
#print (title)
message = d.channel.item.description
#print (message)

#Need to edit this part to check for Code red

#Checks to see if there are any Code Red alerts
if "Code rood" in message:
alertmessage = title + '.' + message + '.'
print (alertmessage)
else:

exit()

Re: Python Weather Alert Script

Posted: Wednesday 17 January 2018 17:16
by Derik
mm
Is there perhaps a option ti use the internal python editor in domoticz
And us the internal lua
Is better for the backups..

And is there perhaps a option to use text device in stat of Chromecast?

Re: Python Weather Alert Script

Posted: Wednesday 17 January 2018 19:55
by moengiant
The lua part I would say yes as it is a time script, however for the python scripts not so sure as they aren't really triggered by events - other scripts.

I was as well thinking of a few other ways of communicating a weather event. Text, turn a dummy switch on/off, turn a light red and or even to squeezebox (LMS) are just a few ideas I had.

I'm working on a caller ID script now but I'll take a look at adding text message. That would be nice when one is away from their home.

Re: Python Weather Alert Script

Posted: Wednesday 17 January 2018 19:59
by Derik
Mm see now you use Windows..
Need to play with that...

More options are better...😉
Do not have a Google plug...

Re: Python Weather Alert Script

Posted: Friday 19 January 2018 4:39
by moengiant
The script can now send the title of the weather alert via a text message.