Skip to content

sebaxtian/tangara-email-notifications

Repository files navigation

tangara-email-notifications

Email notifications related to Tangara Sensors, when any sensor doesn't report data or isn't available.


Requirements

  • Python 3:

  • 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.
    • 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:
{
    "token": "ya29.a0ARrdaM-3sywDwFLToHz6CuMI6X7aGzfCsh0VHcv_0S2ykDiHBTQjN_IYllDGop0TEmCdfD_XjLOBhcyQA1wCXUm0ISxyWY0p4Fm33XEeZXj2Zk_4DeC9G_BjehT3ShcRaX5ljQrV83ejBSWEqyeVNRPzhlVn",
    "refresh_token": "1//0dW7ynmcwPg-LCgYIARAAGA0SNwF-L9IrfnJg9Sy9ZdGrcL1tL9oRzdgTJxdYb86Ww4gL7jnlFn7TGclMekW5VADkJB5YQYiuL1s",
    "expiry": "2022-07-01T03:31:50.460388Z"
}

Environment Variables

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

Source Code

See ./src directory.

Inputs

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

Outputs

Here is the sensors_status.csv file, this dataset contains the report about when each Tangara sensor was down or is up.

How to use

Please read and execute each step below:

Step 1

Create and use Python virtual environment:

$promt> python -m venv .venv
$promt> source .venv/bin/activate

Step 2

Install all Python requirements:

$promt> python -m pip install -U pip
$promt> pip install -r requirements.txt

Step 3

Run Email Notifications Script:

$promt> python src/notify_subscribers.py -n -s input/sensors.csv

Optional

Generate a requirements file and then install from it in another environment:

$promt> pip freeze > requirements.txt

That's all for now ...


License

GPL-3.0 License

About me

https://about.me/sebaxtian

About

Email notifications related to Tangara Sensors, when any sensor doesn't report data or isn't available. https://tangara.chis.pa/

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published