Skip to content

Python-based application designed to scrape water outage information from a water company website

Notifications You must be signed in to change notification settings

Redeagle48/WaterAlerts

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

19 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Water Alerts

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.

Table of Contents

Prerequisites

Before you begin, ensure you have the following installed:

  • Python 3.8 or higher
  • pip (Python package installer)

Installation

  1. Clone the repository:

    git clone https://github.com/Redeagle48/WaterAlerts.git
    cd WaterAlerts
  2. Create a virtual environment:

    python -m venv .venv
  3. Activate the virtual environment:

    • On Windows:

      .venv\Scripts\activate
    • On macOS/Linux:

      source .venv/bin/activate
  4. Install the required packages:

    pip install -r requirements.txt

Configuration

  1. 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>"

Running the Application

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.

Crontab Running Script

Execution job

*/30 * * * * /bin/bash -c 'source <path to>/venv/bin/activate && python <path to>/src/water_alerts.py' >> <path to>/logs/script.log 2>&1

Truncate log file

0 0 */7 * * truncate -s 0 <path to>/logs/script.log

Testing

To run the unit tests, use the following command:

python -m unittest discover -s tests

License

This project is licensed under the MIT License. See the LICENSE file for details.

About

Python-based application designed to scrape water outage information from a water company website

Resources

Stars

Watchers

Forks

Releases

No releases published

Languages