Skip to content

Commit 14a61c5

Browse files
committed
Added project structure
1 parent f306af5 commit 14a61c5

12 files changed

Lines changed: 563 additions & 6 deletions

File tree

.github/workflows/lint.yml

Lines changed: 82 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,82 @@
1+
name: Code Quality
2+
3+
on:
4+
push:
5+
branches: [ main, develop ]
6+
pull_request:
7+
branches: [ main ]
8+
9+
jobs:
10+
lint:
11+
runs-on: ubuntu-latest
12+
strategy:
13+
matrix:
14+
python-version: ["3.8", "3.9", "3.10", "3.11", "3.12"]
15+
16+
steps:
17+
- uses: actions/checkout@v4
18+
19+
- name: Set up Python ${{ matrix.python-version }}
20+
uses: actions/setup-python@v4
21+
with:
22+
python-version: ${{ matrix.python-version }}
23+
24+
- name: Install dependencies
25+
run: |
26+
python -m pip install --upgrade pip
27+
pip install ruff black isort mypy
28+
pip install -e ".[dev]"
29+
30+
- name: Lint with ruff
31+
run: |
32+
# Check for syntax errors and undefined names
33+
ruff check . --select=E9,F63,F7,F82 --show-source
34+
# Run full linting
35+
ruff check .
36+
37+
- name: Check code formatting with black
38+
run: |
39+
black --check --diff .
40+
41+
- name: Check import sorting with isort
42+
run: |
43+
isort --check-only --diff .
44+
45+
- name: Type checking with mypy
46+
run: |
47+
mypy src/vattenfall_charger --ignore-missing-imports
48+
continue-on-error: true # Don't fail on type errors for now
49+
50+
test:
51+
runs-on: ubuntu-latest
52+
needs: lint
53+
strategy:
54+
matrix:
55+
python-version: ["3.8", "3.9", "3.10", "3.11", "3.12"]
56+
57+
steps:
58+
- uses: actions/checkout@v4
59+
60+
- name: Set up Python ${{ matrix.python-version }}
61+
uses: actions/setup-python@v4
62+
with:
63+
python-version: ${{ matrix.python-version }}
64+
65+
- name: Install dependencies
66+
run: |
67+
python -m pip install --upgrade pip
68+
pip install -e ".[dev]"
69+
70+
- name: Run tests
71+
run: |
72+
# For now, just check that the package can be imported
73+
python -c "import vattenfall_charger; print('Package imports successfully')"
74+
# TODO: Add proper tests with pytest
75+
# pytest tests/
76+
77+
- name: Check package build
78+
run: |
79+
pip install build
80+
python -m build
81+
pip install dist/*.whl
82+
python -c "import vattenfall_charger; print('Package installs and imports successfully')"

.github/workflows/publish.yml

Lines changed: 86 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,86 @@
1+
name: Publish Package
2+
3+
on:
4+
release:
5+
types: [published]
6+
workflow_dispatch:
7+
inputs:
8+
environment:
9+
description: 'Environment to deploy to'
10+
required: true
11+
default: 'testpypi'
12+
type: choice
13+
options:
14+
- testpypi
15+
- pypi
16+
17+
jobs:
18+
publish:
19+
runs-on: ubuntu-latest
20+
environment:
21+
name: ${{ github.event_name == 'release' && 'pypi' || github.event.inputs.environment }}
22+
permissions:
23+
id-token: write # For trusted publishing
24+
contents: read
25+
26+
steps:
27+
- uses: actions/checkout@v4
28+
29+
- name: Set up Python
30+
uses: actions/setup-python@v4
31+
with:
32+
python-version: '3.11'
33+
34+
- name: Install build dependencies
35+
run: |
36+
python -m pip install --upgrade pip
37+
pip install build twine
38+
39+
- name: Build package
40+
run: |
41+
python -m build
42+
43+
- name: Check package
44+
run: |
45+
twine check dist/*
46+
47+
- name: Publish to TestPyPI
48+
if: github.event.inputs.environment == 'testpypi' || (github.event_name == 'workflow_dispatch' && github.event.inputs.environment == 'testpypi')
49+
uses: pypa/gh-action-pypi-publish@release/v1
50+
with:
51+
repository-url: https://test.pypi.org/legacy/
52+
password: ${{ secrets.TEST_PYPI_API_TOKEN }}
53+
54+
- name: Publish to PyPI
55+
if: github.event_name == 'release' || github.event.inputs.environment == 'pypi'
56+
uses: pypa/gh-action-pypi-publish@release/v1
57+
with:
58+
password: ${{ secrets.PYPI_API_TOKEN }}
59+
60+
verify-install:
61+
needs: publish
62+
runs-on: ubuntu-latest
63+
strategy:
64+
matrix:
65+
python-version: ["3.8", "3.9", "3.10", "3.11", "3.12"]
66+
67+
steps:
68+
- name: Set up Python ${{ matrix.python-version }}
69+
uses: actions/setup-python@v4
70+
with:
71+
python-version: ${{ matrix.python-version }}
72+
73+
- name: Wait for package availability
74+
run: sleep 60
75+
76+
- name: Install and test package from PyPI
77+
if: github.event_name == 'release' || github.event.inputs.environment == 'pypi'
78+
run: |
79+
pip install vattenfall-charger
80+
python -c "import vattenfall_charger; print('Package installed successfully from PyPI')"
81+
82+
- name: Install and test package from TestPyPI
83+
if: github.event.inputs.environment == 'testpypi'
84+
run: |
85+
pip install --index-url https://test.pypi.org/simple/ --extra-index-url https://pypi.org/simple/ vattenfall-charger
86+
python -c "import vattenfall_charger; print('Package installed successfully from TestPyPI')"

.gitignore

Lines changed: 18 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,20 @@
1+
# Secrets and environment
2+
*.env
13
secrets.env
24

3-
__pycache__
5+
# Python
6+
__pycache__/
7+
*.pyc
8+
*.egg-info/
9+
build/
10+
dist/
11+
.pytest_cache/
12+
13+
# IDEs and OS
14+
.vscode/
15+
.idea/
16+
.DS_Store
17+
18+
# Selenium
19+
chromedriver
20+
*.log

README.md

Lines changed: 151 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,151 @@
1+
# ⚡ Vattenfall Charger Controller 🔌
2+
3+
*Because manually walking to your EV charger is so 2023* 🚗💨
4+
5+
Welcome to the most electrifying Python package you'll ever use! This nifty little tool lets you remotely control your Vattenfall EV charging station from the comfort of your couch, office, or anywhere with an internet connection.
6+
7+
## 🚀 Features That'll Shock You
8+
9+
- **Remote Start**: Start charging your EV without leaving your warm bed
10+
- **WebSocket Magic**: Real-time communication with your charging station
11+
- **Selenium-Powered**: Automates the login process like a digital ninja
12+
- **Environment-Friendly**: Uses environment variables (and saves the planet!)
13+
- **Async/Await**: Because we're not living in the stone age
14+
15+
## 🏗️ Installation
16+
17+
```bash
18+
pip install vattenfall-charger
19+
```
20+
21+
Or if you're feeling adventurous and want to build from source:
22+
23+
```bash
24+
git clone https://github.com/bram/vattenfall-charger.git
25+
cd vattenfall-charger
26+
pip install -e .
27+
```
28+
29+
## 🎮 Quick Start
30+
31+
### Environment Setup
32+
33+
Create a `.env` file or set these environment variables:
34+
35+
```bash
36+
export USERNAME="your@email.com"
37+
export PASSWORD="your_super_secret_password"
38+
export STATION_NAME="EVB-P1234567"
39+
export RFID="12345AB6789C01"
40+
export SUBSCRIPTION_KEY="your_subscription_key_here"
41+
```
42+
43+
### Command Line Usage
44+
45+
```bash
46+
# Start charging like a boss
47+
vattenfall-charger
48+
```
49+
50+
### Python API Usage
51+
52+
```python
53+
import asyncio
54+
from vattenfall_charger import send_remote_start
55+
56+
# Charge your car like it's 2024
57+
asyncio.run(send_remote_start())
58+
```
59+
60+
## 🔧 Development Setup
61+
62+
Want to contribute? Awesome! Here's how to get started:
63+
64+
```bash
65+
# Clone the repo
66+
git clone https://github.com/bram/vattenfall-charger.git
67+
cd vattenfall-charger
68+
69+
# Install development dependencies
70+
pip install -e ".[dev]"
71+
72+
# Run the linter (because clean code is happy code)
73+
ruff check .
74+
75+
# Format your code (make it pretty)
76+
black .
77+
78+
# Run tests (when we have them)
79+
pytest
80+
```
81+
82+
## 🏗️ Project Structure
83+
84+
```
85+
vattenfall-charger/
86+
├── src/
87+
│ └── vattenfall_charger/
88+
│ ├── __init__.py
89+
│ ├── charger.py # Main charging logic
90+
│ ├── login.py # Authentication magic
91+
│ ├── command_utils.py # API utilities
92+
│ └── consts.py # Configuration constants
93+
├── .github/
94+
│ └── workflows/
95+
│ ├── lint.yml # Code quality checks
96+
│ └── publish.yml # Automated publishing
97+
├── setup.py # Package setup
98+
├── requirements.txt # Dependencies
99+
├── pyproject.toml # Modern Python packaging
100+
└── README.md # This awesome file
101+
```
102+
103+
## 🌟 How It Works
104+
105+
1. **Login**: Uses Selenium to authenticate with Vattenfall's portal
106+
2. **Get Tokens**: Retrieves bearer tokens and command IDs
107+
3. **WebSocket Connection**: Establishes a real-time connection
108+
4. **Send Commands**: Sends remote start commands to your charging station
109+
5. **Profit**: Your car starts charging! 🎉
110+
111+
## 🚨 Important Notes
112+
113+
- **Chrome Required**: This package uses Chrome for authentication
114+
- **Credentials**: Keep your credentials safe and never commit them to version control
115+
- **Rate Limits**: Don't spam the API (be nice to the servers)
116+
- **Testing**: Always test in a safe environment first
117+
118+
## 🤝 Contributing
119+
120+
Found a bug? Want to add a feature? PRs are welcome! Just make sure to:
121+
122+
1. Write clean, documented code
123+
2. Follow the existing code style
124+
3. Add tests (when we have a test framework)
125+
4. Update this README if needed
126+
127+
## 📄 License
128+
129+
MIT License - feel free to use this for your own EV charging adventures!
130+
131+
## 🎯 Roadmap
132+
133+
- [ ] Add support for multiple charging stations
134+
- [ ] Implement charging status monitoring
135+
- [ ] Add scheduling capabilities
136+
- [ ] Create a web dashboard
137+
- [ ] Add support for other EV providers (because sharing is caring)
138+
139+
## 💬 Support
140+
141+
Having issues? Found a bug? Want to share your success story?
142+
143+
- 🐛 [Report bugs](https://github.com/bram/vattenfall-charger/issues)
144+
- 💡 [Request features](https://github.com/bram/vattenfall-charger/issues)
145+
- 📚 [Read the docs](https://github.com/bram/vattenfall-charger#readme)
146+
147+
---
148+
149+
*Made with ❤️ and lots of ☕ by developers who are tired of walking to their EV chargers*
150+
151+
**Disclaimer**: This is an unofficial tool and is not affiliated with Vattenfall. Use at your own risk and always follow local regulations regarding EV charging.

0 commit comments

Comments
 (0)