driveeClient 0.1.0__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (46) hide show
  1. driveeclient-0.1.0/.gitignore +39 -0
  2. driveeclient-0.1.0/LICENSE +21 -0
  3. driveeclient-0.1.0/LOCAL_TESTING.md +307 -0
  4. driveeclient-0.1.0/MANIFEST.in +23 -0
  5. driveeclient-0.1.0/PKG-INFO +163 -0
  6. driveeclient-0.1.0/README.md +119 -0
  7. driveeclient-0.1.0/__init__.py +73 -0
  8. driveeclient-0.1.0/driveeClient.egg-info/SOURCES.txt +43 -0
  9. driveeclient-0.1.0/drivee_client/__init__.py +71 -0
  10. driveeclient-0.1.0/drivee_client/drivee_client.py +321 -0
  11. driveeclient-0.1.0/drivee_client/dtos/__init__.py +46 -0
  12. driveeclient-0.1.0/drivee_client/dtos/base_dto.py +20 -0
  13. driveeclient-0.1.0/drivee_client/dtos/charge_point_dto.py +18 -0
  14. driveeclient-0.1.0/drivee_client/dtos/charging_history_dto.py +18 -0
  15. driveeclient-0.1.0/drivee_client/dtos/charging_period_dto.py +16 -0
  16. driveeclient-0.1.0/drivee_client/dtos/charging_responses_dto.py +11 -0
  17. driveeclient-0.1.0/drivee_client/dtos/charging_session_dto.py +40 -0
  18. driveeclient-0.1.0/drivee_client/dtos/connector_dto.py +11 -0
  19. driveeclient-0.1.0/drivee_client/dtos/currency_dto.py +34 -0
  20. driveeclient-0.1.0/drivee_client/dtos/evse_dto.py +26 -0
  21. driveeclient-0.1.0/drivee_client/dtos/payment_details_dto.py +22 -0
  22. driveeclient-0.1.0/drivee_client/dtos/power_stats_dto.py +11 -0
  23. driveeclient-0.1.0/drivee_client/dtos/price_periods_dto.py +11 -0
  24. driveeclient-0.1.0/drivee_client/errors/__init__.py +117 -0
  25. driveeclient-0.1.0/drivee_client/models/__init__.py +22 -0
  26. driveeclient-0.1.0/drivee_client/models/base_model.py +62 -0
  27. driveeclient-0.1.0/drivee_client/models/charge_point.py +75 -0
  28. driveeclient-0.1.0/drivee_client/models/charging_history.py +36 -0
  29. driveeclient-0.1.0/drivee_client/models/charging_response.py +21 -0
  30. driveeclient-0.1.0/drivee_client/models/charging_session.py +156 -0
  31. driveeclient-0.1.0/drivee_client/models/connector.py +78 -0
  32. driveeclient-0.1.0/drivee_client/models/currency.py +53 -0
  33. driveeclient-0.1.0/drivee_client/models/evse.py +120 -0
  34. driveeclient-0.1.0/drivee_client/models/power_stats.py +15 -0
  35. driveeclient-0.1.0/drivee_client/models/power_stats_history_entry.py +17 -0
  36. driveeclient-0.1.0/drivee_client/models/price_periods.py +27 -0
  37. driveeclient-0.1.0/drivee_client/models/types.py +73 -0
  38. driveeclient-0.1.0/pyproject.toml +129 -0
  39. driveeclient-0.1.0/requirements.txt +6 -0
  40. driveeclient-0.1.0/setup.cfg +4 -0
  41. driveeclient-0.1.0/tests/actions_helper.py +19 -0
  42. driveeclient-0.1.0/tests/test_charge_point.py +35 -0
  43. driveeclient-0.1.0/tests/test_charging_history.py +23 -0
  44. driveeclient-0.1.0/tests/test_charging_session.py +23 -0
  45. driveeclient-0.1.0/tests/test_drivee_client.py +194 -0
  46. driveeclient-0.1.0/tests/test_prices.py +35 -0
