python-homewizard-energy 5.0.0b1__tar.gz → 6.0.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.
- {python_homewizard_energy-5.0.0b1 → python_homewizard_energy-6.0.0}/PKG-INFO +1 -1
- {python_homewizard_energy-5.0.0b1 → python_homewizard_energy-6.0.0}/homewizard_energy/__init__.py +2 -2
- {python_homewizard_energy-5.0.0b1 → python_homewizard_energy-6.0.0}/homewizard_energy/const.py +0 -1
- {python_homewizard_energy-5.0.0b1 → python_homewizard_energy-6.0.0}/homewizard_energy/homewizard_energy.py +3 -64
- {python_homewizard_energy-5.0.0b1 → python_homewizard_energy-6.0.0}/homewizard_energy/models.py +4 -25
- {python_homewizard_energy-5.0.0b1 → python_homewizard_energy-6.0.0}/pyproject.toml +5 -5
- {python_homewizard_energy-5.0.0b1 → python_homewizard_energy-6.0.0}/LICENSE +0 -0
- {python_homewizard_energy-5.0.0b1 → python_homewizard_energy-6.0.0}/README.md +0 -0
- {python_homewizard_energy-5.0.0b1 → python_homewizard_energy-6.0.0}/homewizard_energy/errors.py +0 -0
- {python_homewizard_energy-5.0.0b1 → python_homewizard_energy-6.0.0}/homewizard_energy/py.typed +0 -0
{python_homewizard_energy-5.0.0b1 → python_homewizard_energy-6.0.0}/homewizard_energy/__init__.py
RENAMED
|
@@ -1,7 +1,8 @@
|
|
|
1
1
|
"""HomeWizard Energy API library."""
|
|
2
|
+
|
|
2
3
|
from .errors import DisabledError, InvalidStateError, RequestError, UnsupportedError
|
|
3
4
|
from .homewizard_energy import HomeWizardEnergy
|
|
4
|
-
from .models import Data,
|
|
5
|
+
from .models import Data, Device, ExternalDevice, State, System
|
|
5
6
|
|
|
6
7
|
__all__ = [
|
|
7
8
|
"HomeWizardEnergy",
|
|
@@ -10,7 +11,6 @@ __all__ = [
|
|
|
10
11
|
"UnsupportedError",
|
|
11
12
|
"DisabledError",
|
|
12
13
|
"Data",
|
|
13
|
-
"Decryption",
|
|
14
14
|
"Device",
|
|
15
15
|
"ExternalDevice",
|
|
16
16
|
"State",
|
|
@@ -1,20 +1,20 @@
|
|
|
1
1
|
"""Representation of a HomeWizard Energy device."""
|
|
2
|
+
|
|
2
3
|
from __future__ import annotations
|
|
3
4
|
|
|
4
5
|
import asyncio
|
|
5
6
|
import logging
|
|
6
|
-
import string
|
|
7
7
|
from collections.abc import Callable, Coroutine
|
|
8
8
|
from http import HTTPStatus
|
|
9
9
|
from typing import Any, TypeVar
|
|
10
10
|
|
|
11
11
|
import async_timeout
|
|
12
12
|
from aiohttp.client import ClientError, ClientResponseError, ClientSession
|
|
13
|
-
from aiohttp.hdrs import
|
|
13
|
+
from aiohttp.hdrs import METH_GET, METH_PUT
|
|
14
14
|
|
|
15
15
|
from .const import SUPPORTED_API_VERSION
|
|
16
16
|
from .errors import DisabledError, NotFoundError, RequestError, UnsupportedError
|
|
17
|
-
from .models import Data,
|
|
17
|
+
from .models import Data, Device, State, System
|
|
18
18
|
|
|
19
19
|
_LOGGER = logging.getLogger(__name__)
|
|
20
20
|
|
|
@@ -145,67 +145,6 @@ class HomeWizardEnergy:
|
|
|
145
145
|
await self.request("api/v1/identify", method=METH_PUT)
|
|
146
146
|
return True
|
|
147
147
|
|
|
148
|
-
@optional_method
|
|
149
|
-
async def decryption(self) -> Decryption:
|
|
150
|
-
"""Return the decryption object."""
|
|
151
|
-
response = await self.request("api/v1/decryption")
|
|
152
|
-
return Decryption.from_dict(response)
|
|
153
|
-
|
|
154
|
-
@optional_method
|
|
155
|
-
async def decryption_set(
|
|
156
|
-
self,
|
|
157
|
-
key: str | None = None,
|
|
158
|
-
aad: str | None = None,
|
|
159
|
-
) -> bool:
|
|
160
|
-
"""Set state of device."""
|
|
161
|
-
data = {}
|
|
162
|
-
|
|
163
|
-
if key is not None:
|
|
164
|
-
if len(key) != 32:
|
|
165
|
-
raise ValueError("Key length should be 32 characters long")
|
|
166
|
-
if not all(c in string.hexdigits for c in key):
|
|
167
|
-
raise ValueError(
|
|
168
|
-
"Key should only contain hexadecimal characters (0-9/a-f)"
|
|
169
|
-
)
|
|
170
|
-
|
|
171
|
-
data["key"] = key
|
|
172
|
-
|
|
173
|
-
if aad is not None:
|
|
174
|
-
if len(aad) != 34:
|
|
175
|
-
|
|
176
|
-
hint: str | None = None
|
|
177
|
-
if len(aad) == 32:
|
|
178
|
-
hint = "Hint: Try prefixing AAD with '30', e.g. '30<AAD>'"
|
|
179
|
-
raise ValueError("AAD length should be 34 characters long", hint)
|
|
180
|
-
if not all(c in string.hexdigits for c in aad):
|
|
181
|
-
raise ValueError(
|
|
182
|
-
"AAD should only contain hexadecimal characters (0-9/a-f)"
|
|
183
|
-
)
|
|
184
|
-
|
|
185
|
-
data["aad"] = aad
|
|
186
|
-
|
|
187
|
-
if not data:
|
|
188
|
-
_LOGGER.error("At least one decryption key is required")
|
|
189
|
-
return False
|
|
190
|
-
|
|
191
|
-
await self.request("api/v1/decryption", method=METH_PUT, data=data)
|
|
192
|
-
return True
|
|
193
|
-
|
|
194
|
-
@optional_method
|
|
195
|
-
async def decryption_reset(
|
|
196
|
-
self,
|
|
197
|
-
key: bool = False,
|
|
198
|
-
aad: bool = False,
|
|
199
|
-
) -> bool:
|
|
200
|
-
"""Reset decryption keys of device."""
|
|
201
|
-
data = {
|
|
202
|
-
"key": key,
|
|
203
|
-
"aad": aad,
|
|
204
|
-
}
|
|
205
|
-
|
|
206
|
-
await self.request("api/v1/decryption", method=METH_DELETE, data=data)
|
|
207
|
-
return True
|
|
208
|
-
|
|
209
148
|
async def request(
|
|
210
149
|
self, path: str, method: str = METH_GET, data: object = None
|
|
211
150
|
) -> Any:
|
{python_homewizard_energy-5.0.0b1 → python_homewizard_energy-6.0.0}/homewizard_energy/models.py
RENAMED
|
@@ -161,7 +161,9 @@ class Data:
|
|
|
161
161
|
for external in external_devices:
|
|
162
162
|
with suppress(ValueError, KeyError):
|
|
163
163
|
device = ExternalDevice.from_dict(external)
|
|
164
|
-
|
|
164
|
+
type_unique_id = f"{external.get('type')}_{device.unique_id}"
|
|
165
|
+
|
|
166
|
+
devices[type_unique_id] = device
|
|
165
167
|
|
|
166
168
|
return devices
|
|
167
169
|
|
|
@@ -276,7 +278,7 @@ class ExternalDevice:
|
|
|
276
278
|
"water_meter": ExternalDevice.DeviceType.WATER_METER,
|
|
277
279
|
"inlet_heat_meter": ExternalDevice.DeviceType.INLET_HEAT_METER,
|
|
278
280
|
}[value]
|
|
279
|
-
except
|
|
281
|
+
except KeyError:
|
|
280
282
|
return ExternalDevice.DeviceType.UNKNOWN
|
|
281
283
|
|
|
282
284
|
unique_id: str
|
|
@@ -351,26 +353,3 @@ class System:
|
|
|
351
353
|
return System(
|
|
352
354
|
cloud_enabled=data.get("cloud_enabled"),
|
|
353
355
|
)
|
|
354
|
-
|
|
355
|
-
|
|
356
|
-
@dataclass
|
|
357
|
-
class Decryption:
|
|
358
|
-
"""Represent decryption API."""
|
|
359
|
-
|
|
360
|
-
key_set: bool | None
|
|
361
|
-
aad_set: bool | None
|
|
362
|
-
|
|
363
|
-
@staticmethod
|
|
364
|
-
def from_dict(data: dict[str, Any]) -> Decryption:
|
|
365
|
-
"""Return Decryption object from API response.
|
|
366
|
-
|
|
367
|
-
Args:
|
|
368
|
-
data: The data from the HomeWizard Energy `api/v1/decryption` API.
|
|
369
|
-
|
|
370
|
-
Returns:
|
|
371
|
-
A Decryption object.
|
|
372
|
-
"""
|
|
373
|
-
return Decryption(
|
|
374
|
-
key_set=data.get("key"),
|
|
375
|
-
aad_set=data.get("aad"),
|
|
376
|
-
)
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
[tool.poetry]
|
|
2
2
|
name = "python-homewizard-energy"
|
|
3
|
-
version = "
|
|
3
|
+
version = "6.0.0"
|
|
4
4
|
description = "Asynchronous Python client for the HomeWizard Energy"
|
|
5
5
|
authors = ["DCSBL"]
|
|
6
6
|
maintainers = ["DCSBL"]
|
|
@@ -22,19 +22,19 @@ async-timeout = "^4.0.3"
|
|
|
22
22
|
|
|
23
23
|
[tool.poetry.dev-dependencies]
|
|
24
24
|
aresponses = "^3.0.0"
|
|
25
|
-
black = "^
|
|
25
|
+
black = "^24.4"
|
|
26
26
|
blacken-docs = "^1.16.0"
|
|
27
27
|
flake8 = "^4.0.1"
|
|
28
28
|
flake8-docstrings = "^1.7.0"
|
|
29
29
|
isort = "^5.13.2"
|
|
30
30
|
pre-commit = "^3.6.0"
|
|
31
31
|
pre-commit-hooks = "^4.5.0"
|
|
32
|
-
pylint = "^3.0
|
|
32
|
+
pylint = "^3.1.0"
|
|
33
33
|
pytest = "^7.4.4"
|
|
34
|
-
pytest-asyncio = "^0.23.
|
|
34
|
+
pytest-asyncio = "^0.23.6"
|
|
35
35
|
pytest-cov = "^4.1.0"
|
|
36
36
|
yamllint = "^1.33.0"
|
|
37
|
-
pyupgrade = "^3.15.
|
|
37
|
+
pyupgrade = "^3.15.2"
|
|
38
38
|
flake8-simplify = "^0.21.0"
|
|
39
39
|
vulture = "^2.11"
|
|
40
40
|
flake8-bandit = "^3.0.0"
|
|
File without changes
|
|
File without changes
|
{python_homewizard_energy-5.0.0b1 → python_homewizard_energy-6.0.0}/homewizard_energy/errors.py
RENAMED
|
File without changes
|
{python_homewizard_energy-5.0.0b1 → python_homewizard_energy-6.0.0}/homewizard_energy/py.typed
RENAMED
|
File without changes
|