HK radiation notification 香港輻射監測
Go to file
fred42 74a140fb86 fix 9999 value 2024-04-13 10:38:39 +02:00
.env add .env example 2023-08-31 09:02:14 +00:00
.gitignore Initial commit 2023-08-31 08:58:24 +00:00
LICENSE Initial commit 2023-08-31 08:58:24 +00:00
README.md 更新「README.md」 2023-08-31 09:46:20 +00:00
radiation.py fix 9999 value 2024-04-13 10:38:39 +02:00
requirements.txt first commit 2023-08-31 09:00:00 +00:00

README.md

HK radiation E-mail notification

Based on data from the Hong Kong Observatory [https://www.hko.gov.hk/en/index.html].

Requirements

  • Python 3.6+
  • requests
  • mailtrap
  • python-dotenv

Usage

  1. install the requirements
pip install -r requirements.txt
  1. create the .env file
# for sending email
MAILTRAP_API_KEY=your_mailtrap_api_key
MAIL_FROM=mailtrap@you_domain_within_mailtrap
MAIL_TO=the_mail_you_want_to_send_to
THRESHOLD=0.3

# data source
RADIATION_URL=https://www.hko.gov.hk/radiation/monitoring/data/rmn_hourly_mean_used.txt
  1. Run
python radiation.py
  1. cron job
# check every half an hour
15,45 * * * * python /path/to/radiation.py

Notes

  • This project uses mailtrap [https://mailtrap.io/] to send emails, you need to bind your own domain name to send emails. You can send 1000 emails per month for free. You don't need a cell phone number or a payment method to sign up for an account.
  • This project uses requests to obtain hourly radiation detection data from the Hong Kong Observatory.
  • The data log file is in the project root directory and is named all_data_log.log. If the radiation level exceeds 0.3, an email alert will only be sent once every 6 hours.