python-homewizard-energy 8.2.0__tar.gz → 8.3.1__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.2.0 → python_homewizard_energy-8.3.1}/PKG-INFO +1 -1
- {python_homewizard_energy-8.2.0 → python_homewizard_energy-8.3.1}/homewizard_energy/homewizard_energy.py +6 -2
- {python_homewizard_energy-8.2.0 → python_homewizard_energy-8.3.1}/homewizard_energy/models.py +23 -0
- {python_homewizard_energy-8.2.0 → python_homewizard_energy-8.3.1}/homewizard_energy/v2/__init__.py +6 -4
- {python_homewizard_energy-8.2.0 → python_homewizard_energy-8.3.1}/pyproject.toml +2 -1
- {python_homewizard_energy-8.2.0 → python_homewizard_energy-8.3.1}/LICENSE +0 -0
- {python_homewizard_energy-8.2.0 → python_homewizard_energy-8.3.1}/README.md +0 -0
- {python_homewizard_energy-8.2.0 → python_homewizard_energy-8.3.1}/homewizard_energy/__init__.py +0 -0
- {python_homewizard_energy-8.2.0 → python_homewizard_energy-8.3.1}/homewizard_energy/const.py +0 -0
- {python_homewizard_energy-8.2.0 → python_homewizard_energy-8.3.1}/homewizard_energy/errors.py +0 -0
- {python_homewizard_energy-8.2.0 → python_homewizard_energy-8.3.1}/homewizard_energy/py.typed +0 -0
- {python_homewizard_energy-8.2.0 → python_homewizard_energy-8.3.1}/homewizard_energy/utils.py +0 -0
- {python_homewizard_energy-8.2.0 → python_homewizard_energy-8.3.1}/homewizard_energy/v1/__init__.py +0 -0
- {python_homewizard_energy-8.2.0 → python_homewizard_energy-8.3.1}/homewizard_energy/v1/const.py +0 -0
- {python_homewizard_energy-8.2.0 → python_homewizard_energy-8.3.1}/homewizard_energy/v2/cacert.py +0 -0
- {python_homewizard_energy-8.2.0 → python_homewizard_energy-8.3.1}/homewizard_energy/v2/const.py +0 -0
|
@@ -22,6 +22,8 @@ class HomeWizardEnergy:
|
|
|
22
22
|
|
|
23
23
|
_device: Device | None = None
|
|
24
24
|
|
|
25
|
+
_lock: asyncio.Lock
|
|
26
|
+
|
|
25
27
|
def __init__(
|
|
26
28
|
self,
|
|
27
29
|
host: str,
|
|
@@ -40,6 +42,8 @@ class HomeWizardEnergy:
|
|
|
40
42
|
self._close_session = clientsession is None
|
|
41
43
|
self._request_timeout = timeout
|
|
42
44
|
|
|
45
|
+
self._lock = asyncio.Lock()
|
|
46
|
+
|
|
43
47
|
@property
|
|
44
48
|
def host(self) -> str:
|
|
45
49
|
"""Return the hostname of the device.
|
|
@@ -117,6 +121,8 @@ class HomeWizardEnergy:
|
|
|
117
121
|
async def _create_clientsession(self) -> None:
|
|
118
122
|
"""Create a client session."""
|
|
119
123
|
|
|
124
|
+
LOGGER.debug("Creating clientsession")
|
|
125
|
+
|
|
120
126
|
if self._session is not None:
|
|
121
127
|
raise RuntimeError("Session already exists")
|
|
122
128
|
|
|
@@ -131,8 +137,6 @@ class HomeWizardEnergy:
|
|
|
131
137
|
connector=connector, timeout=ClientTimeout(total=self._request_timeout)
|
|
132
138
|
)
|
|
133
139
|
|
|
134
|
-
# self._session = self._create_clientsession(connector, timeout=ClientTimeout(total=self._request_timeout))
|
|
135
|
-
|
|
136
140
|
async def __aenter__(self) -> HomeWizardEnergy:
|
|
137
141
|
"""Async enter.
|
|
138
142
|
|
{python_homewizard_energy-8.2.0 → python_homewizard_energy-8.3.1}/homewizard_energy/models.py
RENAMED
|
@@ -85,6 +85,12 @@ class CombinedModels:
|
|
|
85
85
|
self.system = System()
|
|
86
86
|
self.system.wifi_ssid = self.measurement.wifi_ssid
|
|
87
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
|
+
|
|
88
94
|
## state.brightness -> system.status_led_brightness_pct
|
|
89
95
|
if self.state is not None and self.state.brightness is not None:
|
|
90
96
|
if self.system is None:
|
|
@@ -540,6 +546,8 @@ class SystemUpdate(UpdateBaseModel):
|
|
|
540
546
|
class System(BaseModel):
|
|
541
547
|
"""Represent System config."""
|
|
542
548
|
|
|
549
|
+
wifi_strength_pct: int | None = None
|
|
550
|
+
|
|
543
551
|
wifi_ssid: str | None = field(default=None)
|
|
544
552
|
wifi_rssi_db: int | None = field(default=None)
|
|
545
553
|
cloud_enabled: bool | None = field(default=None)
|
|
@@ -547,6 +555,21 @@ class System(BaseModel):
|
|
|
547
555
|
status_led_brightness_pct: int | None = field(default=None)
|
|
548
556
|
api_v1_enabled: bool | None = field(default=None)
|
|
549
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
|
+
|
|
550
573
|
|
|
551
574
|
@dataclass(kw_only=True)
|
|
552
575
|
class Token(BaseModel):
|
{python_homewizard_energy-8.2.0 → python_homewizard_energy-8.3.1}/homewizard_energy/v2/__init__.py
RENAMED
|
@@ -221,11 +221,13 @@ class HomeWizardEnergyV2(HomeWizardEnergy):
|
|
|
221
221
|
) -> tuple[HTTPStatus, dict[str, Any] | None]:
|
|
222
222
|
"""Make a request to the API."""
|
|
223
223
|
|
|
224
|
-
|
|
225
|
-
|
|
224
|
+
async with self._lock:
|
|
225
|
+
if self._session is None:
|
|
226
|
+
await self._create_clientsession()
|
|
226
227
|
|
|
227
|
-
|
|
228
|
-
self._ssl
|
|
228
|
+
async with self._lock:
|
|
229
|
+
if self._ssl is False:
|
|
230
|
+
self._ssl = await self._get_ssl_context()
|
|
229
231
|
|
|
230
232
|
# Construct request
|
|
231
233
|
url = f"https://{self.host}{path}"
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
[tool.poetry]
|
|
2
2
|
name = "python-homewizard-energy"
|
|
3
|
-
version = "8.
|
|
3
|
+
version = "8.3.1"
|
|
4
4
|
description = "Asynchronous Python client for the HomeWizard Energy"
|
|
5
5
|
authors = ["DCSBL"]
|
|
6
6
|
maintainers = ["DCSBL"]
|
|
@@ -107,6 +107,7 @@ max-attributes=20
|
|
|
107
107
|
|
|
108
108
|
[tool.pytest.ini_options]
|
|
109
109
|
addopts = "--cov"
|
|
110
|
+
asyncio_mode = "auto"
|
|
110
111
|
|
|
111
112
|
[tool.vulture]
|
|
112
113
|
min_confidence = 80
|
|
File without changes
|
|
File without changes
|
{python_homewizard_energy-8.2.0 → python_homewizard_energy-8.3.1}/homewizard_energy/__init__.py
RENAMED
|
File without changes
|
{python_homewizard_energy-8.2.0 → python_homewizard_energy-8.3.1}/homewizard_energy/const.py
RENAMED
|
File without changes
|
{python_homewizard_energy-8.2.0 → python_homewizard_energy-8.3.1}/homewizard_energy/errors.py
RENAMED
|
File without changes
|
{python_homewizard_energy-8.2.0 → python_homewizard_energy-8.3.1}/homewizard_energy/py.typed
RENAMED
|
File without changes
|
{python_homewizard_energy-8.2.0 → python_homewizard_energy-8.3.1}/homewizard_energy/utils.py
RENAMED
|
File without changes
|
{python_homewizard_energy-8.2.0 → python_homewizard_energy-8.3.1}/homewizard_energy/v1/__init__.py
RENAMED
|
File without changes
|
{python_homewizard_energy-8.2.0 → python_homewizard_energy-8.3.1}/homewizard_energy/v1/const.py
RENAMED
|
File without changes
|
{python_homewizard_energy-8.2.0 → python_homewizard_energy-8.3.1}/homewizard_energy/v2/cacert.py
RENAMED
|
File without changes
|
{python_homewizard_energy-8.2.0 → python_homewizard_energy-8.3.1}/homewizard_energy/v2/const.py
RENAMED
|
File without changes
|