python-homewizard-energy 8.1.1__tar.gz → 8.2.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.
Files changed (16) hide show
  1. {python_homewizard_energy-8.1.1 → python_homewizard_energy-8.2.0}/PKG-INFO +2 -1
  2. {python_homewizard_energy-8.1.1 → python_homewizard_energy-8.2.0}/homewizard_energy/models.py +28 -1
  3. python_homewizard_energy-8.2.0/homewizard_energy/utils.py +13 -0
  4. {python_homewizard_energy-8.1.1 → python_homewizard_energy-8.2.0}/homewizard_energy/v2/__init__.py +0 -1
  5. {python_homewizard_energy-8.1.1 → python_homewizard_energy-8.2.0}/pyproject.toml +2 -1
  6. {python_homewizard_energy-8.1.1 → python_homewizard_energy-8.2.0}/LICENSE +0 -0
  7. {python_homewizard_energy-8.1.1 → python_homewizard_energy-8.2.0}/README.md +0 -0
  8. {python_homewizard_energy-8.1.1 → python_homewizard_energy-8.2.0}/homewizard_energy/__init__.py +0 -0
  9. {python_homewizard_energy-8.1.1 → python_homewizard_energy-8.2.0}/homewizard_energy/const.py +0 -0
  10. {python_homewizard_energy-8.1.1 → python_homewizard_energy-8.2.0}/homewizard_energy/errors.py +0 -0
  11. {python_homewizard_energy-8.1.1 → python_homewizard_energy-8.2.0}/homewizard_energy/homewizard_energy.py +0 -0
  12. {python_homewizard_energy-8.1.1 → python_homewizard_energy-8.2.0}/homewizard_energy/py.typed +0 -0
  13. {python_homewizard_energy-8.1.1 → python_homewizard_energy-8.2.0}/homewizard_energy/v1/__init__.py +0 -0
  14. {python_homewizard_energy-8.1.1 → python_homewizard_energy-8.2.0}/homewizard_energy/v1/const.py +0 -0
  15. {python_homewizard_energy-8.1.1 → python_homewizard_energy-8.2.0}/homewizard_energy/v2/cacert.py +0 -0
  16. {python_homewizard_energy-8.1.1 → python_homewizard_energy-8.2.0}/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: 8.1.1
3
+ Version: 8.2.0
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
@@ -13,6 +13,7 @@ Classifier: Programming Language :: Python :: 3.12
13
13
  Classifier: Programming Language :: Python :: 3.13
14
14
  Requires-Dist: aiohttp (>=3.0.0)
15
15
  Requires-Dist: async-timeout (>=4.0.3,<6.0.0)
16
+ Requires-Dist: awesomeversion (>=24.6.0,<25.0.0)
16
17
  Requires-Dist: backoff (>=2.2.1,<3.0.0)
17
18
  Requires-Dist: mashumaro (>=3.15,<4.0)
18
19
  Requires-Dist: multidict (>=6.0.5,<7.0.0)
@@ -7,11 +7,27 @@ from datetime import datetime
7
7
  from enum import StrEnum
8
8
  from typing import Any
9
9
 
10
+ from awesomeversion import AwesomeVersion
10
11
  from mashumaro.config import BaseConfig
11
12
  from mashumaro.exceptions import MissingField
12
13
  from mashumaro.mixins.orjson import DataClassORJSONMixin
14
+ from mashumaro.types import SerializationStrategy
13
15
 
14
16
  from .const import LOGGER, MODEL_TO_ID, MODEL_TO_NAME, Model
17
+ from .utils import get_awesome_version
18
+
19
+
20
+ class AwesomeVersionSerializationStrategy(SerializationStrategy, use_annotations=True):
21
+ """Serialization strategy for AwesomeVersion objects."""
22
+
23
+ def serialize(self, value: AwesomeVersion) -> str:
24
+ """Serialize AwesomeVersion object to string."""
25
+ return str(value)
26
+
27
+ def deserialize(self, value: str) -> AwesomeVersion | None:
28
+ """Deserialize string to AwesomeVersion object."""
29
+ version = get_awesome_version(value)
30
+ return version
15
31
 
16
32
 
17
33
  class BaseModel(DataClassORJSONMixin):
@@ -22,6 +38,9 @@ class BaseModel(DataClassORJSONMixin):
22
38
  """Mashumaro configuration."""
23
39
 
24
40
  serialize_by_alias = True
41
+ serialization_strategy = { # noqa: RUF012
42
+ AwesomeVersion: AwesomeVersionSerializationStrategy()
43
+ }
25
44
  omit_none = True
26
45
 
27
46
 
@@ -95,7 +114,7 @@ class Device(BaseModel):
95
114
  product_name: str = field()
96
115
  product_type: str = field()
97
116
  serial: str = field()
98
- api_version: str = field()
117
+ api_version: AwesomeVersion = field()
99
118
  firmware_version: str = field()
100
119
 
101
120
  @classmethod
@@ -111,6 +130,14 @@ class Device(BaseModel):
111
130
  """Return if the device supports state."""
112
131
  return self.product_type == Model.ENERGY_SOCKET
113
132
 
133
+ def supports_cloud_enable(self) -> bool:
134
+ """Return if the device supports cloud enable/disable."""
135
+ return self.product_type != Model.BATTERY
136
+
137
+ def supports_reboot(self) -> bool:
138
+ """Return if the device supports reboot."""
139
+ return self.api_version.major >= 2
140
+
114
141
  def supports_identify(self) -> bool:
115
142
  """Return if the device supports identify."""
116
143
  return self.product_type not in (
@@ -0,0 +1,13 @@
1
+ """Utilities for Python HomeWizard Energy."""
2
+
3
+ from functools import lru_cache
4
+
5
+ from awesomeversion import AwesomeVersion
6
+
7
+
8
+ @lru_cache
9
+ def get_awesome_version(version: str) -> AwesomeVersion:
10
+ """Return a cached AwesomeVersion object."""
11
+ if version.lower() == "v1":
12
+ return AwesomeVersion("1.0.0")
13
+ return AwesomeVersion(version)
@@ -207,7 +207,6 @@ class HomeWizardEnergyV2(HomeWizardEnergy):
207
207
  if self._identifier is not None:
208
208
  context.hostname_checks_common_name = True
209
209
  else:
210
- LOGGER.warning("No hostname provided, skipping hostname validation")
211
210
  context.check_hostname = False # Skip hostname validation
212
211
  context.verify_mode = ssl.CERT_REQUIRED # Keep SSL verification active
213
212
  return context
@@ -1,6 +1,6 @@
1
1
  [tool.poetry]
2
2
  name = "python-homewizard-energy"
3
- version = "8.1.1"
3
+ version = "8.2.0"
4
4
  description = "Asynchronous Python client for the HomeWizard Energy"
5
5
  authors = ["DCSBL"]
6
6
  maintainers = ["DCSBL"]
@@ -23,6 +23,7 @@ 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 = "^24.6.0"
26
27
 
27
28
  [tool.poetry.dev-dependencies]
28
29
  aresponses = "^3.0.0"