python-homewizard-energy 9.0.0__tar.gz → 9.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-9.0.0 → python_homewizard_energy-9.1.0b1}/PKG-INFO +1 -1
- {python_homewizard_energy-9.0.0 → python_homewizard_energy-9.1.0b1}/homewizard_energy/homewizard_energy.py +12 -3
- {python_homewizard_energy-9.0.0 → python_homewizard_energy-9.1.0b1}/homewizard_energy/models.py +40 -1
- {python_homewizard_energy-9.0.0 → python_homewizard_energy-9.1.0b1}/homewizard_energy/v2/__init__.py +43 -1
- {python_homewizard_energy-9.0.0 → python_homewizard_energy-9.1.0b1}/pyproject.toml +10 -10
- {python_homewizard_energy-9.0.0 → python_homewizard_energy-9.1.0b1}/LICENSE +0 -0
- {python_homewizard_energy-9.0.0 → python_homewizard_energy-9.1.0b1}/README.md +0 -0
- {python_homewizard_energy-9.0.0 → python_homewizard_energy-9.1.0b1}/homewizard_energy/__init__.py +0 -0
- {python_homewizard_energy-9.0.0 → python_homewizard_energy-9.1.0b1}/homewizard_energy/const.py +0 -0
- {python_homewizard_energy-9.0.0 → python_homewizard_energy-9.1.0b1}/homewizard_energy/errors.py +0 -0
- {python_homewizard_energy-9.0.0 → python_homewizard_energy-9.1.0b1}/homewizard_energy/py.typed +0 -0
- {python_homewizard_energy-9.0.0 → python_homewizard_energy-9.1.0b1}/homewizard_energy/utils.py +0 -0
- {python_homewizard_energy-9.0.0 → python_homewizard_energy-9.1.0b1}/homewizard_energy/v1/__init__.py +0 -0
- {python_homewizard_energy-9.0.0 → python_homewizard_energy-9.1.0b1}/homewizard_energy/v1/const.py +0 -0
- {python_homewizard_energy-9.0.0 → python_homewizard_energy-9.1.0b1}/homewizard_energy/v2/cacert.py +0 -0
- {python_homewizard_energy-9.0.0 → python_homewizard_energy-9.1.0b1}/homewizard_energy/v2/const.py +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.0 → python_homewizard_energy-9.1.0b1}/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
|
|
@@ -183,6 +188,10 @@ class Device(BaseModel):
|
|
|
183
188
|
"""Return if the device supports telegram."""
|
|
184
189
|
return self.product_type == Model.P1_METER
|
|
185
190
|
|
|
191
|
+
def supports_batteries(self) -> bool:
|
|
192
|
+
"""Return if the device supports batteries."""
|
|
193
|
+
return self.product_type == Model.P1_METER
|
|
194
|
+
|
|
186
195
|
|
|
187
196
|
@dataclass(kw_only=True)
|
|
188
197
|
class Measurement(BaseModel):
|
|
@@ -601,6 +610,36 @@ class System(BaseModel):
|
|
|
601
610
|
return obj
|
|
602
611
|
|
|
603
612
|
|
|
613
|
+
@dataclass
|
|
614
|
+
class BatteriesUpdate(UpdateBaseModel):
|
|
615
|
+
"""Represent Batteries update config."""
|
|
616
|
+
|
|
617
|
+
mode: Batteries.Mode | None = field(default=None)
|
|
618
|
+
|
|
619
|
+
|
|
620
|
+
@dataclass(kw_only=True)
|
|
621
|
+
class Batteries(BaseModel):
|
|
622
|
+
"""Represent Batteries config."""
|
|
623
|
+
|
|
624
|
+
class Mode(StrEnum):
|
|
625
|
+
"""Device type allocations."""
|
|
626
|
+
|
|
627
|
+
ZERO = "zero"
|
|
628
|
+
TO_FULL = "to_full"
|
|
629
|
+
STANDBY = "standby"
|
|
630
|
+
|
|
631
|
+
mode: Mode | None = field(
|
|
632
|
+
default=None,
|
|
633
|
+
metadata={
|
|
634
|
+
"deserialize": lambda x: Batteries.Mode.__members__.get(x.upper(), None)
|
|
635
|
+
},
|
|
636
|
+
)
|
|
637
|
+
power_w: float | None = field(default=None)
|
|
638
|
+
target_power_w: float | None = field(default=None)
|
|
639
|
+
max_consumption_w: float | None = field(default=None)
|
|
640
|
+
max_production_w: float | None = field(default=None)
|
|
641
|
+
|
|
642
|
+
|
|
604
643
|
@dataclass(kw_only=True)
|
|
605
644
|
class Token(BaseModel):
|
|
606
645
|
"""Represent Token."""
|
{python_homewizard_energy-9.0.0 → python_homewizard_energy-9.1.0b1}/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.0-beta-1"
|
|
4
4
|
description = "Asynchronous Python client for the HomeWizard Energy"
|
|
5
5
|
authors = ["DCSBL"]
|
|
6
6
|
maintainers = ["DCSBL"]
|
|
@@ -30,13 +30,13 @@ 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.6"
|
|
36
|
+
pytest = "^8.3.5"
|
|
37
|
+
pytest-asyncio = "^0.26.0"
|
|
38
|
+
pytest-cov = "^6.1.1"
|
|
39
|
+
yamllint = "^1.37.0"
|
|
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.0 → python_homewizard_energy-9.1.0b1}/homewizard_energy/__init__.py
RENAMED
|
File without changes
|
{python_homewizard_energy-9.0.0 → python_homewizard_energy-9.1.0b1}/homewizard_energy/const.py
RENAMED
|
File without changes
|
{python_homewizard_energy-9.0.0 → python_homewizard_energy-9.1.0b1}/homewizard_energy/errors.py
RENAMED
|
File without changes
|
{python_homewizard_energy-9.0.0 → python_homewizard_energy-9.1.0b1}/homewizard_energy/py.typed
RENAMED
|
File without changes
|
{python_homewizard_energy-9.0.0 → python_homewizard_energy-9.1.0b1}/homewizard_energy/utils.py
RENAMED
|
File without changes
|
{python_homewizard_energy-9.0.0 → python_homewizard_energy-9.1.0b1}/homewizard_energy/v1/__init__.py
RENAMED
|
File without changes
|
{python_homewizard_energy-9.0.0 → python_homewizard_energy-9.1.0b1}/homewizard_energy/v1/const.py
RENAMED
|
File without changes
|
{python_homewizard_energy-9.0.0 → python_homewizard_energy-9.1.0b1}/homewizard_energy/v2/cacert.py
RENAMED
|
File without changes
|
{python_homewizard_energy-9.0.0 → python_homewizard_energy-9.1.0b1}/homewizard_energy/v2/const.py
RENAMED
|
File without changes
|