python-homewizard-energy 9.0.0b1__tar.gz → 9.1.1__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-9.0.0b1 → python_homewizard_energy-9.1.1}/PKG-INFO +2 -2
- {python_homewizard_energy-9.0.0b1 → python_homewizard_energy-9.1.1}/homewizard_energy/homewizard_energy.py +12 -3
- {python_homewizard_energy-9.0.0b1 → python_homewizard_energy-9.1.1}/homewizard_energy/models.py +39 -27
- {python_homewizard_energy-9.0.0b1 → python_homewizard_energy-9.1.1}/homewizard_energy/v2/__init__.py +43 -1
- {python_homewizard_energy-9.0.0b1 → python_homewizard_energy-9.1.1}/pyproject.toml +11 -11
- {python_homewizard_energy-9.0.0b1 → python_homewizard_energy-9.1.1}/LICENSE +0 -0
- {python_homewizard_energy-9.0.0b1 → python_homewizard_energy-9.1.1}/README.md +0 -0
- {python_homewizard_energy-9.0.0b1 → python_homewizard_energy-9.1.1}/homewizard_energy/__init__.py +0 -0
- {python_homewizard_energy-9.0.0b1 → python_homewizard_energy-9.1.1}/homewizard_energy/const.py +0 -0
- {python_homewizard_energy-9.0.0b1 → python_homewizard_energy-9.1.1}/homewizard_energy/errors.py +0 -0
- {python_homewizard_energy-9.0.0b1 → python_homewizard_energy-9.1.1}/homewizard_energy/py.typed +0 -0
- {python_homewizard_energy-9.0.0b1 → python_homewizard_energy-9.1.1}/homewizard_energy/utils.py +0 -0
- {python_homewizard_energy-9.0.0b1 → python_homewizard_energy-9.1.1}/homewizard_energy/v1/__init__.py +0 -0
- {python_homewizard_energy-9.0.0b1 → python_homewizard_energy-9.1.1}/homewizard_energy/v1/const.py +0 -0
- {python_homewizard_energy-9.0.0b1 → python_homewizard_energy-9.1.1}/homewizard_energy/v2/cacert.py +0 -0
- {python_homewizard_energy-9.0.0b1 → python_homewizard_energy-9.1.1}/homewizard_energy/v2/const.py +0 -0
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.3
|
|
2
2
|
Name: python-homewizard-energy
|
|
3
|
-
Version: 9.
|
|
3
|
+
Version: 9.1.1
|
|
4
4
|
Summary: Asynchronous Python client for the HomeWizard Energy
|
|
5
5
|
License: Apache-2.0
|
|
6
6
|
Author: DCSBL
|
|
@@ -12,7 +12,7 @@ Classifier: Programming Language :: Python :: 3.12
|
|
|
12
12
|
Classifier: Programming Language :: Python :: 3.13
|
|
13
13
|
Requires-Dist: aiohttp (>=3.0.0)
|
|
14
14
|
Requires-Dist: async-timeout (>=4.0.3,<6.0.0)
|
|
15
|
-
Requires-Dist: awesomeversion (>=24.6.0
|
|
15
|
+
Requires-Dist: awesomeversion (>=24.6.0)
|
|
16
16
|
Requires-Dist: backoff (>=2.2.1,<3.0.0)
|
|
17
17
|
Requires-Dist: mashumaro (>=3.15,<4.0)
|
|
18
18
|
Requires-Dist: multidict (>=6.0.5,<7.0.0)
|
|
@@ -9,7 +9,7 @@ from aiohttp.client import ClientSession, ClientTimeout, TCPConnector
|
|
|
9
9
|
|
|
10
10
|
from .const import LOGGER
|
|
11
11
|
from .errors import UnsupportedError
|
|
12
|
-
from .models import CombinedModels, Device, Measurement, State, System
|
|
12
|
+
from .models import Batteries, CombinedModels, Device, Measurement, State, System
|
|
13
13
|
|
|
14
14
|
|
|
15
15
|
class HomeWizardEnergy:
|
|
@@ -63,15 +63,20 @@ class HomeWizardEnergy:
|
|
|
63
63
|
except (UnsupportedError, NotImplementedError):
|
|
64
64
|
return None
|
|
65
65
|
|
|
66
|
-
device, measurement, system, state = await asyncio.gather(
|
|
66
|
+
device, measurement, system, state, batteries = await asyncio.gather(
|
|
67
67
|
fetch_data(self.device()),
|
|
68
68
|
fetch_data(self.measurement()),
|
|
69
69
|
fetch_data(self.system()),
|
|
70
70
|
fetch_data(self.state()),
|
|
71
|
+
fetch_data(self.batteries()),
|
|
71
72
|
)
|
|
72
73
|
|
|
73
74
|
return CombinedModels(
|
|
74
|
-
device=device,
|
|
75
|
+
device=device,
|
|
76
|
+
measurement=measurement,
|
|
77
|
+
system=system,
|
|
78
|
+
state=state,
|
|
79
|
+
batteries=batteries,
|
|
75
80
|
)
|
|
76
81
|
|
|
77
82
|
async def device(self, reset_cache: bool = False) -> Device:
|
|
@@ -104,6 +109,10 @@ class HomeWizardEnergy:
|
|
|
104
109
|
"""Get/set the state."""
|
|
105
110
|
raise UnsupportedError("State is not supported")
|
|
106
111
|
|
|
112
|
+
async def batteries(self, mode: Batteries.Mode | None = None) -> Batteries:
|
|
113
|
+
"""Get the batteries."""
|
|
114
|
+
raise UnsupportedError("Batteries are not supported")
|
|
115
|
+
|
|
107
116
|
async def identify(
|
|
108
117
|
self,
|
|
109
118
|
) -> None:
|
{python_homewizard_energy-9.0.0b1 → python_homewizard_energy-9.1.1}/homewizard_energy/models.py
RENAMED
|
@@ -22,7 +22,7 @@ class AwesomeVersionSerializationStrategy(SerializationStrategy, use_annotations
|
|
|
22
22
|
|
|
23
23
|
def serialize(self, value: AwesomeVersion) -> str:
|
|
24
24
|
"""Serialize AwesomeVersion object to string."""
|
|
25
|
-
return str(value)
|
|
25
|
+
return str(value) # pragma: no cover
|
|
26
26
|
|
|
27
27
|
def deserialize(self, value: str) -> AwesomeVersion | None:
|
|
28
28
|
"""Deserialize string to AwesomeVersion object."""
|
|
@@ -65,18 +65,23 @@ class CombinedModels:
|
|
|
65
65
|
measurement: Measurement
|
|
66
66
|
state: State | None
|
|
67
67
|
system: System | None
|
|
68
|
+
batteries: Batteries | None
|
|
68
69
|
|
|
70
|
+
# pylint: disable=too-many-arguments
|
|
71
|
+
# pylint: disable=too-many-positional-arguments
|
|
69
72
|
def __init__(
|
|
70
73
|
self,
|
|
71
74
|
device: Device,
|
|
72
75
|
measurement: Measurement,
|
|
73
76
|
state: State | None,
|
|
74
77
|
system: System | None,
|
|
78
|
+
batteries: Batteries | None = None,
|
|
75
79
|
):
|
|
76
80
|
self.device = device
|
|
77
81
|
self.measurement = measurement
|
|
78
82
|
self.state = state
|
|
79
83
|
self.system = system
|
|
84
|
+
self.batteries = batteries
|
|
80
85
|
|
|
81
86
|
# Move things around for backwards compatibility
|
|
82
87
|
## measurement.wifi_ssid -> system.wifi_ssid
|
|
@@ -97,32 +102,6 @@ class CombinedModels:
|
|
|
97
102
|
self.system = System()
|
|
98
103
|
self.system.status_led_brightness_pct = (self.state.brightness / 255) * 100
|
|
99
104
|
|
|
100
|
-
if self.device.product_type != Model.P1_METER and self.measurement is not None:
|
|
101
|
-
# Remove duplicate 't1' tariff from non-tariff meters
|
|
102
|
-
if (
|
|
103
|
-
self.measurement.energy_import_kwh is not None
|
|
104
|
-
and self.measurement.energy_import_kwh
|
|
105
|
-
== self.measurement.energy_import_t1_kwh
|
|
106
|
-
):
|
|
107
|
-
self.measurement.energy_import_t1_kwh = None
|
|
108
|
-
if (
|
|
109
|
-
self.measurement.energy_export_kwh is not None
|
|
110
|
-
and self.measurement.energy_export_kwh
|
|
111
|
-
== self.measurement.energy_export_t1_kwh
|
|
112
|
-
):
|
|
113
|
-
self.measurement.energy_export_t1_kwh = None
|
|
114
|
-
|
|
115
|
-
# Remove duplicate 'power_l1' from 1-phase meters
|
|
116
|
-
# If l2 or l3 is present, keep 'power_l1'
|
|
117
|
-
if (
|
|
118
|
-
self.measurement.power_w is not None
|
|
119
|
-
and self.measurement.power_l2_w is None
|
|
120
|
-
and self.measurement.power_l3_w is None
|
|
121
|
-
and (self.measurement.power_w == self.measurement.power_l1_w)
|
|
122
|
-
):
|
|
123
|
-
# Remove duplicate 'power_l1_w' when it matches 'power_w' and l2 or l3 is present
|
|
124
|
-
self.measurement.power_l1_w = None
|
|
125
|
-
|
|
126
105
|
|
|
127
106
|
def get_verification_hostname(model: str, serial_number: str) -> str:
|
|
128
107
|
"""Helper method to convert device model and serial to identifier
|
|
@@ -183,6 +162,10 @@ class Device(BaseModel):
|
|
|
183
162
|
"""Return if the device supports telegram."""
|
|
184
163
|
return self.product_type == Model.P1_METER
|
|
185
164
|
|
|
165
|
+
def supports_batteries(self) -> bool:
|
|
166
|
+
"""Return if the device supports batteries."""
|
|
167
|
+
return self.product_type == Model.P1_METER
|
|
168
|
+
|
|
186
169
|
|
|
187
170
|
@dataclass(kw_only=True)
|
|
188
171
|
class Measurement(BaseModel):
|
|
@@ -601,6 +584,35 @@ class System(BaseModel):
|
|
|
601
584
|
return obj
|
|
602
585
|
|
|
603
586
|
|
|
587
|
+
@dataclass
|
|
588
|
+
class BatteriesUpdate(UpdateBaseModel):
|
|
589
|
+
"""Represent Batteries update config."""
|
|
590
|
+
|
|
591
|
+
mode: Batteries.Mode | None = field(default=None)
|
|
592
|
+
|
|
593
|
+
|
|
594
|
+
@dataclass(kw_only=True)
|
|
595
|
+
class Batteries(BaseModel):
|
|
596
|
+
"""Represent Batteries config."""
|
|
597
|
+
|
|
598
|
+
class Mode(StrEnum):
|
|
599
|
+
"""Device type allocations."""
|
|
600
|
+
|
|
601
|
+
ZERO = "zero"
|
|
602
|
+
TO_FULL = "to_full"
|
|
603
|
+
STANDBY = "standby"
|
|
604
|
+
|
|
605
|
+
mode: Mode = field(
|
|
606
|
+
metadata={
|
|
607
|
+
"deserialize": lambda x: Batteries.Mode.__members__.get(x.upper(), None)
|
|
608
|
+
},
|
|
609
|
+
)
|
|
610
|
+
power_w: float = field()
|
|
611
|
+
target_power_w: float = field()
|
|
612
|
+
max_consumption_w: float = field()
|
|
613
|
+
max_production_w: float = field()
|
|
614
|
+
|
|
615
|
+
|
|
604
616
|
@dataclass(kw_only=True)
|
|
605
617
|
class Token(BaseModel):
|
|
606
618
|
"""Represent Token."""
|
{python_homewizard_energy-9.0.0b1 → python_homewizard_energy-9.1.1}/homewizard_energy/v2/__init__.py
RENAMED
|
@@ -19,12 +19,22 @@ from ..const import LOGGER
|
|
|
19
19
|
from ..errors import (
|
|
20
20
|
DisabledError,
|
|
21
21
|
InvalidUserNameError,
|
|
22
|
+
NotFoundError,
|
|
22
23
|
RequestError,
|
|
23
24
|
ResponseError,
|
|
24
25
|
UnauthorizedError,
|
|
26
|
+
UnsupportedError,
|
|
25
27
|
)
|
|
26
28
|
from ..homewizard_energy import HomeWizardEnergy
|
|
27
|
-
from ..models import
|
|
29
|
+
from ..models import (
|
|
30
|
+
Batteries,
|
|
31
|
+
BatteriesUpdate,
|
|
32
|
+
Device,
|
|
33
|
+
Measurement,
|
|
34
|
+
System,
|
|
35
|
+
SystemUpdate,
|
|
36
|
+
Token,
|
|
37
|
+
)
|
|
28
38
|
from .cacert import CACERT
|
|
29
39
|
|
|
30
40
|
T = TypeVar("T")
|
|
@@ -137,6 +147,36 @@ class HomeWizardEnergyV2(HomeWizardEnergy):
|
|
|
137
147
|
system = System.from_json(response)
|
|
138
148
|
return system
|
|
139
149
|
|
|
150
|
+
@authorized_method
|
|
151
|
+
async def batteries(
|
|
152
|
+
self,
|
|
153
|
+
mode: Batteries.Mode | None = None,
|
|
154
|
+
) -> Batteries:
|
|
155
|
+
"""Return the batteries object."""
|
|
156
|
+
|
|
157
|
+
if self._device is not None and self._device.supports_batteries() is False:
|
|
158
|
+
raise UnsupportedError("Batteries is not supported")
|
|
159
|
+
|
|
160
|
+
try:
|
|
161
|
+
if mode is not None:
|
|
162
|
+
data = BatteriesUpdate(
|
|
163
|
+
mode=mode,
|
|
164
|
+
).to_dict()
|
|
165
|
+
status, response = await self._request(
|
|
166
|
+
"/api/batteries", method=METH_PUT, data=data
|
|
167
|
+
)
|
|
168
|
+
else:
|
|
169
|
+
status, response = await self._request("/api/batteries")
|
|
170
|
+
|
|
171
|
+
if status != HTTPStatus.OK:
|
|
172
|
+
error = json.loads(response).get("error", response)
|
|
173
|
+
raise RequestError(f"Failed to get batteries: {error}")
|
|
174
|
+
except NotFoundError as exception:
|
|
175
|
+
# The batteries endpoint is not available on the device
|
|
176
|
+
raise UnsupportedError("Batteries is not supported") from exception
|
|
177
|
+
|
|
178
|
+
return Batteries.from_json(response)
|
|
179
|
+
|
|
140
180
|
@authorized_method
|
|
141
181
|
async def identify(
|
|
142
182
|
self,
|
|
@@ -275,6 +315,8 @@ class HomeWizardEnergyV2(HomeWizardEnergy):
|
|
|
275
315
|
case HTTPStatus.NO_CONTENT:
|
|
276
316
|
# No content, just return
|
|
277
317
|
return (HTTPStatus.NO_CONTENT, None)
|
|
318
|
+
case HTTPStatus.NOT_FOUND:
|
|
319
|
+
raise NotFoundError("Resource not found")
|
|
278
320
|
case HTTPStatus.OK:
|
|
279
321
|
pass
|
|
280
322
|
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
[tool.poetry]
|
|
2
2
|
name = "python-homewizard-energy"
|
|
3
|
-
version = "9.
|
|
3
|
+
version = "9.1.1"
|
|
4
4
|
description = "Asynchronous Python client for the HomeWizard Energy"
|
|
5
5
|
authors = ["DCSBL"]
|
|
6
6
|
maintainers = ["DCSBL"]
|
|
@@ -23,20 +23,20 @@ multidict = "^6.0.5" ## To fix aiohttp dependency at python 3.12
|
|
|
23
23
|
backoff = "^2.2.1"
|
|
24
24
|
orjson = "^3.10"
|
|
25
25
|
mashumaro = "^3.15"
|
|
26
|
-
awesomeversion = "
|
|
26
|
+
awesomeversion = ">=24.6.0"
|
|
27
27
|
|
|
28
28
|
[tool.poetry.dev-dependencies]
|
|
29
29
|
aresponses = "^3.0.0"
|
|
30
30
|
flake8 = "^4.0.1"
|
|
31
31
|
flake8-docstrings = "^1.7.0"
|
|
32
32
|
isort = "^6.0.1"
|
|
33
|
-
pre-commit = "^4.
|
|
33
|
+
pre-commit = "^4.2.0"
|
|
34
34
|
pre-commit-hooks = "^5.0.0"
|
|
35
|
-
pylint = "^3.3.
|
|
36
|
-
pytest = "^8.3.
|
|
37
|
-
pytest-asyncio = "^0.
|
|
38
|
-
pytest-cov = "^6.
|
|
39
|
-
yamllint = "^1.
|
|
35
|
+
pylint = "^3.3.7"
|
|
36
|
+
pytest = "^8.3.5"
|
|
37
|
+
pytest-asyncio = "^0.26.0"
|
|
38
|
+
pytest-cov = "^6.1.1"
|
|
39
|
+
yamllint = "^1.37.1"
|
|
40
40
|
pyupgrade = "^3.19.0"
|
|
41
41
|
flake8-simplify = "^0.21.0"
|
|
42
42
|
vulture = "^2.13"
|
|
@@ -46,12 +46,12 @@ flake8-builtins = "^2.5.0"
|
|
|
46
46
|
flake8-comprehensions = "^3.15.0"
|
|
47
47
|
flake8-eradicate = "^1.2.1"
|
|
48
48
|
flake8-markdown = "^0.3.0"
|
|
49
|
-
ruff = "0.
|
|
49
|
+
ruff = "0.11.7"
|
|
50
50
|
darglint = "^1.8.1"
|
|
51
51
|
safety = "^3.2.10"
|
|
52
|
-
codespell = "^2.
|
|
52
|
+
codespell = "^2.4.1"
|
|
53
53
|
bandit = "^1.8.3"
|
|
54
|
-
syrupy = "^4.
|
|
54
|
+
syrupy = "^4.9.1"
|
|
55
55
|
|
|
56
56
|
[tool.poetry.urls]
|
|
57
57
|
"Bug Tracker" = "https://github.com/homewizard/python-homewizard-energy/issues"
|
|
File without changes
|
|
File without changes
|
{python_homewizard_energy-9.0.0b1 → python_homewizard_energy-9.1.1}/homewizard_energy/__init__.py
RENAMED
|
File without changes
|
{python_homewizard_energy-9.0.0b1 → python_homewizard_energy-9.1.1}/homewizard_energy/const.py
RENAMED
|
File without changes
|
{python_homewizard_energy-9.0.0b1 → python_homewizard_energy-9.1.1}/homewizard_energy/errors.py
RENAMED
|
File without changes
|
{python_homewizard_energy-9.0.0b1 → python_homewizard_energy-9.1.1}/homewizard_energy/py.typed
RENAMED
|
File without changes
|
{python_homewizard_energy-9.0.0b1 → python_homewizard_energy-9.1.1}/homewizard_energy/utils.py
RENAMED
|
File without changes
|
{python_homewizard_energy-9.0.0b1 → python_homewizard_energy-9.1.1}/homewizard_energy/v1/__init__.py
RENAMED
|
File without changes
|
{python_homewizard_energy-9.0.0b1 → python_homewizard_energy-9.1.1}/homewizard_energy/v1/const.py
RENAMED
|
File without changes
|
{python_homewizard_energy-9.0.0b1 → python_homewizard_energy-9.1.1}/homewizard_energy/v2/cacert.py
RENAMED
|
File without changes
|
{python_homewizard_energy-9.0.0b1 → python_homewizard_energy-9.1.1}/homewizard_energy/v2/const.py
RENAMED
|
File without changes
|