A Python web application that displays instantaneous power usage data. The application authenticates users and shows real-time power data that refreshes every 10 seconds.
- User authentication using the NET2GRID Customer Engagement API
- Display of instantaneous power data for electricity and gas
- Auto-refresh of power data every 10 seconds
- Responsive design for desktop and mobile devices
- Docker containerization for easy deployment
- Docker and Docker Compose
- NET2GRID API credentials (client_id and client_secret)
-
Clone this repository:
git clone <repository-url> cd energyUsage -
Create a
.envfile in the project root with your API credentials:# API Configuration CLIENT_ID=your_client_id CLIENT_SECRET=your_client_secret API_BASE_URL=https://api.n2g-ynni.net # Flask Configuration SECRET_KEY=your_secret_key_for_flask_sessions PORT=5000Replace
your_client_id,your_client_secret, andyour_secret_key_for_flask_sessionswith your actual values.
-
Build the Docker image:
docker build -t energy-usage-app . -
Run the container:
docker run -p 5000:5000 --env-file .env energy-usage-app -
Access the application at http://localhost:5000
-
Install dependencies:
pip install pip-tools pip-compile pyproject.toml --output-file=requirements.txt pip install -r requirements.txt -
Run the application:
python app.py -
Access the application at http://localhost:5000
- Open the application in your web browser
- Log in with your NET2GRID credentials
- View your instantaneous power data on the dashboard
- The data will automatically refresh every 10 seconds
energyUsage/
├── app.py # Main Flask application
├── templates/ # HTML templates
│ ├── login.html # Login page
│ └── dashboard.html # Dashboard page
├── static/ # Static files
│ └── css/
│ └── style.css # CSS styles
├── .env # Environment variables
├── pyproject.toml # Project dependencies
├── Dockerfile # Docker configuration
└── .dockerignore # Docker ignore file
The application uses the NET2GRID Customer Engagement API. The OpenAPI specification can be found in the docs/ directory.