python-homewizard-energy 8.1.1__tar.gz → 8.3.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-8.1.1 → python_homewizard_energy-8.3.0}/PKG-INFO +2 -1
- {python_homewizard_energy-8.1.1 → python_homewizard_energy-8.3.0}/homewizard_energy/models.py +51 -1
- python_homewizard_energy-8.3.0/homewizard_energy/utils.py +13 -0
- {python_homewizard_energy-8.1.1 → python_homewizard_energy-8.3.0}/homewizard_energy/v2/__init__.py +0 -1
- {python_homewizard_energy-8.1.1 → python_homewizard_energy-8.3.0}/pyproject.toml +2 -1
- {python_homewizard_energy-8.1.1 → python_homewizard_energy-8.3.0}/LICENSE +0 -0
- {python_homewizard_energy-8.1.1 → python_homewizard_energy-8.3.0}/README.md +0 -0
- {python_homewizard_energy-8.1.1 → python_homewizard_energy-8.3.0}/homewizard_energy/__init__.py +0 -0
- {python_homewizard_energy-8.1.1 → python_homewizard_energy-8.3.0}/homewizard_energy/const.py +0 -0
- {python_homewizard_energy-8.1.1 → python_homewizard_energy-8.3.0}/homewizard_energy/errors.py +0 -0
- {python_homewizard_energy-8.1.1 → python_homewizard_energy-8.3.0}/homewizard_energy/homewizard_energy.py +0 -0
- {python_homewizard_energy-8.1.1 → python_homewizard_energy-8.3.0}/homewizard_energy/py.typed +0 -0
- {python_homewizard_energy-8.1.1 → python_homewizard_energy-8.3.0}/homewizard_energy/v1/__init__.py +0 -0
- {python_homewizard_energy-8.1.1 → python_homewizard_energy-8.3.0}/homewizard_energy/v1/const.py +0 -0
- {python_homewizard_energy-8.1.1 → python_homewizard_energy-8.3.0}/homewizard_energy/v2/cacert.py +0 -0
- {python_homewizard_energy-8.1.1 → python_homewizard_energy-8.3.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.
|
|
3
|
+
Version: 8.3.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)
|
{python_homewizard_energy-8.1.1 → python_homewizard_energy-8.3.0}/homewizard_energy/models.py
RENAMED
|
@@ -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
|
|
|
@@ -66,6 +85,12 @@ class CombinedModels:
|
|
|
66
85
|
self.system = System()
|
|
67
86
|
self.system.wifi_ssid = self.measurement.wifi_ssid
|
|
68
87
|
|
|
88
|
+
## measurement.wifi_strength -> system.wifi_strength_pct
|
|
89
|
+
if self.measurement is not None and self.measurement.wifi_strength is not None:
|
|
90
|
+
if self.system is None:
|
|
91
|
+
self.system = System()
|
|
92
|
+
self.system.wifi_strength_pct = self.measurement.wifi_strength
|
|
93
|
+
|
|
69
94
|
## state.brightness -> system.status_led_brightness_pct
|
|
70
95
|
if self.state is not None and self.state.brightness is not None:
|
|
71
96
|
if self.system is None:
|
|
@@ -95,7 +120,7 @@ class Device(BaseModel):
|
|
|
95
120
|
product_name: str = field()
|
|
96
121
|
product_type: str = field()
|
|
97
122
|
serial: str = field()
|
|
98
|
-
api_version:
|
|
123
|
+
api_version: AwesomeVersion = field()
|
|
99
124
|
firmware_version: str = field()
|
|
100
125
|
|
|
101
126
|
@classmethod
|
|
@@ -111,6 +136,14 @@ class Device(BaseModel):
|
|
|
111
136
|
"""Return if the device supports state."""
|
|
112
137
|
return self.product_type == Model.ENERGY_SOCKET
|
|
113
138
|
|
|
139
|
+
def supports_cloud_enable(self) -> bool:
|
|
140
|
+
"""Return if the device supports cloud enable/disable."""
|
|
141
|
+
return self.product_type != Model.BATTERY
|
|
142
|
+
|
|
143
|
+
def supports_reboot(self) -> bool:
|
|
144
|
+
"""Return if the device supports reboot."""
|
|
145
|
+
return self.api_version.major >= 2
|
|
146
|
+
|
|
114
147
|
def supports_identify(self) -> bool:
|
|
115
148
|
"""Return if the device supports identify."""
|
|
116
149
|
return self.product_type not in (
|
|
@@ -513,6 +546,8 @@ class SystemUpdate(UpdateBaseModel):
|
|
|
513
546
|
class System(BaseModel):
|
|
514
547
|
"""Represent System config."""
|
|
515
548
|
|
|
549
|
+
wifi_strength_pct: int | None = None
|
|
550
|
+
|
|
516
551
|
wifi_ssid: str | None = field(default=None)
|
|
517
552
|
wifi_rssi_db: int | None = field(default=None)
|
|
518
553
|
cloud_enabled: bool | None = field(default=None)
|
|
@@ -520,6 +555,21 @@ class System(BaseModel):
|
|
|
520
555
|
status_led_brightness_pct: int | None = field(default=None)
|
|
521
556
|
api_v1_enabled: bool | None = field(default=None)
|
|
522
557
|
|
|
558
|
+
@classmethod
|
|
559
|
+
def __post_deserialize__(cls, obj: System) -> System:
|
|
560
|
+
_ = cls # Unused
|
|
561
|
+
|
|
562
|
+
if obj.wifi_rssi_db is not None:
|
|
563
|
+
obj.wifi_strength_pct = (
|
|
564
|
+
0
|
|
565
|
+
if obj.wifi_rssi_db <= -100 or obj.wifi_rssi_db == 0
|
|
566
|
+
else 100
|
|
567
|
+
if obj.wifi_rssi_db >= -50
|
|
568
|
+
else 2 * (obj.wifi_rssi_db + 100)
|
|
569
|
+
)
|
|
570
|
+
|
|
571
|
+
return obj
|
|
572
|
+
|
|
523
573
|
|
|
524
574
|
@dataclass(kw_only=True)
|
|
525
575
|
class Token(BaseModel):
|
|
@@ -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)
|
{python_homewizard_energy-8.1.1 → python_homewizard_energy-8.3.0}/homewizard_energy/v2/__init__.py
RENAMED
|
@@ -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.
|
|
3
|
+
version = "8.3.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"
|
|
File without changes
|
|
File without changes
|
{python_homewizard_energy-8.1.1 → python_homewizard_energy-8.3.0}/homewizard_energy/__init__.py
RENAMED
|
File without changes
|
{python_homewizard_energy-8.1.1 → python_homewizard_energy-8.3.0}/homewizard_energy/const.py
RENAMED
|
File without changes
|
{python_homewizard_energy-8.1.1 → python_homewizard_energy-8.3.0}/homewizard_energy/errors.py
RENAMED
|
File without changes
|
|
File without changes
|
{python_homewizard_energy-8.1.1 → python_homewizard_energy-8.3.0}/homewizard_energy/py.typed
RENAMED
|
File without changes
|
{python_homewizard_energy-8.1.1 → python_homewizard_energy-8.3.0}/homewizard_energy/v1/__init__.py
RENAMED
|
File without changes
|
{python_homewizard_energy-8.1.1 → python_homewizard_energy-8.3.0}/homewizard_energy/v1/const.py
RENAMED
|
File without changes
|
{python_homewizard_energy-8.1.1 → python_homewizard_energy-8.3.0}/homewizard_energy/v2/cacert.py
RENAMED
|
File without changes
|
{python_homewizard_energy-8.1.1 → python_homewizard_energy-8.3.0}/homewizard_energy/v2/const.py
RENAMED
|
File without changes
|