python-homewizard-energy 7.0.0b1__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.
Files changed (16) hide show
  1. {python_homewizard_energy-7.0.0b1 → python_homewizard_energy-7.1.0b1}/PKG-INFO +1 -1
  2. python_homewizard_energy-7.1.0b1/homewizard_energy/__init__.py +57 -0
  3. {python_homewizard_energy-7.0.0b1 → python_homewizard_energy-7.1.0b1}/homewizard_energy/v2/models.py +5 -0
  4. {python_homewizard_energy-7.0.0b1 → python_homewizard_energy-7.1.0b1}/pyproject.toml +5 -5
  5. python_homewizard_energy-7.0.0b1/homewizard_energy/__init__.py +0 -14
  6. {python_homewizard_energy-7.0.0b1 → python_homewizard_energy-7.1.0b1}/LICENSE +0 -0
  7. {python_homewizard_energy-7.0.0b1 → python_homewizard_energy-7.1.0b1}/README.md +0 -0
  8. {python_homewizard_energy-7.0.0b1 → python_homewizard_energy-7.1.0b1}/homewizard_energy/brand.py +0 -0
  9. {python_homewizard_energy-7.0.0b1 → python_homewizard_energy-7.1.0b1}/homewizard_energy/errors.py +0 -0
  10. {python_homewizard_energy-7.0.0b1 → python_homewizard_energy-7.1.0b1}/homewizard_energy/py.typed +0 -0
  11. {python_homewizard_energy-7.0.0b1 → python_homewizard_energy-7.1.0b1}/homewizard_energy/v1/__init__.py +0 -0
  12. {python_homewizard_energy-7.0.0b1 → python_homewizard_energy-7.1.0b1}/homewizard_energy/v1/const.py +0 -0
  13. {python_homewizard_energy-7.0.0b1 → python_homewizard_energy-7.1.0b1}/homewizard_energy/v1/models.py +0 -0
  14. {python_homewizard_energy-7.0.0b1 → python_homewizard_energy-7.1.0b1}/homewizard_energy/v2/__init__.py +0 -0
  15. {python_homewizard_energy-7.0.0b1 → python_homewizard_energy-7.1.0b1}/homewizard_energy/v2/cacert.py +0 -0
  16. {python_homewizard_energy-7.0.0b1 → python_homewizard_energy-7.1.0b1}/homewizard_energy/v2/const.py +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: python-homewizard-energy
3
- Version: 7.0.0b1
3
+ Version: 7.1.0b1
4
4
  Summary: Asynchronous Python client for the HomeWizard Energy
5
5
  Home-page: https://github.com/homewizard/python-homewizard-energy
6
6
  License: Apache-2.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}"
@@ -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.0.0-beta-1"
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 = "^3.7.1"
31
- pre-commit-hooks = "^4.6.0"
32
- pylint = "^3.3.1"
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.7.1"
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
- ]