About this project

This is an electricity monitoring tool for Nanjing University dormitory users, mainly addressing the problem that electricity balance can only be viewed through an app or website and is difficult to track over time. The project provides a Python script that automatically logs into the Nanjing University electricity recharge system, supporting both traditional CAPTCHA (ddddocr OCR) and slider verification (captcha-recognizer AI recognition), and can automatically detect the current verification type and perform multiple retry rounds. The collected remaining electricity balance is saved as JSON and CSV files, while also generating historical electricity change curve charts. The project has integrated GitHub Actions, allowing scheduled automatic execution after configuring NJU_USERNAME and NJU_PASSWORD in repository Secrets, without requiring local deployment. The workflow supports sending email alerts when the electricity balance falls below thresholds, which can be adjusted in config_workflow.json, for example general alert at 200 kWh, important alert at 10 kWh, and urgent alert at 5 kWh. Local execution requires Python 3.9+, Chrome browser, and ChromeDriver, and the monitoring or visualization web dashboard can be started with one click via batch files. The web dashboard provides an interactive electricity curve and data table with zooming, dragging, and hover viewing, adapted for both desktop and mobile. The project also includes auxiliary tools for environment testing, page structure debugging, and CAPTCHA recognition testing, and provides troubleshooting instructions for common issues such as PIL compatibility, ChromeDriver version matching, and OCR recognition failures.