Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
45 changes: 45 additions & 0 deletions .dockerignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
__pycache__/
*.pyc
*.pyo
*.pyd
.Python
pip-log.txt
pip-delete-this-directory.txt
.tox/
.coverage
.coverage.*
.cache
nosetests.xml
coverage.xml
*.cover
*.log
.git
.mypy_cache
.pytest_cache
.hypothesis

# Local environment
.env
.venv
env/
venv/
ENV/
env.bak/
venv.bak/
dist/

# IDEs
.vscode/
.idea/
*.swp
*.swo
*~

# OS
.DS_Store
.DS_Store?
._*
.Spotlight-V100
.Trashes
ehthumbs.db
Thumbs.db
3 changes: 3 additions & 0 deletions .env.example
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
# Copy this to .env and fill in your credentials
CHECKWATT_USERNAME=your_eib_username
CHECKWATT_PASSWORD=your_eib_password
3 changes: 2 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
dist/
__pycache__/
pipx_shared.pth
cw_test.py
cw_test.py
.env
16 changes: 16 additions & 0 deletions Dockerfile.dev
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
FROM python:3.11-slim

WORKDIR /app
# Dependencies
RUN pip install --no-cache-dir poetry
COPY pyproject.toml poetry.lock ./

RUN poetry config virtualenvs.create false \
&& poetry install --only main --no-root --no-interaction --no-ansi

# Dev dependencies
RUN pip install black flake8

ENV PYTHONPATH="${PYTHONPATH}:/app"

CMD ["python"]
33 changes: 33 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -207,6 +207,39 @@ Export: 668.539 kWh

```

## Docker Development

For developers who prefer not to install Python locally, a Docker-based development environment is available.

### Prerequisites

- Docker and Docker Compose installed
- CheckWatt EnergyInBalance credentials

### Quick Start

1. **Set up credentials**
```bash
cp .env.example .env
# Edit .env with your CheckWatt credentials
```

2. **Build, run & cleanup**
```bash
# Build the development container
docker compose -f docker-compose.dev.yml build

# Run the example
docker compose -f docker-compose.dev.yml run --rm pycheckwatt-dev python examples/example.py

# Clean up containers
docker compose -f docker-compose.dev.yml down
```

Inside the container local code changes are automatically synced and you can run standard Python development commands.



# Acknowledgements
This module was developed as a team effort by the following contributors.

Expand Down
18 changes: 18 additions & 0 deletions docker-compose.dev.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
services:
pycheckwatt-dev:
build:
context: .
dockerfile: Dockerfile.dev
volumes:
- .:/app
- pip-cache:/root/.cache/pip
environment:
- CHECKWATT_USERNAME=${CHECKWATT_USERNAME:-}
- CHECKWATT_PASSWORD=${CHECKWATT_PASSWORD:-}
- PYTHONPATH=/app
stdin_open: true
tty: true
working_dir: /app

volumes:
pip-cache:
6 changes: 3 additions & 3 deletions examples/example.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,14 @@

import argparse
import json
import os

from pycheckwatt import CheckwattManager


async def main(show_details=False):
"""Fetch username and password from environment variables."""
username = "EIB username"
password = "EiB password"
username = os.getenv("CHECKWATT_USERNAME")
password = os.getenv("CHECKWATT_PASSWORD")

# Create the async class
async with CheckwattManager(username, password) as check_watt_instance:
Expand Down
Loading