The Temperature Alert project utilizes the uAgent library to provide a convenient tool for users to monitor real-time temperatures in a specified location. This project is designed for anyone who wants to receive temperature alerts based on their preferences. Here's what Temperature Alert can do:
- Connects to a free weather API to fetch real-time temperatures for the specified location.
- Allows users to set their preferred temperature range, including a minimum and maximum temperature.
- Sends an alert/notification to the user when the current temperature in their chosen location falls below the minimum or rises above the maximum threshold they've set.
Before you start using Temperature Alert, ensure you have the following prerequisites installed:
- Python (version 3.8 or higher is recommended)
- Poetry (a packaging and dependency management tool for Python)
You can install Poetry by following the instructions here.
To run the Temperature Alert project, you'll need API keys from two sources:
- Visit OpenWeather and sign up or log in.
- Your API key will be available on the dashboard. Use the "Current Weather" data option.
- Visit API Ninjas and sign up or log in.
- Your API key will be available on the dashboard. Use the "Geocoding API."
server.address
Visit Uagents Doc
Once you have obtained these API keys, create a .env
file in the src
directory with the following content:
export WEATHER_API_KEY="{YOUR OPEN WEATHER API KEY}"
export LOCATION_API_KEY="{YOUR API NINJAS GEOCODING API KEY}"
export SERVER_ADDRESS="{YOUR SERVER ADRRESS}"
To use the environment variables from .env and install the project:
bash
poetry intall
poetry shell
pip install -r requirements.txt
To run the project and its agents:
bash
cd src
poetry run python main.py
You need to look for the following output in the logs:
ALERT: Temperature(21.980000000000018°C) is above maximum temperature i.e (20.0°C)
You will get alert as Push notifications as alerts. You can set your personalised minimum as well as maximum temperature for alert