python-homewizard-energy 10.0.0b1__tar.gz → 10.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-10.0.0b1 → python_homewizard_energy-10.1.0b1}/PKG-INFO +1 -2
  2. {python_homewizard_energy-10.0.0b1 → python_homewizard_energy-10.1.0b1}/homewizard_energy/models.py +36 -18
  3. {python_homewizard_energy-10.0.0b1 → python_homewizard_energy-10.1.0b1}/homewizard_energy/v1/__init__.py +2 -3
  4. {python_homewizard_energy-10.0.0b1 → python_homewizard_energy-10.1.0b1}/homewizard_energy/v2/__init__.py +2 -3
  5. {python_homewizard_energy-10.0.0b1 → python_homewizard_energy-10.1.0b1}/pyproject.toml +2 -3
  6. {python_homewizard_energy-10.0.0b1 → python_homewizard_energy-10.1.0b1}/LICENSE +0 -0
  7. {python_homewizard_energy-10.0.0b1 → python_homewizard_energy-10.1.0b1}/README.md +0 -0
  8. {python_homewizard_energy-10.0.0b1 → python_homewizard_energy-10.1.0b1}/homewizard_energy/__init__.py +0 -0
  9. {python_homewizard_energy-10.0.0b1 → python_homewizard_energy-10.1.0b1}/homewizard_energy/const.py +0 -0
  10. {python_homewizard_energy-10.0.0b1 → python_homewizard_energy-10.1.0b1}/homewizard_energy/errors.py +0 -0
  11. {python_homewizard_energy-10.0.0b1 → python_homewizard_energy-10.1.0b1}/homewizard_energy/homewizard_energy.py +0 -0
  12. {python_homewizard_energy-10.0.0b1 → python_homewizard_energy-10.1.0b1}/homewizard_energy/py.typed +0 -0
  13. {python_homewizard_energy-10.0.0b1 → python_homewizard_energy-10.1.0b1}/homewizard_energy/utils.py +0 -0
  14. {python_homewizard_energy-10.0.0b1 → python_homewizard_energy-10.1.0b1}/homewizard_energy/v1/const.py +0 -0
  15. {python_homewizard_energy-10.0.0b1 → python_homewizard_energy-10.1.0b1}/homewizard_energy/v2/cacert.py +0 -0
  16. {python_homewizard_energy-10.0.0b1 → python_homewizard_energy-10.1.0b1}/homewizard_energy/v2/const.py +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: python-homewizard-energy
3
- Version: 10.0.0b1
3
+ Version: 10.1.0b1
4
4
  Summary: Asynchronous Python client for the HomeWizard Energy
5
5
  License: Apache-2.0
6
6
  License-File: LICENSE
@@ -13,7 +13,6 @@ Classifier: Programming Language :: Python :: 3.12
13
13
  Classifier: Programming Language :: Python :: 3.13
14
14
  Classifier: Programming Language :: Python :: 3.14
15
15
  Requires-Dist: aiohttp (>=3.0.0)
16
- Requires-Dist: async-timeout (>=4.0.3,<6.0.0)
17
16
  Requires-Dist: awesomeversion (>=24.6.0)
18
17
  Requires-Dist: backoff (>=2.2.1,<3.0.0)
19
18
  Requires-Dist: mashumaro (>=3.15,<4.0)
@@ -192,9 +192,9 @@ class Device(BaseModel):
192
192
  return None
193
193
 
194
194
  modes = [
195
- Batteries.Mode.ZERO,
196
- Batteries.Mode.TO_FULL,
197
195
  Batteries.Mode.STANDBY,
196
+ Batteries.Mode.TO_FULL,
197
+ Batteries.Mode.ZERO,
198
198
  ]
199
199
 
200
200
  if self.api_version >= AwesomeVersion("2.2.0"):
@@ -667,6 +667,8 @@ class BatteriesUpdate(UpdateBaseModel):
667
667
  )
668
668
  case Batteries.Mode.TO_FULL:
669
669
  return BatteriesUpdate(mode=Batteries.Mode.TO_FULL)
670
+ case Batteries.Mode.PREDICTIVE:
671
+ return BatteriesUpdate(mode=Batteries.Mode.PREDICTIVE)
670
672
  case Batteries.Mode.STANDBY:
671
673
  return BatteriesUpdate(mode=Batteries.Mode.STANDBY, permissions=[])
672
674
 
@@ -686,6 +688,7 @@ class Batteries(BaseModel):
686
688
 
687
689
  ZERO = "zero"
688
690
  TO_FULL = "to_full"
691
+ PREDICTIVE = "predictive"
689
692
  STANDBY = "standby"
690
693
  ZERO_CHARGE_ONLY = "zero_charge_only"
691
694
  ZERO_DISCHARGE_ONLY = "zero_discharge_only"
@@ -701,8 +704,8 @@ class Batteries(BaseModel):
701
704
  "deserialize": lambda x: Batteries.Mode.__members__.get(x.upper(), None)
702
705
  },
703
706
  )
