Email notifications related to Tangara Sensors, when any sensor doesn't report data or isn't available.
-
Python 3:
- See requirements.txt file.
-
Gmail API Credentials:
- Please follow the official instructions to get the credentials.json file, this one has a JSON structure similar to the example.credentials.json file.
- See https://developers.google.com/gmail/api/quickstart/python The credentials.json file must be ignored from the repository
- Refresh Token:
- This is a token.json file created when the script is first to run, this one has a JSON structure similar to the example.token.json file, this file will be used to refresh the Gmail API token. The token.json file must only have the follow structure:
- Please follow the official instructions to get the credentials.json file, this one has a JSON structure similar to the example.credentials.json file.
{
"token": "ya29.a0ARrdaM-3sywDwFLToHz6CuMI6X7aGzfCsh0VHcv_0S2ykDiHBTQjN_IYllDGop0TEmCdfD_XjLOBhcyQA1wCXUm0ISxyWY0p4Fm33XEeZXj2Zk_4DeC9G_BjehT3ShcRaX5ljQrV83ejBSWEqyeVNRPzhlVn",
"refresh_token": "1//0dW7ynmcwPg-LCgYIARAAGA0SNwF-L9IrfnJg9Sy9ZdGrcL1tL9oRzdgTJxdYb86Ww4gL7jnlFn7TGclMekW5VADkJB5YQYiuL1s",
"expiry": "2022-07-01T03:31:50.460388Z"
}
Setup your own values to environment variables, use the example.env file, and save your custom values as a .env file. The .env file must be ignored from the repository
See ./src directory.
There are a couple of inputs to the Email Notifications, use the mailing_list.csv file to subscribe people that will be notified, They will be the people in charge of any Tangara sensor, and use the sensors.csv file to register each Tangara sensor. Please use the example.mailing_list.csv to create the mailing_list.csv file. The mailing_list.csv file must be ignored from the repository
Here is the sensors_status.csv file, this dataset contains the report about when each Tangara sensor was down or is up.
Please read and execute each step below:
Create and use Python virtual environment:
$promt> python -m venv .venv
$promt> source .venv/bin/activate
Install all Python requirements:
$promt> python -m pip install -U pip
$promt> pip install -r requirements.txt
Run Email Notifications Script:
$promt> python src/notify_subscribers.py -n -s input/sensors.csv
Generate a requirements file and then install from it in another environment:
$promt> pip freeze > requirements.txt
That's all for now ...