Water Alerts is a Python-based application designed to scrape water outage information from a specified website, process the data using OpenAI's API, and publish the results to an MQTT broker.
- Prerequisites
- Installation
- Configuration
- Running the Application
- Crontab Running Script
- Testing
- License
Before you begin, ensure you have the following installed:
- Python 3.8 or higher
- pip (Python package installer)
-
Clone the repository:
git clone https://github.com/Redeagle48/WaterAlerts.git cd WaterAlerts
-
Create a virtual environment:
python -m venv .venv
-
Activate the virtual environment:
-
On Windows:
.venv\Scripts\activate
-
On macOS/Linux:
source .venv/bin/activate
-
-
Install the required packages:
pip install -r requirements.txt
-
Copy the
config.toml
file to the root directory of the project and update the configuration values as needed:[mqtt] broker = "<broker ip>" port = "<broker port>" user = "<mqtt user>" password = "<mqtt pass>" topic = "<mqtt topic>" [openai] api_key = "<openai api key>" model = "<openai model>"
To run the application, execute the following command:
python src/water_alerts.py
This will start the process of scraping water outage information, processing it with OpenAI, and publishing the results to the MQTT broker.
*/30 * * * * /bin/bash -c 'source <path to>/venv/bin/activate && python <path to>/src/water_alerts.py' >> <path to>/logs/script.log 2>&1
0 0 */7 * * truncate -s 0 <path to>/logs/script.log
To run the unit tests, use the following command:
python -m unittest discover -s tests
This project is licensed under the MIT License. See the LICENSE file for details.