python-homewizard-energy 9.2.0__tar.gz → 10.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-9.2.0 → python_homewizard_energy-10.0.0}/PKG-INFO +5 -3
- {python_homewizard_energy-9.2.0 → python_homewizard_energy-10.0.0}/README.md +1 -1
- {python_homewizard_energy-9.2.0 → python_homewizard_energy-10.0.0}/homewizard_energy/homewizard_energy.py +1 -1
- {python_homewizard_energy-9.2.0 → python_homewizard_energy-10.0.0}/homewizard_energy/models.py +120 -1
- {python_homewizard_energy-9.2.0 → python_homewizard_energy-10.0.0}/homewizard_energy/v2/__init__.py +1 -3
- {python_homewizard_energy-9.2.0 → python_homewizard_energy-10.0.0}/pyproject.toml +16 -16
- {python_homewizard_energy-9.2.0 → python_homewizard_energy-10.0.0}/LICENSE +0 -0
- {python_homewizard_energy-9.2.0 → python_homewizard_energy-10.0.0}/homewizard_energy/__init__.py +0 -0
- {python_homewizard_energy-9.2.0 → python_homewizard_energy-10.0.0}/homewizard_energy/const.py +0 -0
- {python_homewizard_energy-9.2.0 → python_homewizard_energy-10.0.0}/homewizard_energy/errors.py +0 -0
- {python_homewizard_energy-9.2.0 → python_homewizard_energy-10.0.0}/homewizard_energy/py.typed +0 -0
- {python_homewizard_energy-9.2.0 → python_homewizard_energy-10.0.0}/homewizard_energy/utils.py +0 -0
- {python_homewizard_energy-9.2.0 → python_homewizard_energy-10.0.0}/homewizard_energy/v1/__init__.py +0 -0
- {python_homewizard_energy-9.2.0 → python_homewizard_energy-10.0.0}/homewizard_energy/v1/const.py +0 -0
- {python_homewizard_energy-9.2.0 → python_homewizard_energy-10.0.0}/homewizard_energy/v2/cacert.py +0 -0
- {python_homewizard_energy-9.2.0 → python_homewizard_energy-10.0.0}/homewizard_energy/v2/const.py +0 -0
|
@@ -1,8 +1,9 @@
|
|
|
1
|
-
Metadata-Version: 2.
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
2
|
Name: python-homewizard-energy
|
|
3
|
-
Version:
|
|
3
|
+
Version: 10.0.0
|
|
4
4
|
Summary: Asynchronous Python client for the HomeWizard Energy
|
|
5
5
|
License: Apache-2.0
|
|
6
|
+
License-File: LICENSE
|
|
6
7
|
Author: DCSBL
|
|
7
8
|
Maintainer: DCSBL
|
|
8
9
|
Requires-Python: >=3.12,<4.0
|
|
@@ -10,6 +11,7 @@ Classifier: License :: OSI Approved :: Apache Software License
|
|
|
10
11
|
Classifier: Programming Language :: Python :: 3
|
|
11
12
|
Classifier: Programming Language :: Python :: 3.12
|
|
12
13
|
Classifier: Programming Language :: Python :: 3.13
|
|
14
|
+
Classifier: Programming Language :: Python :: 3.14
|
|
13
15
|
Requires-Dist: aiohttp (>=3.0.0)
|
|
14
16
|
Requires-Dist: async-timeout (>=4.0.3,<6.0.0)
|
|
15
17
|
Requires-Dist: awesomeversion (>=24.6.0)
|
|
@@ -83,7 +85,7 @@ asyncio.run(main())
|
|
|
83
85
|
Pull requests are welcome. For major changes, please open an issue first to discuss what you would like to change.
|
|
84
86
|
|
|
85
87
|
## Requirements
|
|
86
|
-
- Python 3.
|
|
88
|
+
- Python 3.12 or higher
|
|
87
89
|
- [Poetry](https://python-poetry.org/docs/#installing-with-pipx)
|
|
88
90
|
|
|
89
91
|
## Installation and setup
|
|
@@ -57,7 +57,7 @@ asyncio.run(main())
|
|
|
57
57
|
Pull requests are welcome. For major changes, please open an issue first to discuss what you would like to change.
|
|
58
58
|
|
|
59
59
|
## Requirements
|
|
60
|
-
- Python 3.
|
|
60
|
+
- Python 3.12 or higher
|
|
61
61
|
- [Poetry](https://python-poetry.org/docs/#installing-with-pipx)
|
|
62
62
|
|
|
63
63
|
## Installation and setup
|
|
@@ -137,7 +137,7 @@ class HomeWizardEnergy:
|
|
|
137
137
|
LOGGER.debug("Creating clientsession")
|
|
138
138
|
|
|
139
139
|
if self._session is not None:
|
|
140
|
-
raise RuntimeError("Session already exists")
|
|
140
|
+
raise RuntimeError("Session already exists") # pragma: no cover
|
|
141
141
|
|
|
142
142
|
connector = TCPConnector(
|
|
143
143
|
enable_cleanup_closed=True,
|
{python_homewizard_energy-9.2.0 → python_homewizard_energy-10.0.0}/homewizard_energy/models.py
RENAMED
|
@@ -141,6 +141,20 @@ class Device(BaseModel):
|
|
|
141
141
|
"""Return if the device supports state."""
|
|
142
142
|
return self.product_type == Model.ENERGY_SOCKET
|
|
143
143
|
|
|
144
|
+
def supports_led_brightness(self) -> bool:
|
|
145
|
+
"""Return if the device supports LED brightness control."""
|
|
146
|
+
if self.product_type in (
|
|
147
|
+
Model.BATTERY,
|
|
148
|
+
Model.ENERGY_SOCKET,
|
|
149
|
+
):
|
|
150
|
+
return True
|
|
151
|
+
|
|
152
|
+
# P1 Meter supports LED brightness from API v2.0.0 onwards
|
|
153
|
+
if self.product_type == Model.P1_METER:
|
|
154
|
+
return self.api_version.major >= 2
|
|
155
|
+
|
|
156
|
+
return False
|
|
157
|
+
|
|
144
158
|
def supports_cloud_enable(self) -> bool:
|
|
145
159
|
"""Return if the device supports cloud enable/disable."""
|
|
146
160
|
return self.product_type != Model.BATTERY
|
|
@@ -172,6 +186,25 @@ class Device(BaseModel):
|
|
|
172
186
|
Model.ENERGY_METER_EASTRON_SDM630,
|
|
173
187
|
)
|
|
174
188
|
|
|
189
|
+
def supported_battery_modes(self) -> list[Batteries.Mode] | None:
|
|
190
|
+
"""Return list of supported battery modes."""
|
|
191
|
+
if not self.supports_batteries():
|
|
192
|
+
return None
|
|
193
|
+
|
|
194
|
+
modes = [
|
|
195
|
+
Batteries.Mode.STANDBY,
|
|
196
|
+
Batteries.Mode.TO_FULL,
|
|
197
|
+
Batteries.Mode.ZERO,
|
|
198
|
+
]
|
|
199
|
+
|
|
200
|
+
if self.api_version >= AwesomeVersion("2.2.0"):
|
|
201
|
+
modes += [
|
|
202
|
+
Batteries.Mode.ZERO_CHARGE_ONLY,
|
|
203
|
+
Batteries.Mode.ZERO_DISCHARGE_ONLY,
|
|
204
|
+
]
|
|
205
|
+
|
|
206
|
+
return modes
|
|
207
|
+
|
|
175
208
|
|
|
176
209
|
@dataclass(kw_only=True)
|
|
177
210
|
class Measurement(BaseModel):
|
|
@@ -595,6 +628,49 @@ class BatteriesUpdate(UpdateBaseModel):
|
|
|
595
628
|
"""Represent Batteries update config."""
|
|
596
629
|
|
|
597
630
|
mode: Batteries.Mode | None = field(default=None)
|
|
631
|
+
permissions: list[Batteries.Permissions] | None = field(default=None)
|
|
632
|
+
|
|
633
|
+
@staticmethod
|
|
634
|
+
def from_mode(
|
|
635
|
+
mode: Batteries.Mode,
|
|
636
|
+
) -> BatteriesUpdate:
|
|
637
|
+
"""Convert userfacing mode to API mode.
|
|
638
|
+
|
|
639
|
+
Args:
|
|
640
|
+
mode: Userfacing mode to convert.
|
|
641
|
+
Returns:
|
|
642
|
+
BatteriesUpdate object with API mode and permissions.
|
|
643
|
+
"""
|
|
644
|
+
|
|
645
|
+
match mode:
|
|
646
|
+
case Batteries.Mode.ZERO:
|
|
647
|
+
return BatteriesUpdate(
|
|
648
|
+
mode=Batteries.Mode.ZERO,
|
|
649
|
+
permissions=[
|
|
650
|
+
Batteries.Permissions.CHARGE_ALLOWED,
|
|
651
|
+
Batteries.Permissions.DISCHARGE_ALLOWED,
|
|
652
|
+
],
|
|
653
|
+
)
|
|
654
|
+
case Batteries.Mode.ZERO_CHARGE_ONLY:
|
|
655
|
+
return BatteriesUpdate(
|
|
656
|
+
mode=Batteries.Mode.ZERO,
|
|
657
|
+
permissions=[
|
|
658
|
+
Batteries.Permissions.CHARGE_ALLOWED,
|
|
659
|
+
],
|
|
660
|
+
)
|
|
661
|
+
case Batteries.Mode.ZERO_DISCHARGE_ONLY:
|
|
662
|
+
return BatteriesUpdate(
|
|
663
|
+
mode=Batteries.Mode.ZERO,
|
|
664
|
+
permissions=[
|
|
665
|
+
Batteries.Permissions.DISCHARGE_ALLOWED,
|
|
666
|
+
],
|
|
667
|
+
)
|
|
668
|
+
case Batteries.Mode.TO_FULL:
|
|
669
|
+
return BatteriesUpdate(mode=Batteries.Mode.TO_FULL)
|
|
670
|
+
case Batteries.Mode.STANDBY:
|
|
671
|
+
return BatteriesUpdate(mode=Batteries.Mode.STANDBY, permissions=[])
|
|
672
|
+
|
|
673
|
+
raise ValueError(f"Unsupported Batteries.Mode: {mode!r}")
|
|
598
674
|
|
|
599
675
|
|
|
600
676
|
@dataclass(kw_only=True)
|
|
@@ -602,21 +678,64 @@ class Batteries(BaseModel):
|
|
|
602
678
|
"""Represent Batteries config."""
|
|
603
679
|
|
|
604
680
|
class Mode(StrEnum):
|
|
605
|
-
"""Device type allocations.
|
|
681
|
+
"""Device type allocations.
|
|
682
|
+
|
|
683
|
+
This is the list of modes shown to the user. 'zero_charge_only' and 'zero_discharge_only' are
|
|
684
|
+
mapped to 'zero' in the API via the Permissions parameter
|
|
685
|
+
"""
|
|
606
686
|
|
|
607
687
|
ZERO = "zero"
|
|
608
688
|
TO_FULL = "to_full"
|
|
609
689
|
STANDBY = "standby"
|
|
690
|
+
ZERO_CHARGE_ONLY = "zero_charge_only"
|
|
691
|
+
ZERO_DISCHARGE_ONLY = "zero_discharge_only"
|
|
692
|
+
|
|
693
|
+
class Permissions(StrEnum):
|
|
694
|
+
"""Device permission allocations."""
|
|
695
|
+
|
|
696
|
+
CHARGE_ALLOWED = "charge_allowed"
|
|
697
|
+
DISCHARGE_ALLOWED = "discharge_allowed"
|
|
610
698
|
|
|
611
699
|
mode: Mode = field(
|
|
612
700
|
metadata={
|
|
613
701
|
"deserialize": lambda x: Batteries.Mode.__members__.get(x.upper(), None)
|
|
614
702
|
},
|
|
615
703
|
)
|
|
704
|
+
permissions: list[Permissions] = field(
|
|
705
|
+
default_factory=list,
|
|
706
|
+
metadata={
|
|
707
|
+
"deserialize": lambda lst: [
|
|
708
|
+
perm
|
|
709
|
+
for item in lst
|
|
710
|
+
if (perm := Batteries.Permissions.__members__.get(item.upper(), None))
|
|
711
|
+
is not None
|
|
712
|
+
]
|
|
713
|
+
},
|
|
714
|
+
)
|
|
616
715
|
power_w: float = field()
|
|
617
716
|
target_power_w: float = field()
|
|
618
717
|
max_consumption_w: float = field()
|
|
619
718
|
max_production_w: float = field()
|
|
719
|
+
battery_count: int | None = field(default=None)
|
|
720
|
+
|
|
721
|
+
@classmethod
|
|
722
|
+
def __post_deserialize__(cls, obj: Batteries) -> Batteries:
|
|
723
|
+
"""Set correct mode based on permissions after deserialization."""
|
|
724
|
+
# Only adjust if mode is ZERO
|
|
725
|
+
if obj.mode == cls.Mode.ZERO:
|
|
726
|
+
perms = set(obj.permissions)
|
|
727
|
+
if perms == {cls.Permissions.CHARGE_ALLOWED}:
|
|
728
|
+
obj.mode = cls.Mode.ZERO_CHARGE_ONLY
|
|
729
|
+
elif perms == {cls.Permissions.DISCHARGE_ALLOWED}:
|
|
730
|
+
obj.mode = cls.Mode.ZERO_DISCHARGE_ONLY
|
|
731
|
+
elif perms == {
|
|
732
|
+
cls.Permissions.CHARGE_ALLOWED,
|
|
733
|
+
cls.Permissions.DISCHARGE_ALLOWED,
|
|
734
|
+
}:
|
|
735
|
+
obj.mode = cls.Mode.ZERO
|
|
736
|
+
elif perms == set():
|
|
737
|
+
obj.mode = cls.Mode.STANDBY
|
|
738
|
+
return obj
|
|
620
739
|
|
|
621
740
|
|
|
622
741
|
@dataclass(kw_only=True)
|
{python_homewizard_energy-9.2.0 → python_homewizard_energy-10.0.0}/homewizard_energy/v2/__init__.py
RENAMED
|
@@ -159,9 +159,7 @@ class HomeWizardEnergyV2(HomeWizardEnergy):
|
|
|
159
159
|
|
|
160
160
|
try:
|
|
161
161
|
if mode is not None:
|
|
162
|
-
data = BatteriesUpdate(
|
|
163
|
-
mode=mode,
|
|
164
|
-
).to_dict()
|
|
162
|
+
data = BatteriesUpdate.from_mode(mode).to_dict()
|
|
165
163
|
status, response = await self._request(
|
|
166
164
|
"/api/batteries", method=METH_PUT, data=data
|
|
167
165
|
)
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
[tool.poetry]
|
|
2
2
|
name = "python-homewizard-energy"
|
|
3
|
-
version = "
|
|
3
|
+
version = "10.0.0"
|
|
4
4
|
description = "Asynchronous Python client for the HomeWizard Energy"
|
|
5
5
|
authors = ["DCSBL"]
|
|
6
6
|
maintainers = ["DCSBL"]
|
|
@@ -29,29 +29,29 @@ awesomeversion = ">=24.6.0"
|
|
|
29
29
|
aresponses = "^3.0.0"
|
|
30
30
|
flake8 = "^4.0.1"
|
|
31
31
|
flake8-docstrings = "^1.7.0"
|
|
32
|
-
isort = "^6.0
|
|
33
|
-
pre-commit = "^4.
|
|
34
|
-
pre-commit-hooks = "^
|
|
35
|
-
pylint = "^
|
|
36
|
-
pytest = "^8.
|
|
37
|
-
pytest-asyncio = "^
|
|
38
|
-
pytest-cov = "^
|
|
32
|
+
isort = "^6.1.0"
|
|
33
|
+
pre-commit = "^4.5.0"
|
|
34
|
+
pre-commit-hooks = "^6.0.0"
|
|
35
|
+
pylint = "^4.0.4"
|
|
36
|
+
pytest = "^8.4.2"
|
|
37
|
+
pytest-asyncio = "^1.3.0"
|
|
38
|
+
pytest-cov = "^7.0.0"
|
|
39
39
|
yamllint = "^1.37.1"
|
|
40
|
-
pyupgrade = "^3.
|
|
41
|
-
flake8-simplify = "^0.
|
|
40
|
+
pyupgrade = "^3.21.2"
|
|
41
|
+
flake8-simplify = "^0.22.0"
|
|
42
42
|
vulture = "^2.13"
|
|
43
43
|
flake8-bandit = "^3.0.0"
|
|
44
44
|
flake8-bugbear = "^23.3.12"
|
|
45
|
-
flake8-builtins = "^
|
|
46
|
-
flake8-comprehensions = "^3.
|
|
45
|
+
flake8-builtins = "^3.1.0"
|
|
46
|
+
flake8-comprehensions = "^3.17.0"
|
|
47
47
|
flake8-eradicate = "^1.2.1"
|
|
48
48
|
flake8-markdown = "^0.3.0"
|
|
49
|
-
ruff = "0.
|
|
49
|
+
ruff = "0.14.7"
|
|
50
50
|
darglint = "^1.8.1"
|
|
51
|
-
safety = "^3.
|
|
51
|
+
safety = "^3.7.0"
|
|
52
52
|
codespell = "^2.4.1"
|
|
53
|
-
bandit = "^1.
|
|
54
|
-
syrupy = "^
|
|
53
|
+
bandit = "^1.9.2"
|
|
54
|
+
syrupy = "^5.0.0"
|
|
55
55
|
|
|
56
56
|
[tool.poetry.urls]
|
|
57
57
|
"Bug Tracker" = "https://github.com/homewizard/python-homewizard-energy/issues"
|
|
File without changes
|
{python_homewizard_energy-9.2.0 → python_homewizard_energy-10.0.0}/homewizard_energy/__init__.py
RENAMED
|
File without changes
|
{python_homewizard_energy-9.2.0 → python_homewizard_energy-10.0.0}/homewizard_energy/const.py
RENAMED
|
File without changes
|
{python_homewizard_energy-9.2.0 → python_homewizard_energy-10.0.0}/homewizard_energy/errors.py
RENAMED
|
File without changes
|
{python_homewizard_energy-9.2.0 → python_homewizard_energy-10.0.0}/homewizard_energy/py.typed
RENAMED
|
File without changes
|
{python_homewizard_energy-9.2.0 → python_homewizard_energy-10.0.0}/homewizard_energy/utils.py
RENAMED
|
File without changes
|
{python_homewizard_energy-9.2.0 → python_homewizard_energy-10.0.0}/homewizard_energy/v1/__init__.py
RENAMED
|
File without changes
|
{python_homewizard_energy-9.2.0 → python_homewizard_energy-10.0.0}/homewizard_energy/v1/const.py
RENAMED
|
File without changes
|
{python_homewizard_energy-9.2.0 → python_homewizard_energy-10.0.0}/homewizard_energy/v2/cacert.py
RENAMED
|
File without changes
|
{python_homewizard_energy-9.2.0 → python_homewizard_energy-10.0.0}/homewizard_energy/v2/const.py
RENAMED
|
File without changes
|