python-homewizard-energy 7.0.0__tar.gz → 7.1.0b1__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-7.0.0 → python_homewizard_energy-7.1.0b1}/PKG-INFO +1 -1
- python_homewizard_energy-7.1.0b1/homewizard_energy/__init__.py +57 -0
- {python_homewizard_energy-7.0.0 → python_homewizard_energy-7.1.0b1}/homewizard_energy/v2/models.py +5 -0
- {python_homewizard_energy-7.0.0 → python_homewizard_energy-7.1.0b1}/pyproject.toml +5 -5
- python_homewizard_energy-7.0.0/homewizard_energy/__init__.py +0 -14
- {python_homewizard_energy-7.0.0 → python_homewizard_energy-7.1.0b1}/LICENSE +0 -0
- {python_homewizard_energy-7.0.0 → python_homewizard_energy-7.1.0b1}/README.md +0 -0
- {python_homewizard_energy-7.0.0 → python_homewizard_energy-7.1.0b1}/homewizard_energy/brand.py +0 -0
- {python_homewizard_energy-7.0.0 → python_homewizard_energy-7.1.0b1}/homewizard_energy/errors.py +0 -0
- {python_homewizard_energy-7.0.0 → python_homewizard_energy-7.1.0b1}/homewizard_energy/py.typed +0 -0
- {python_homewizard_energy-7.0.0 → python_homewizard_energy-7.1.0b1}/homewizard_energy/v1/__init__.py +0 -0
- {python_homewizard_energy-7.0.0 → python_homewizard_energy-7.1.0b1}/homewizard_energy/v1/const.py +0 -0
- {python_homewizard_energy-7.0.0 → python_homewizard_energy-7.1.0b1}/homewizard_energy/v1/models.py +0 -0
- {python_homewizard_energy-7.0.0 → python_homewizard_energy-7.1.0b1}/homewizard_energy/v2/__init__.py +0 -0
- {python_homewizard_energy-7.0.0 → python_homewizard_energy-7.1.0b1}/homewizard_energy/v2/cacert.py +0 -0
- {python_homewizard_energy-7.0.0 → python_homewizard_energy-7.1.0b1}/homewizard_energy/v2/const.py +0 -0
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
"""HomeWizard Energy API library."""
|
|
2
|
+
|
|
3
|
+
from aiohttp import ClientSession
|
|
4
|
+
|
|
5
|
+
from .errors import DisabledError, InvalidStateError, RequestError, UnsupportedError
|
|
6
|
+
from .v1 import HomeWizardEnergyV1
|
|
7
|
+
from .v2 import HomeWizardEnergyV2
|
|
8
|
+
|
|
9
|
+
__all__ = [
|
|
10
|
+
"DisabledError",
|
|
11
|
+
"HomeWizardEnergyV1",
|
|
12
|
+
"HomeWizardEnergyV2",
|
|
13
|
+
"InvalidStateError",
|
|
14
|
+
"RequestError",
|
|
15
|
+
"UnsupportedError",
|
|
16
|
+
]
|
|
17
|
+
|
|
18
|
+
|
|
19
|
+
async def has_v2_api(host: str, websession: ClientSession | None = None) -> bool:
|
|
20
|
+
"""Check if the device has support for the v2 api."""
|
|
21
|
+
websession_provided = websession is not None
|
|
22
|
+
if websession is None:
|
|
23
|
+
websession = ClientSession()
|
|
24
|
+
try:
|
|
25
|
+
# v2 api is https only and returns a 401 Unauthorized when no key provided,
|
|
26
|
+
# no connection can be made if the device is not v2
|
|
27
|
+
url = f"https://{host}/api"
|
|
28
|
+
async with websession.get(
|
|
29
|
+
url, ssl=False, raise_for_status=False, timeout=15
|
|
30
|
+
) as res:
|
|
31
|
+
return res.status == 401
|
|
32
|
+
except Exception: # pylint: disable=broad-except
|
|
33
|
+
# all other status/exceptions means the device is not v2 or not reachable at this time
|
|
34
|
+
return False
|
|
35
|
+
finally:
|
|
36
|
+
if not websession_provided:
|
|
37
|
+
await websession.close()
|
|
38
|
+
|
|
39
|
+
|
|
40
|
+
def get_verification_hostname(model: str, serial_number: str) -> str:
|
|
41
|
+
"""Get the verification name for the device."""
|
|
42
|
+
model_map = {
|
|
43
|
+
"HWE-P1": "p1dongle",
|
|
44
|
+
"HWE-SKT": "energysocket",
|
|
45
|
+
"HWE-WTR": "watermeter",
|
|
46
|
+
"HWE-DSP": "display",
|
|
47
|
+
"HWE-KWH1": "energymeter",
|
|
48
|
+
"SDM230-wifi": "energymeter",
|
|
49
|
+
"HWE-KWH3": "energymeter",
|
|
50
|
+
"SDM630-wifi": "energymeter",
|
|
51
|
+
"HWE-BAT": "battery",
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
if model not in model_map:
|
|
55
|
+
raise ValueError(f"Unsupported model: {model}")
|
|
56
|
+
|
|
57
|
+
return f"appliance/{model_map[model]}/{serial_number}"
|
{python_homewizard_energy-7.0.0 → python_homewizard_energy-7.1.0b1}/homewizard_energy/v2/models.py
RENAMED
|
@@ -78,6 +78,9 @@ class Measurement:
|
|
|
78
78
|
|
|
79
79
|
frequency_hz: float | None
|
|
80
80
|
|
|
81
|
+
cycles: int | None
|
|
82
|
+
state_of_charge_pct: float | None
|
|
83
|
+
|
|
81
84
|
voltage_sag_l1_count: int | None
|
|
82
85
|
voltage_sag_l2_count: int | None
|
|
83
86
|
voltage_sag_l3_count: int | None
|
|
@@ -183,6 +186,8 @@ class Measurement:
|
|
|
183
186
|
current_l2_a=data.get("current_l2_a"),
|
|
184
187
|
current_l3_a=data.get("current_l3_a"),
|
|
185
188
|
frequency_hz=data.get("frequency_hz"),
|
|
189
|
+
cycles=data.get("cycles"),
|
|
190
|
+
state_of_charge_pct=data.get("state_of_charge_pct"),
|
|
186
191
|
voltage_sag_l1_count=data.get("voltage_sag_l1_count"),
|
|
187
192
|
voltage_sag_l2_count=data.get("voltage_sag_l2_count"),
|
|
188
193
|
voltage_sag_l3_count=data.get("voltage_sag_l3_count"),
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
[tool.poetry]
|
|
2
2
|
name = "python-homewizard-energy"
|
|
3
|
-
version = "7.
|
|
3
|
+
version = "7.1.0-beta-1"
|
|
4
4
|
description = "Asynchronous Python client for the HomeWizard Energy"
|
|
5
5
|
authors = ["DCSBL"]
|
|
6
6
|
maintainers = ["DCSBL"]
|
|
@@ -27,9 +27,9 @@ aresponses = "^3.0.0"
|
|
|
27
27
|
flake8 = "^4.0.1"
|
|
28
28
|
flake8-docstrings = "^1.7.0"
|
|
29
29
|
isort = "^5.13.2"
|
|
30
|
-
pre-commit = "^
|
|
31
|
-
pre-commit-hooks = "^
|
|
32
|
-
pylint = "^3.3.
|
|
30
|
+
pre-commit = "^4.0.1"
|
|
31
|
+
pre-commit-hooks = "^5.0.0"
|
|
32
|
+
pylint = "^3.3.3"
|
|
33
33
|
pytest = "^8.3.3"
|
|
34
34
|
pytest-asyncio = "^0.24.0"
|
|
35
35
|
pytest-cov = "^5.0.0"
|
|
@@ -43,7 +43,7 @@ flake8-builtins = "^2.5.0"
|
|
|
43
43
|
flake8-comprehensions = "^3.15.0"
|
|
44
44
|
flake8-eradicate = "^1.2.1"
|
|
45
45
|
flake8-markdown = "^0.3.0"
|
|
46
|
-
ruff = "0.
|
|
46
|
+
ruff = "0.8.1"
|
|
47
47
|
darglint = "^1.8.1"
|
|
48
48
|
safety = "^3.2.10"
|
|
49
49
|
codespell = "^2.3.0"
|
|
@@ -1,14 +0,0 @@
|
|
|
1
|
-
"""HomeWizard Energy API library."""
|
|
2
|
-
|
|
3
|
-
from .errors import DisabledError, InvalidStateError, RequestError, UnsupportedError
|
|
4
|
-
from .v1 import HomeWizardEnergyV1
|
|
5
|
-
from .v2 import HomeWizardEnergyV2
|
|
6
|
-
|
|
7
|
-
__all__ = [
|
|
8
|
-
"DisabledError",
|
|
9
|
-
"HomeWizardEnergyV1",
|
|
10
|
-
"HomeWizardEnergyV2",
|
|
11
|
-
"InvalidStateError",
|
|
12
|
-
"RequestError",
|
|
13
|
-
"UnsupportedError",
|
|
14
|
-
]
|
|
File without changes
|
|
File without changes
|
{python_homewizard_energy-7.0.0 → python_homewizard_energy-7.1.0b1}/homewizard_energy/brand.py
RENAMED
|
File without changes
|
{python_homewizard_energy-7.0.0 → python_homewizard_energy-7.1.0b1}/homewizard_energy/errors.py
RENAMED
|
File without changes
|
{python_homewizard_energy-7.0.0 → python_homewizard_energy-7.1.0b1}/homewizard_energy/py.typed
RENAMED
|
File without changes
|
{python_homewizard_energy-7.0.0 → python_homewizard_energy-7.1.0b1}/homewizard_energy/v1/__init__.py
RENAMED
|
File without changes
|
{python_homewizard_energy-7.0.0 → python_homewizard_energy-7.1.0b1}/homewizard_energy/v1/const.py
RENAMED
|
File without changes
|
{python_homewizard_energy-7.0.0 → python_homewizard_energy-7.1.0b1}/homewizard_energy/v1/models.py
RENAMED
|
File without changes
|
{python_homewizard_energy-7.0.0 → python_homewizard_energy-7.1.0b1}/homewizard_energy/v2/__init__.py
RENAMED
|
File without changes
|
{python_homewizard_energy-7.0.0 → python_homewizard_energy-7.1.0b1}/homewizard_energy/v2/cacert.py
RENAMED
|
File without changes
|
{python_homewizard_energy-7.0.0 → python_homewizard_energy-7.1.0b1}/homewizard_energy/v2/const.py
RENAMED
|
File without changes
|