Weather Alerts In Multiple Locations

Last modified: August 13, 2014 | Posted in Examples

Since Nebri was just taking shape and a team member needed weather updates, I told him to try IFTTT.  It was a great experience for him, but he quickly hit a wall that made it nearly useless: He couldn’t create weather alerts for multiple locations.

Herein lies the main issues with IFTTT and friends. We must wait for them to enable the functionality we want for integrations and robust plugins. What’s a hacker to do?


Nebri gets around this limitation easily. First connect to your instance and

pip install yweather

Then use a script like this to grab the weather data:

import yweather

class yweather_scraper(NebriOS):
    listens_to = ['check_city_weather','check_country_weather']

    def check(self):
        return self.check_city_weather and self.check_country_weather is not None

    def action(self):
        client = yweather.Client()
        id = client.fetch_woeid(self.check_city_weather + " " + self.check_country_weather)
        weather_dump = client.fetch_weather(id)

        # which type of weather raises the alarm?
        alert_list = ["0","1","2","3","4","24"]

        for i in weather_dump["forecast"]:
            if i["code"] in alert_list:
                self.weather_code = i["code"]
                self.weather_text = i["text"]
                self.weather_date = i["date"]
                self.weather_alert = True

Next you would setup a drip for each City/Country set you would like to monitor. You could put that on a once a day check.

Nebri Drip
You can also make unlimited drips to monitor unlimited locations.

Alright! Now if the alert triggers you can have another script react to the alert. Want to send an SMS? Leave a message in Slack? Send an email? Upload a webcam photo do Dropbox of the effected area? It’s up to you.

Did we say limitless?