@@ -0,0 +1,39 @@
1
+ # Environment variables
2
+ .env
3
+ .env.example
4
+ # Python
5
+ __pycache__/
6
+ *.py[cod]
7
+ *$py.class
8
+ *.so
9
+ .Python
10
+ build/
11
+ develop-eggs/
12
+ dist/
13
+ downloads/
14
+ eggs/
15
+ .eggs/
16
+ lib/
17
+ lib64/
18
+ parts/
19
+ sdist/
20
+ var/
21
+ wheels/
22
+ *.egg-info/
23
+ .installed.cfg
24
+ *.egg
25
+
26
+ # Virtual Environment
27
+ venv/
28
+ env/
29
+ ENV/
30
+
31
+ # IDE
32
+ .idea/
33
+ .vscode/
34
+ *.swp
35
+ *.swo
36
+
37
+ # OS
38
+ .DS_Store
39
+ Thumbs.db
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2025 Your Name
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
@@ -0,0 +1,307 @@
1
+ # Local Testing Guide for drivee-client
2
+
3
+ This guide explains how to test the `drivee-client` package locally before publishing to PyPI.
4
+
5
+ ## 🎯 Testing Methods
6
+
7
+ ### Method 1: Editable Install (Recommended for Development)
8
+
9
+ **Best for:** Active development where you're making frequent changes.
10
+
11
+ ```bash
12
+ # Install in editable mode
13
+ python build.py install-local
14
+
15
+ # Or manually:
16
+ pip install -e .
17
+ ```
18
+
19
+ **Advantages:**
20
+
21
+ - ✅ Changes to source code are immediately reflected
22
+ - ✅ No need to rebuild after each change
23
+ - ✅ Can use debugger and see source code
24
+ - ✅ Perfect for development workflow
25
+
26
+ **Test it:**
27
+
28
+ ```bash
29
+ # Run the test script
30
+ python test_local_install.py
31
+
32
+ # Or test manually in Python
33
+ python -c "from drivee_client import DriveeClient; print('Success!')"
34
+ ```
35
+
36
+ **Uninstall when done:**
37
+
38
+ ```bash
39
+ pip uninstall drivee-client
40
+ ```
41
+
42
+ ---
43
+
44
+ ### Method 2: Install from Built Distribution
45
+
46
+ **Best for:** Testing the actual package before publishing to PyPI.
47
+
48
+ ```bash
49
+ # Build the package
50
+ python build.py build
51
+
52
+ # Install from the built wheel
53
+ python build.py install-dist
54
+
55
+ # Or manually:
56
+ pip install dist/drivee_client-*.whl --force-reinstall
57
+ ```
58
+
59
+ **Advantages:**
60
+
61
+ - ✅ Tests the exact package that will be published
62
+ - ✅ Verifies package metadata and dependencies
63
+ - ✅ Ensures all files are included correctly
64
+ - ✅ Validates the installation process
65
+
66
+ **Important:** You need to rebuild and reinstall after each code change.
67
+
68
+ ---
69
+
70
+ ### Method 3: Test from Test PyPI
71
+
72
+ **Best for:** Final validation before production release.
73
+
74
+ ```bash
75
+ # Build and upload to Test PyPI
76
+ python build.py all
77
+ python build.py test-upload
78
+
79
+ # Install from Test PyPI
80
+ pip install --index-url https://test.pypi.org/simple/drivee-client
81
+
82
+ # Or with dependencies from regular PyPI
83
+ pip install --index-url https://test.pypi.org/simple/ --extra-index-url https://pypi.org/simple/drivee-client
84
+ ```
85
+
86
+ **Advantages:**
87
+
88
+ - ✅ Tests the complete publishing workflow
89
+ - ✅ Validates package on a real PyPI server
90
+ - ✅ Safe environment (won't affect production)
91
+ - ✅ Can share test version with others
92
+
93
+ ---
94
+
95
+ ## 📋 Complete Testing Workflow
96
+
97
+ ### Step 1: Development Testing
98
+
99
+ ```bash
100
+ # Install in editable mode
101
+ python build.py install-local
102
+
103
+ # Run tests
104
+ pytest
105
+
106
+ # Run the verification script
107
+ python test_local_install.py
108
+
109
+ # Test your code manually
110
+ python -c "
111
+ import asyncio
112
+ from drivee_client import DriveeClient
113
+
114
+ async def test():
115
+ async with DriveeClient('user', 'pass') as client:
116
+ print('Client created successfully!')
117
+
118
+ asyncio.run(test())
119
+ "
120
+ ```
121
+
122
+ ### Step 2: Pre-publish Testing
123
+
124
+ ```bash
125
+ # Clean and build
126
+ python build.py all
127
+
128
+ # Install from dist to test the package
129
+ python build.py install-dist
130
+
131
+ # Run full test suite
132
+ pytest
133
+
134
+ # Run the verification script
135
+ python test_local_install.py
136
+ ```
137
+
138
+ ### Step 3: Test PyPI Validation
139
+
140
+ ```bash
141
+ # Upload to Test PyPI
142
+ python build.py test-upload
143
+
144
+ # Create a new virtual environment for clean testing
145
+ python -m venv test_env
146
+ test_env\Scripts\activate # Windows
147
+ # source test_env/bin/activate # Linux/Mac
148
+
149
+ # Install from Test PyPI
150
+ pip install --index-url https://test.pypi.org/simple/ --extra-index-url https://pypi.org/simple/ drivee-client
151
+
152
+ # Test the package
153
+ python test_local_install.py
154
+
155
+ # Deactivate and cleanup
156
+ deactivate
157
+ ```
158
+
159
+ ### Step 4: Production Release
160
+
161
+ ```bash
162
+ # Only after all tests pass!
163
+ python build.py upload
164
+ ```
165
+
166
+ ---
167
+
168
+ ## 🧪 Testing Checklist
169
+
170
+ Before publishing to PyPI, ensure:
171
+
172
+ - [ ] All unit tests pass (`pytest`)
173
+ - [ ] Package builds without errors (`python build.py build`)
174
+ - [ ] Package passes twine check (`python build.py check`)
175
+ - [ ] Local install works (`python build.py install-local`)
176
+ - [ ] Verification script passes (`python test_local_install.py`)
177
+ - [ ] Version number updated in `drivee_client/__init__.py`
178
+ - [ ] CHANGELOG.md updated with changes
179
+ - [ ] README.md is accurate and up-to-date
180
+ - [ ] All dependencies are listed in `pyproject.toml`
181
+ - [ ] Test PyPI upload successful (`python build.py test-upload`)
182
+ - [ ] Installation from Test PyPI works
183
+ - [ ] Git changes committed and tagged
184
+
185
+ ---
186
+
187
+ ## 🐛 Troubleshooting
188
+
189
+ ### "no running event loop" error
190
+
191
+ If you see `RuntimeError: no running event loop` when trying to instantiate `DriveeClient`:
192
+
193
+ **Problem:** The `DriveeClient` creates an `aiohttp.ClientSession` in `__init__`, which requires an active event loop.
194
+
195
+ **Solution:** Always instantiate and use `DriveeClient` within an async context:
196
+
197
+ ```python
198
+ import asyncio
199
+ from drivee_client import DriveeClient
200
+
201
+ # ❌ Wrong - will fail with "no running event loop"
202
+ client = DriveeClient("user", "pass")
203
+
204
+ # ✅ Correct - use within async function
205
+ async def main():
206
+ async with DriveeClient("user", "pass") as client:
207
+ await client.init()
208
+ # Your code here
209
+
210
+ asyncio.run(main())
211
+ ```
212
+
213
+ ### "Module not found" after installation
214
+
215
+ ```bash
216
+ # Ensure you're in the right environment
217
+ pip list | grep drivee
218
+
219
+ # Try reinstalling
220
+ pip uninstall drivee-client
221
+ python build.py install-local
222
+ ```
223
+
224
+ ### Changes not reflected after editing code
225
+
226
+ ```bash
227
+ # If using editable install, restart Python interpreter
228
+ # If using dist install, rebuild and reinstall
229
+ python build.py build
230
+ python build.py install-dist
231
+ ```
232
+
233
+ ### Import errors for dependencies
234
+
235
+ ```bash
236
+ # Install dependencies manually
237
+ pip install aiohttp pydantic tenacity python-dotenv
238
+
239
+ # Or from the project
240
+ pip install -r requirements.txt
241
+ ```
242
+
243
+ ### Package metadata issues
244
+
245
+ ```bash
246
+ # Check the built package
247
+ python build.py build
248
+ python build.py check
249
+
250
+ # Inspect the wheel contents
251
+ pip install wheel
252
+ wheel unpack dist/drivee_client-*.whl
253
+ ```
254
+
255
+ ---
256
+
257
+ ## 💡 Tips
258
+
259
+ 1. **Always use virtual environments** to avoid conflicts:
260
+
261
+ ```bash
262
+ python -m venv venv
263
+ venv\Scripts\activate # Windows
264
+ ```
265
+
266
+ 2. **Use pytest fixtures** for testing async code:
267
+
268
+ ```python
269
+ import pytest
270
+ from drivee_client import DriveeClient
271
+
272
+ @pytest.mark.asyncio
273
+ async def test_client():
274
+ async with DriveeClient("user", "pass") as client:
275
+ assert client is not None
276
+ ```
277
+
278
+ 3. **Mock API calls** during testing:
279
+
280
+ ```python
281
+ from unittest.mock import AsyncMock, patch
282
+
283
+ @patch('aiohttp.ClientSession.post')
284
+ async def test_login(mock_post):
285
+ mock_post.return_value.__aenter__.return_value.json = AsyncMock(
286
+ return_value={"token": "test_token"}
287
+ )
288
+ # Your test code here
289
+ ```
290
+
291
+ 4. **Test with different Python versions** if supporting multiple versions:
292
+
293
+ ```bash
294
+ # Using pyenv or virtualenv for each version
295
+ python3.10 -m venv venv310
296
+ python3.11 -m venv venv311
297
+ python3.12 -m venv venv312
298
+ ```
299
+
300
+ ---
301
+
302
+ ## 📚 Additional Resources
303
+
304
+ - [Python Packaging Guide](https://packaging.python.org/)
305
+ - [Testing with pytest](https://docs.pytest.org/)
306
+ - [Test PyPI](https://test.pypi.org/)
307
+ - [Twine Documentation](https://twine.readthedocs.io/)
@@ -0,0 +1,23 @@
1
+ include README.md
2
+ include LICENSE
3
+ include requirements.txt
4
+ include pyproject.toml
5
+ recursive-include drivee_client *.py
6
+ recursive-include tests *.py
7
+ recursive-include docs *.md *.rst
8
+ global-exclude *.pyc
9
+ global-exclude __pycache__
10
+ global-exclude .DS_Store
11
+ global-exclude *.so
12
+ global-exclude build.py
13
+ global-exclude package_build.py
14
+ global-exclude package_build_script.py
15
+ global-exclude test_local_install.py
16
+ global-exclude main.py
17
+ prune .git
18
+ prune .github
19
+ prune .vscode
20
+ prune build
21
+ prune dist
22
+ prune *.egg-info
23
+ prune actions
@@ -0,0 +1,163 @@
1
+ Metadata-Version: 2.4
2
+ Name: driveeClient
3
+ Version: 0.1.0
4
+ Summary: Python client library for automation and control of an EV Wallbox charger via local API or cloud endpoints
5
+ Author-email: Your Name <your.email@example.com>
6
+ Maintainer-email: Your Name <your.email@example.com>
7
+ License: MIT
8
+ Project-URL: Homepage, https://github.com/yourusername/drivee-client
9
+ Project-URL: Repository, https://github.com/yourusername/drivee-client
10
+ Project-URL: Issues, https://github.com/yourusername/drivee-client/issues
11
+ Project-URL: Documentation, https://github.com/yourusername/drivee-client#readme
12
+ Keywords: ev,charging,wallbox,drivee,electric-vehicle,api-client
13
+ Classifier: Development Status :: 4 - Beta
14
+ Classifier: Intended Audience :: Developers
15
+ Classifier: License :: OSI Approved :: MIT License
16
+ Classifier: Operating System :: OS Independent
17
+ Classifier: Programming Language :: Python :: 3
18
+ Classifier: Programming Language :: Python :: 3.10
19
+ Classifier: Programming Language :: Python :: 3.11
20
+ Classifier: Programming Language :: Python :: 3.12
21
+ Classifier: Topic :: Software Development :: Libraries :: Python Modules
22
+ Classifier: Topic :: Home Automation
23
+ Classifier: Topic :: Internet :: WWW/HTTP :: HTTP Servers
24
+ Requires-Python: >=3.10
25
+ Description-Content-Type: text/markdown
26
+ License-File: LICENSE
27
+ Requires-Dist: aiohttp>=3.8.0
28
+ Requires-Dist: pydantic>=2.0.0
29
+ Requires-Dist: tenacity>=8.0.0
30
+ Requires-Dist: python-dotenv>=1.0.0
31
+ Provides-Extra: dev
32
+ Requires-Dist: pytest>=7.0.0; extra == "dev"
33
+ Requires-Dist: pytest-asyncio>=0.21.0; extra == "dev"
34
+ Requires-Dist: black>=23.0.0; extra == "dev"
35
+ Requires-Dist: isort>=5.12.0; extra == "dev"
36
+ Requires-Dist: flake8>=6.0.0; extra == "dev"
37
+ Requires-Dist: mypy>=1.0.0; extra == "dev"
38
+ Requires-Dist: pylance; extra == "dev"
39
+ Provides-Extra: test
40
+ Requires-Dist: pytest>=7.0.0; extra == "test"
41
+ Requires-Dist: pytest-asyncio>=0.21.0; extra == "test"
42
+ Requires-Dist: pytest-cov>=4.0.0; extra == "test"
43
+ Dynamic: license-file
44
+
45
+ # Drivee Client
46
+
47
+ A Python client library for automation and control of EV Wallbox chargers via the Drivee cloud API.
48
+
49
+ [![PyPI version](https://badge.fury.io/py/drivee-client.svg)](https://badge.fury.io/py/drivee-client)
50
+ [![Python Support](https://img.shields.io/pypi/pyversions/drivee-client.svg)](https://pypi.org/project/drivee-client/)
51
+ [![License: MIT](https://img.shields.io/badge/License-MIT-yellow.svg)](https://opensource.org/licenses/MIT)
52
+
53
+ ## Installation
54
+
55
+ ```bash
56
+ pip install drivee-client
57
+ ```
58
+
59
+ ## Quick Start
60
+
61
+ ```python
62
+ import asyncio
63
+ from drivee_client import DriveeClient
64
+
65
+ async def main():
66
+ async with DriveeClient("username", "password") as client:
67
+ await client.init()
68
+
69
+ # Get charge point info
70
+ charge_point = await client.get_charge_point()
71
+ print(f"Charge point: {charge_point.name}")
72
+ print(f"Status: {charge_point.evse.status}")
73
+
74
+ # Start charging
75
+ response = await client.start_charging()
76
+ print(f"Started session: {response.session.id}")
77
+
78
+ # Get charging history
79
+ history = await client.get_charging_history()
80
+ for session in history.sessions:
81
+ print(f"Session {session.id}: {session.energy/1000:.2f}kWh")
82
+
83
+ if __name__ == "__main__":
84
+ asyncio.run(main())
85
+ ```
86
+
87
+ ## Features
88
+
89
+ - **Async/await support** - Built with `aiohttp` for non-blocking I/O
90
+ - **Type-safe** - Full type hints with Pydantic models
91
+ - **Error handling** - Comprehensive error handling with custom exceptions
92
+ - **Rate limiting** - Built-in retry logic with exponential backoff
93
+ - **Clean architecture** - Separation of DTOs and business models
94
+ - **Domain validation** - Business rule validation in model layer
95
+
96
+ ## Architecture
97
+
98
+ The client library follows a clear separation of concerns with three main layers:
99
+
100
+ ### Data Transfer Objects (DTOs)
101
+
102
+ Located in `dtos/`, these are pure data classes that:
103
+
104
+ - Match the exact structure of API responses
105
+ - Use Pydantic for validation and serialization
106
+ - Have no business logic
107
+ - Follow naming convention: All DTO classes end with 'DTO' suffix
108
+ - Are only used within the model layer
109
+
110
+ ### Business Models
111
+
112
+ Located in `models/`, these classes:
113
+
114
+ - Encapsulate DTOs and provide business logic
115
+ - Expose only business-relevant properties and methods
116
+ - Use Protocol-based typing for DTO interfaces
117
+ - Handle all business rules and validations
118
+ - Are the only classes exposed to the Home Assistant integration
119
+
120
+ ### API Client
121
+
122
+ The `drivee_client.py` handles:
123
+
124
+ - REST API communication
125
+ - Authentication
126
+ - Request/response mapping to DTOs
127
+ - Error handling and retries
128
+
129
+ ## Installation
130
+
131
+ 1. Copy the `custom_components/drivee` folder to your Home Assistant's `custom_components` directory.
132
+ 2. Restart Home Assistant.
133
+
134
+ ## Configuration
135
+
136
+ 1. Go to Home Assistant's Settings > Devices & Services
137
+ 2. Click "Add Integration"
138
+ 3. Search for "Drivee"
139
+ 4. Enter your Drivee API base URL
140
+ 5. (Optional) Enter your API key if required
141
+
142
+ ## Usage
143
+
144
+ After configuration, you can control your Drivee device through Home Assistant's interface. The integration will create a switch entity that you can use to control your device.
145
+
146
+ ## Development
147
+
148
+ To develop or modify this integration:
149
+
150
+ 1. Clone this repository
151
+ 2. Install dependencies:
152
+
153
+ ```bash
154
+ pip install -r requirements.txt
155
+ ```
156
+
157
+ 3. Make your changes
158
+ 4. Test the integration locally
159
+ 5. Copy the modified files to your Home Assistant's `custom_components` directory
160
+
161
+ ## License
162
+
163
+ MIT License
@@ -0,0 +1,119 @@
1
+ # Drivee Client
2
+
3
+ A Python client library for automation and control of EV Wallbox chargers via the Drivee cloud API.
4
+
5
+ [![PyPI version](https://badge.fury.io/py/drivee-client.svg)](https://badge.fury.io/py/drivee-client)
6
+ [![Python Support](https://img.shields.io/pypi/pyversions/drivee-client.svg)](https://pypi.org/project/drivee-client/)
7
+ [![License: MIT](https://img.shields.io/badge/License-MIT-yellow.svg)](https://opensource.org/licenses/MIT)
8
+
9
+ ## Installation
10
+
11
+ ```bash
12
+ pip install drivee-client
13
+ ```
14
+
15
+ ## Quick Start
16
+
17
+ ```python
18
+ import asyncio
19
+ from drivee_client import DriveeClient
20
+
21
+ async def main():
22
+ async with DriveeClient("username", "password") as client:
23
+ await client.init()
24
+
25
+ # Get charge point info
26
+ charge_point = await client.get_charge_point()
27
+ print(f"Charge point: {charge_point.name}")
28
+ print(f"Status: {charge_point.evse.status}")
29
+
30
+ # Start charging
31
+ response = await client.start_charging()
32
+ print(f"Started session: {response.session.id}")
33
+
34
+ # Get charging history
35
+ history = await client.get_charging_history()
36
+ for session in history.sessions:
37
+ print(f"Session {session.id}: {session.energy/1000:.2f}kWh")
38
+
39
+ if __name__ == "__main__":
40
+ asyncio.run(main())
41
+ ```
42
+
43
+ ## Features
44
+
45
+ - **Async/await support** - Built with `aiohttp` for non-blocking I/O
46
+ - **Type-safe** - Full type hints with Pydantic models
47
+ - **Error handling** - Comprehensive error handling with custom exceptions
48
+ - **Rate limiting** - Built-in retry logic with exponential backoff
49
+ - **Clean architecture** - Separation of DTOs and business models
50
+ - **Domain validation** - Business rule validation in model layer
51
+
52
+ ## Architecture
53
+
54
+ The client library follows a clear separation of concerns with three main layers:
55
+
56
+ ### Data Transfer Objects (DTOs)
57
+
58
+ Located in `dtos/`, these are pure data classes that:
59
+
60
+ - Match the exact structure of API responses
61
+ - Use Pydantic for validation and serialization
62
+ - Have no business logic
63
+ - Follow naming convention: All DTO classes end with 'DTO' suffix
64
+ - Are only used within the model layer
65
+
66
+ ### Business Models
67
+
68
+ Located in `models/`, these classes:
69
+
70
+ - Encapsulate DTOs and provide business logic
71
+ - Expose only business-relevant properties and methods
72
+ - Use Protocol-based typing for DTO interfaces
73
+ - Handle all business rules and validations
74
+ - Are the only classes exposed to the Home Assistant integration
75
+
76
+ ### API Client
77
+
78
+ The `drivee_client.py` handles:
79
+
80
+ - REST API communication
81
+ - Authentication
82
+ - Request/response mapping to DTOs
83
+ - Error handling and retries
84
+
85
+ ## Installation
86
+
87
+ 1. Copy the `custom_components/drivee` folder to your Home Assistant's `custom_components` directory.
88
+ 2. Restart Home Assistant.
89
+
90
+ ## Configuration
91
+
92
+ 1. Go to Home Assistant's Settings > Devices & Services
93
+ 2. Click "Add Integration"
94
+ 3. Search for "Drivee"
95
+ 4. Enter your Drivee API base URL
96
+ 5. (Optional) Enter your API key if required
97
+
98
+ ## Usage
99
+
100
+ After configuration, you can control your Drivee device through Home Assistant's interface. The integration will create a switch entity that you can use to control your device.
101
+
102
+ ## Development
103
+
104
+ To develop or modify this integration:
105
+
106
+ 1. Clone this repository
107
+ 2. Install dependencies:
108
+
109
+ ```bash
110
+ pip install -r requirements.txt
111
+ ```
112
+
113
+ 3. Make your changes
114
+ 4. Test the integration locally
115
+ 5. Copy the modified files to your Home Assistant's `custom_components` directory
116
+
117
+ ## License
118
+
119
+ MIT License