Python script that sends a SMS notification when an power outage occurred at a watched location using Hydro-Québec API.
- Python3,
pip
andvirtualenv
installed - GDAL installed
- Twilio account credentials (for SMS)
- Clone this repository
- Setup the virtualenv and activate it
- Install the requirements
- Create a directory named
logs
- Install GDAL module and bindings (see GDAL section)
- Configure your watched locations (see Locations section)
- Configure your Twilio credentials (see Settings section)
First, ensure that you have installed the GDAL library on your system. The Debian package is called libgdal-dev
and the Homebrew package is called gdal
.
To confirm that you have installed GDAL properly, this command should return the installed version:
gdal-config --version
Second, with your virtualenv activated, run the following command to install the GDAL Python package:
pip install GDAL==$(gdal-config --version) --global-option=build_ext --global-option="$(gdal-config --cflags)"
If you get the error "Could not find a version that satisfies the requirement", try to select a previous version from the same major and minor version.
For example, if I'm trying to install 1.10.1
and it's not available, I should try 1.10.0
:
pip install GDAL==1.10.0 --global-option=build_ext --global-option="$(gdal-config --cflags)"
Note that might still not do it. I was able to install GDAL on Debian Jessie, but not on Wheezy.
Create a copy of the file config.yml.dist
named config.yml
.
Add as much locations as you want, following this example:
locations:
Home:
lat: 45.123
lng: -73.456
Work:
lat: 35.123
lng: -75.456
Be sure to write valid YAML document.
Create a copy of the file hqoutage/settings.py.dist
named hqoutage/settings.py
.
Configure your Twilio credentials and phone numbers, following this example:
TWILIO = {
'ACCOUNT_SID': 'AC00000000000000000000000000000000',
'AUTH_TOKEN': '00000000000000000000000000000000',
'FROM': ' +15555555555',
'TO': '+15555555555',
}
Check your Twilio account to get your Account SID and Auth Token.
Install this crontab to run the script every minute:
* * * * * /path/to/env/bin/python /path/to/hq-outage/hqoutage/check.py --log --quiet