704
- permissions: list[Permissions] = field(
705
- default_factory=list,
707
+ permissions: list[Permissions] | None = field(
708
+ default=None,
706
709
  metadata={
707
710
  "deserialize": lambda lst: [
708
711
  perm
@@ -710,6 +713,8 @@ class Batteries(BaseModel):
710
713
  if (perm := Batteries.Permissions.__members__.get(item.upper(), None))
711
714
  is not None
712
715
  ]
716
+ if lst is not None
717
+ else None
713
718
  },
714
719
  )
715
720
  power_w: float = field()
@@ -720,21 +725,34 @@ class Batteries(BaseModel):
720
725
 
721
726
  @classmethod
722
727
  def __post_deserialize__(cls, obj: Batteries) -> Batteries:
723
- """Set correct mode based on permissions after deserialization."""
728
+ """Set correct mode based on permissions after deserialization.
729
+ If permissions is missing and mode is ZERO, keep mode as ZERO for backwards compatibility.
730
+ If permissions is present (even if empty), apply the mapping logic.
731
+ """
724
732
  # 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
733
+ if obj.mode != cls.Mode.ZERO:
734
+ return obj
735
+
736
+ # Detect if 'permissions' was present in the original data
737
+ # If using mashumaro, the original dict is not available here, so we infer:
738
+ # If permissions is None, treat as 'not provided'. If it's an empty list, treat as 'provided but empty'.
739
+ if obj.permissions is None:
740
+ # Permissions not provided, keep mode as ZERO (backwards compatibility)
741
+ return obj
742
+
743
+ perms = set(obj.permissions)
744
+ if perms == {cls.Permissions.CHARGE_ALLOWED}:
745
+ obj.mode = cls.Mode.ZERO_CHARGE_ONLY
746
+ elif perms == {cls.Permissions.DISCHARGE_ALLOWED}:
747
+ obj.mode = cls.Mode.ZERO_DISCHARGE_ONLY
748
+ elif perms == {
749
+ cls.Permissions.CHARGE_ALLOWED,
750
+ cls.Permissions.DISCHARGE_ALLOWED,
751
+ }:
752
+ obj.mode = cls.Mode.ZERO
753
+ elif perms == set():
754
+ obj.mode = cls.Mode.STANDBY
755
+
738
756
  return obj
739
757
 
740
758
 
@@ -7,7 +7,6 @@ from collections.abc import Callable, Coroutine
7
7
  from http import HTTPStatus
8
8
  from typing import Any, TypeVar
9
9
 
10
- import async_timeout
11
10
  import backoff
12
11
  from aiohttp.client import ClientError, ClientResponseError
13
12
  from aiohttp.hdrs import METH_GET, METH_PUT
@@ -153,7 +152,7 @@ class HomeWizardEnergyV1(HomeWizardEnergy):
153
152
  LOGGER.debug("%s, %s, %s", method, url, data)
154
153
 
155
154
  try:
156
- async with async_timeout.timeout(self._request_timeout):
155
+ async with asyncio.timeout(self._request_timeout):
157
156
  resp = await self._session.request(
158
157
  method,
159
158
  url,
@@ -161,7 +160,7 @@ class HomeWizardEnergyV1(HomeWizardEnergy):
161
160
  headers=headers,
162
161
  )
163
162
  LOGGER.debug("%s, %s", resp.status, await resp.text("utf-8"))
164
- except asyncio.TimeoutError as exception:
163
+ except TimeoutError as exception:
165
164
  raise RequestError(
166
165
  f"Timeout occurred while connecting to the HomeWizard Energy device at {self.host}"
167
166
  ) from exception
@@ -9,7 +9,6 @@ from collections.abc import Callable, Coroutine
9
9
  from http import HTTPStatus
10
10
  from typing import Any, TypeVar
11
11
 
12
- import async_timeout
13
12
  import backoff
14
13
  from aiohttp.client import ClientError, ClientResponseError, ClientSession
15
14
  from aiohttp.hdrs import METH_DELETE, METH_GET, METH_POST, METH_PUT
@@ -287,7 +286,7 @@ class HomeWizardEnergyV2(HomeWizardEnergy):
287
286
  LOGGER.debug("%s, %s, %s", method, url, data)
288
287
 
289
288
  try:
290
- async with async_timeout.timeout(self._request_timeout):
289
+ async with asyncio.timeout(self._request_timeout):
291
290
  async with self._lock:
292
291
  resp = await self._session.request(
293
292
  method,
@@ -298,7 +297,7 @@ class HomeWizardEnergyV2(HomeWizardEnergy):
298
297
  server_hostname=self._identifier,
299
298
  )
300
299
  LOGGER.debug("%s, %s", resp.status, await resp.text("utf-8"))
301
- except asyncio.TimeoutError as exception:
300
+ except TimeoutError as exception:
302
301
  raise RequestError(
303
302
  f"Timeout occurred while connecting to the HomeWizard Energy device at {self.host}"
304
303
  ) from exception
@@ -1,6 +1,6 @@
1
1
  [tool.poetry]
2
2
  name = "python-homewizard-energy"
3
- version = "10.0.0-beta-1"
3
+ version = "10.1.0b1"
4
4
  description = "Asynchronous Python client for the HomeWizard Energy"
5
5
  authors = ["DCSBL"]
6
6
  maintainers = ["DCSBL"]
@@ -18,7 +18,6 @@ packages = [
18
18
  [tool.poetry.dependencies]
19
19
  python = "^3.12"
20
20
  aiohttp = ">=3.0.0"
21
- async-timeout = ">=4.0.3,<6.0.0"
22
21
  multidict = "^6.0.5" ## To fix aiohttp dependency at python 3.12
23
22
  backoff = "^2.2.1"
24
23
  orjson = "^3.10"
@@ -33,7 +32,7 @@ isort = "^6.1.0"
33
32
  pre-commit = "^4.5.0"
34
33
  pre-commit-hooks = "^6.0.0"
35
34
  pylint = "^4.0.4"
36
- pytest = "^8.4.2"
35
+ pytest = "^9.0.3"
37
36
  pytest-asyncio = "^1.3.0"
38
37
  pytest-cov = "^7.0.0"
39
38
  yamllint = "^1.37.1"