The Temperature Alert Agent is a Python script that uses the uAgents library to fetch real-time temperatures from a free weather API for a specified location. It allows users to set their preferred temperature range (minimum and maximum temperature) and sends an alert/notification when the current temperature in the chosen location goes below the minimum or above the maximum threshold.
To run the Temperature Alert Agent, follow these steps:
-
Clone the repository to your local machine:
git clone https://github.com/yourusername/temperature-alert-agent.git
-
Navigate to the project directory:
cd HackAI_Hack-23067 cd src cd uagents
-
Install the required dependencies using Poetry:
poetry install
-
Set your OpenWeatherMap API key and preferred location in the
hackathon.py
script:api_key = "Your_OpenWeatherMap_API_Key" location = "Your_Location" # e.g., "London, UK" min_temperature = 20 # Minimum preferred temperature in °C max_temperature = 30 # Maximum preferred temperature in °C
-
Run the Temperature Alert Agent:
python hackathon.py
The agent will start fetching the current temperature for the specified location and send alerts if the temperature goes outside the preferred range.
- Make sure you have a valid OpenWeatherMap API key. You can obtain one by signing up on the OpenWeatherMap website.
- The agent fetches temperature data every 30 minutes by default. You can adjust the update interval by changing the
period
parameter in thecheck_temperature
method in thehackathon.py
script. - Ensure that your environment allows outbound internet connections for API requests.
Feel free to reach out for any questions or assistance with running the Temperature Alert Agent.