Python Weather Alert Script

Python and python framework

Moderator: leecollings

Post Reply
moengiant
Posts: 28
Joined: Monday 25 January 2016 6:33
Target OS: Windows
Domoticz version:
Contact:

Python Weather Alert Script

Post 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
Derik
Posts: 1602
Joined: Friday 18 October 2013 23:33
Target OS: Raspberry Pi / ODroid
Domoticz version: BETA
Location: Arnhem/Nijmegen Nederland
Contact:

Re: Python Weather Alert Script

Post by Derik »

dear..
Thanks for this...

Is there a option for different country's?
And why do i need a cast?
Xu4: Beta Extreme antenna RFXcomE,WU Fi Ping ip P1 Gen5 PVOutput Harmony HUE SolarmanPv OTG Winddelen Alive ESP Buienradar MySensors WOL Winddelen counting RPi: Beta SMAspot RFlinkTest Domoticz ...Different backups
moengiant
Posts: 28
Joined: Monday 25 January 2016 6:33
Target OS: Windows
Domoticz version:
Contact:

Re: Python Weather Alert Script

Post 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.
I'd rather have a bottle in front of me than a frontal lobotomy
Derik
Posts: 1602
Joined: Friday 18 October 2013 23:33
Target OS: Raspberry Pi / ODroid
Domoticz version: BETA
Location: Arnhem/Nijmegen Nederland
Contact:

Re: Python Weather Alert Script

Post 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,
Xu4: Beta Extreme antenna RFXcomE,WU Fi Ping ip P1 Gen5 PVOutput Harmony HUE SolarmanPv OTG Winddelen Alive ESP Buienradar MySensors WOL Winddelen counting RPi: Beta SMAspot RFlinkTest Domoticz ...Different backups
moengiant
Posts: 28
Joined: Monday 25 January 2016 6:33
Target OS: Windows
Domoticz version:
Contact:

Re: Python Weather Alert Script

Post 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()
I'd rather have a bottle in front of me than a frontal lobotomy
Derik
Posts: 1602
Joined: Friday 18 October 2013 23:33
Target OS: Raspberry Pi / ODroid
Domoticz version: BETA
Location: Arnhem/Nijmegen Nederland
Contact:

Re: Python Weather Alert Script

Post 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?
Xu4: Beta Extreme antenna RFXcomE,WU Fi Ping ip P1 Gen5 PVOutput Harmony HUE SolarmanPv OTG Winddelen Alive ESP Buienradar MySensors WOL Winddelen counting RPi: Beta SMAspot RFlinkTest Domoticz ...Different backups
moengiant
Posts: 28
Joined: Monday 25 January 2016 6:33
Target OS: Windows
Domoticz version:
Contact:

Re: Python Weather Alert Script

Post 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.
Last edited by moengiant on Wednesday 17 January 2018 20:01, edited 1 time in total.
I'd rather have a bottle in front of me than a frontal lobotomy
Derik
Posts: 1602
Joined: Friday 18 October 2013 23:33
Target OS: Raspberry Pi / ODroid
Domoticz version: BETA
Location: Arnhem/Nijmegen Nederland
Contact:

Re: Python Weather Alert Script

Post by Derik »

Mm see now you use Windows..
Need to play with that...

More options are better...😉
Do not have a Google plug...
Xu4: Beta Extreme antenna RFXcomE,WU Fi Ping ip P1 Gen5 PVOutput Harmony HUE SolarmanPv OTG Winddelen Alive ESP Buienradar MySensors WOL Winddelen counting RPi: Beta SMAspot RFlinkTest Domoticz ...Different backups
moengiant
Posts: 28
Joined: Monday 25 January 2016 6:33
Target OS: Windows
Domoticz version:
Contact:

Re: Python Weather Alert Script

Post by moengiant »

The script can now send the title of the weather alert via a text message.
I'd rather have a bottle in front of me than a frontal lobotomy
Post Reply

Who is online

Users browsing this forum: No registered users and 1 guest