Skip to content

This program is an agent that provides weather forecasts. As you know, knowing the weather is very important in our daily lives. It is implemented using LSTM.

License

Notifications You must be signed in to change notification settings

svendotdev/weather-expectation

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

1 Commit
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Rain Alert Bot 🌧

A Python automation script that checks the weather forecast for your location using the OpenWeather API and sends you an email alert if rain is expected.
Perfect for automating daily weather checks and notifying multiple recipients.


✨ Features

  • Real-time Weather Data — Uses OpenWeather's 5-day/3-hour forecast API.
  • Rain Detection — Alerts if rain is expected in the next 12 hours.
  • Email Notifications — Sends alerts to one or more recipients.
  • Secure Credentials — Uses .env file for API keys and email login (never hardcoded).

🛠️ Prerequisites

  • Python 3.8+
  • Email account with App Password enabled
  • OpenWeather API Key
  • Libraries:
    pip install -r requirements.txt

Setup Instructions

1. Clone the repository:

git clone https://github.com/mudasirfayaz/rain-alert-bot.git
cd rain-alert-bot

2. Install Dependencies

pip install -r requirements.txt

3. Create .env File

Create a .env file in the project root with:

MY_LAT=your_latitude
MY_LONG=your_longitude
SMTP_SERVER="smtp.gmail.com"
MY_EMAIL="your_email@example.com"
APP_PASSWORD="your_email_password_or_app_password"
OWM_API_KEY="your_openweather_api_key"

Note

For Gmail, you must enable 2FA and create an App Password.
Google’s Guide on App Passwords

This script works with most email providers that support SMTP.
Simply update the .env file with the correct SMTP_SERVER value.

Provider SMTP Server
Gmail smtp.gmail.com
Yahoo Mail smtp.mail.yahoo.com
Outlook / Hotmail smtp.office365.com
Zoho Mail smtp.zoho.com
Proton Mail mail.protonmail.com

💡 Tip: Always keep your credentials safe by storing them in .env and never committing that file to GitHub.


4. Update recipients.txt

List one email address per line:

friend@example.com
your_second_email@example.com

5. Run Locally

python main.py

Deployment on PythonAnywhere

This script is designed to run on PythonAnywhere so you don’t need to keep your PC on.

Step 1: Create a PythonAnywhere Account


Step 2: Upload Your Files

  • Go to the Files tab.
  • Upload:
    • main.py
    • requirements.txt
    • recipients.txt
    • .env (upload it too, it will remain private)

Step 3: Test the Script

  • In the Bash console, run:
python3 main.py

If it’s raining today, it should send an email.


Step 5: Schedule the Script

  • Go to the Tasks tab → Add a New Scheduled Task.
  • Set it to run everyday at your preferred time (e.g., 07:00).
  • Command to run:
python3 main.py
  • Click Create.

Your script will now automatically check weather and send email if it's raining today.


Video Reference

📺 Watch one of thes these PythonAnywhere scheduling tutorials:
Schedule Python Tasks on PythonAnywhere
How to Schedule python script on PythonAnywhere

These videos shows how to upload files and set scheduled jobs step-by-step.


🔒 Security Note

Warning

Never commit your .env or recipients.txt files.

  • Use App Passwords if using Gmail.
  • .gitignore is already set up to exclude sensitive files.

🖥 Example Use Cases

  • Personal rain reminders.
  • Group/family weather alerts.
  • Office notifications.
  • Integration into a home automation system.

🧑‍💻 Author

mike star*

Telegram: mikestar https://t.me/manchatz

Twitter: mikestar https://x.com/@EleazarTlapala7


📜 License

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

About

This program is an agent that provides weather forecasts. As you know, knowing the weather is very important in our daily lives. It is implemented using LSTM.

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages