python-homewizard-energy 8.0.0a2__tar.gz → 8.0.0a3__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.0.0a2 → python_homewizard_energy-8.0.0a3}/PKG-INFO +1 -1
- {python_homewizard_energy-8.0.0a2 → python_homewizard_energy-8.0.0a3}/homewizard_energy/__init__.py +2 -0
- {python_homewizard_energy-8.0.0a2 → python_homewizard_energy-8.0.0a3}/homewizard_energy/homewizard_energy.py +7 -11
- {python_homewizard_energy-8.0.0a2 → python_homewizard_energy-8.0.0a3}/homewizard_energy/models.py +2 -2
- {python_homewizard_energy-8.0.0a2 → python_homewizard_energy-8.0.0a3}/homewizard_energy/v1/__init__.py +42 -27
- {python_homewizard_energy-8.0.0a2 → python_homewizard_energy-8.0.0a3}/homewizard_energy/v2/__init__.py +13 -3
- {python_homewizard_energy-8.0.0a2 → python_homewizard_energy-8.0.0a3}/pyproject.toml +1 -1
- {python_homewizard_energy-8.0.0a2 → python_homewizard_energy-8.0.0a3}/LICENSE +0 -0
- {python_homewizard_energy-8.0.0a2 → python_homewizard_energy-8.0.0a3}/README.md +0 -0
- {python_homewizard_energy-8.0.0a2 → python_homewizard_energy-8.0.0a3}/homewizard_energy/const.py +0 -0
- {python_homewizard_energy-8.0.0a2 → python_homewizard_energy-8.0.0a3}/homewizard_energy/errors.py +0 -0
- {python_homewizard_energy-8.0.0a2 → python_homewizard_energy-8.0.0a3}/homewizard_energy/py.typed +0 -0
- {python_homewizard_energy-8.0.0a2 → python_homewizard_energy-8.0.0a3}/homewizard_energy/v1/const.py +0 -0
- {python_homewizard_energy-8.0.0a2 → python_homewizard_energy-8.0.0a3}/homewizard_energy/v2/cacert.py +0 -0
- {python_homewizard_energy-8.0.0a2 → python_homewizard_energy-8.0.0a3}/homewizard_energy/v2/const.py +0 -0
{python_homewizard_energy-8.0.0a2 → python_homewizard_energy-8.0.0a3}/homewizard_energy/__init__.py
RENAMED
|
@@ -3,11 +3,13 @@
|
|
|
3
3
|
from aiohttp import ClientSession
|
|
4
4
|
|
|
5
5
|
from .errors import DisabledError, InvalidStateError, RequestError, UnsupportedError
|
|
6
|
+
from .homewizard_energy import HomeWizardEnergy
|
|
6
7
|
from .v1 import HomeWizardEnergyV1
|
|
7
8
|
from .v2 import HomeWizardEnergyV2
|
|
8
9
|
|
|
9
10
|
__all__ = [
|
|
10
11
|
"DisabledError",
|
|
12
|
+
"HomeWizardEnergy",
|
|
11
13
|
"HomeWizardEnergyV1",
|
|
12
14
|
"HomeWizardEnergyV2",
|
|
13
15
|
"InvalidStateError",
|
|
@@ -9,15 +9,7 @@ from aiohttp.client import ClientSession
|
|
|
9
9
|
|
|
10
10
|
from .const import LOGGER
|
|
11
11
|
from .errors import UnsupportedError
|
|
12
|
-
from .models import
|
|
13
|
-
CombinedModels,
|
|
14
|
-
Device,
|
|
15
|
-
Measurement,
|
|
16
|
-
State,
|
|
17
|
-
StateUpdate,
|
|
18
|
-
System,
|
|
19
|
-
SystemUpdate,
|
|
20
|
-
)
|
|
12
|
+
from .models import CombinedModels, Device, Measurement, State, System
|
|
21
13
|
|
|
22
14
|
|
|
23
15
|
class HomeWizardEnergy:
|
|
@@ -90,14 +82,18 @@ class HomeWizardEnergy:
|
|
|
90
82
|
|
|
91
83
|
async def system(
|
|
92
84
|
self,
|
|
93
|
-
|
|
85
|
+
cloud_enabled: bool | None = None,
|
|
86
|
+
status_led_brightness_pct: int | None = None,
|
|
87
|
+
api_v1_enabled: bool | None = None,
|
|
94
88
|
) -> System:
|
|
95
89
|
"""Get/set the system."""
|
|
96
90
|
raise NotImplementedError
|
|
97
91
|
|
|
98
92
|
async def state(
|
|
99
93
|
self,
|
|
100
|
-
|
|
94
|
+
power_on: bool | None = None,
|
|
95
|
+
switch_lock: bool | None = None,
|
|
96
|
+
brightness: int | None = None,
|
|
101
97
|
) -> State:
|
|
102
98
|
"""Get/set the state."""
|
|
103
99
|
raise UnsupportedError("State is not supported")
|
{python_homewizard_energy-8.0.0a2 → python_homewizard_energy-8.0.0a3}/homewizard_energy/models.py
RENAMED
|
@@ -43,7 +43,7 @@ class CombinedModels:
|
|
|
43
43
|
"""All values."""
|
|
44
44
|
|
|
45
45
|
device: Device
|
|
46
|
-
measurement: Measurement
|
|
46
|
+
measurement: Measurement
|
|
47
47
|
state: State | None
|
|
48
48
|
system: System | None
|
|
49
49
|
|
|
@@ -86,7 +86,7 @@ class Device(BaseModel):
|
|
|
86
86
|
"""Return if the device supports state."""
|
|
87
87
|
return self.product_type == Model.ENERGY_SOCKET
|
|
88
88
|
|
|
89
|
-
def
|
|
89
|
+
def supports_identify(self) -> bool:
|
|
90
90
|
"""Return if the device supports identify."""
|
|
91
91
|
return self.product_type not in (
|
|
92
92
|
Model.ENERGY_METER_1_PHASE,
|
|
@@ -81,52 +81,67 @@ class HomeWizardEnergyV1(HomeWizardEnergy):
|
|
|
81
81
|
return Measurement.from_json(response)
|
|
82
82
|
|
|
83
83
|
@optional_method
|
|
84
|
-
async def
|
|
85
|
-
|
|
84
|
+
async def system(
|
|
85
|
+
self,
|
|
86
|
+
cloud_enabled: bool | None = None,
|
|
87
|
+
status_led_brightness_pct: int | None = None,
|
|
88
|
+
api_v1_enabled: bool | None = None,
|
|
89
|
+
) -> System:
|
|
90
|
+
"""Return the system object."""
|
|
86
91
|
|
|
87
|
-
|
|
88
|
-
|
|
92
|
+
# Legacy: raise on unsupported field
|
|
93
|
+
if api_v1_enabled is not None:
|
|
94
|
+
raise UnsupportedError("Setting api_v1_enabled is not supported in v1")
|
|
89
95
|
|
|
90
|
-
|
|
91
|
-
|
|
96
|
+
# Legacy: route 'status_led_brightness_pct' to state
|
|
97
|
+
if status_led_brightness_pct is not None:
|
|
98
|
+
state = await self.state(brightness=status_led_brightness_pct * 2.55)
|
|
99
|
+
return System(status_led_brightness_pct=state.brightness / 2.55)
|
|
100
|
+
|
|
101
|
+
if cloud_enabled is not None:
|
|
102
|
+
# Executing the update
|
|
103
|
+
data = SystemUpdate(cloud_enabled=cloud_enabled).to_dict()
|
|
92
104
|
status, response = await self._request(
|
|
93
|
-
"api/v1/
|
|
105
|
+
"api/v1/system", method=METH_PUT, data=data
|
|
94
106
|
)
|
|
95
107
|
|
|
96
108
|
else:
|
|
97
|
-
status, response = await self._request("api/v1/
|
|
109
|
+
status, response = await self._request("api/v1/system")
|
|
98
110
|
|
|
99
111
|
if status != HTTPStatus.OK:
|
|
100
|
-
raise RequestError("Failed to get/set
|
|
112
|
+
raise RequestError("Failed to get/set system")
|
|
101
113
|
|
|
102
|
-
|
|
103
|
-
return
|
|
114
|
+
system = System.from_json(response)
|
|
115
|
+
return system
|
|
104
116
|
|
|
105
117
|
@optional_method
|
|
106
|
-
async def
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
118
|
+
async def state(
|
|
119
|
+
self,
|
|
120
|
+
power_on: bool | None = None,
|
|
121
|
+
switch_lock: bool | None = None,
|
|
122
|
+
brightness: int | None = None,
|
|
123
|
+
) -> State:
|
|
124
|
+
"""Return or update the state object."""
|
|
125
|
+
|
|
126
|
+
if self._device is not None and self._device.supports_state is False:
|
|
127
|
+
raise UnsupportedError("State is not supported")
|
|
116
128
|
|
|
117
|
-
|
|
129
|
+
if power_on is not None or switch_lock is not None or brightness is not None:
|
|
130
|
+
data = StateUpdate(
|
|
131
|
+
power_on=power_on, switch_lock=switch_lock, brightness=brightness
|
|
132
|
+
).to_dict()
|
|
118
133
|
status, response = await self._request(
|
|
119
|
-
"api/v1/
|
|
134
|
+
"api/v1/state", method=METH_PUT, data=data
|
|
120
135
|
)
|
|
121
136
|
|
|
122
137
|
else:
|
|
123
|
-
status, response = await self._request("api/v1/
|
|
138
|
+
status, response = await self._request("api/v1/state")
|
|
124
139
|
|
|
125
140
|
if status != HTTPStatus.OK:
|
|
126
|
-
raise RequestError("Failed to get/set
|
|
141
|
+
raise RequestError("Failed to get/set state")
|
|
127
142
|
|
|
128
|
-
|
|
129
|
-
return
|
|
143
|
+
state = State.from_json(response)
|
|
144
|
+
return state
|
|
130
145
|
|
|
131
146
|
@optional_method
|
|
132
147
|
async def identify(
|
|
@@ -90,12 +90,22 @@ class HomeWizardEnergyV2(HomeWizardEnergy):
|
|
|
90
90
|
@authorized_method
|
|
91
91
|
async def system(
|
|
92
92
|
self,
|
|
93
|
-
|
|
93
|
+
cloud_enabled: bool | None = None,
|
|
94
|
+
status_led_brightness_pct: int | None = None,
|
|
95
|
+
api_v1_enabled: bool | None = None,
|
|
94
96
|
) -> System:
|
|
95
97
|
"""Return the system object."""
|
|
96
98
|
|
|
97
|
-
if
|
|
98
|
-
|
|
99
|
+
if (
|
|
100
|
+
cloud_enabled is not None
|
|
101
|
+
or status_led_brightness_pct is not None
|
|
102
|
+
or api_v1_enabled is not None
|
|
103
|
+
):
|
|
104
|
+
data = SystemUpdate(
|
|
105
|
+
cloud_enabled=cloud_enabled,
|
|
106
|
+
status_led_brightness_pct=status_led_brightness_pct,
|
|
107
|
+
api_v1_enabled=api_v1_enabled,
|
|
108
|
+
).to_dict()
|
|
99
109
|
status, response = await self._request(
|
|
100
110
|
"/api/system", method=METH_PUT, data=data
|
|
101
111
|
)
|
|
File without changes
|
|
File without changes
|
{python_homewizard_energy-8.0.0a2 → python_homewizard_energy-8.0.0a3}/homewizard_energy/const.py
RENAMED
|
File without changes
|
{python_homewizard_energy-8.0.0a2 → python_homewizard_energy-8.0.0a3}/homewizard_energy/errors.py
RENAMED
|
File without changes
|
{python_homewizard_energy-8.0.0a2 → python_homewizard_energy-8.0.0a3}/homewizard_energy/py.typed
RENAMED
|
File without changes
|
{python_homewizard_energy-8.0.0a2 → python_homewizard_energy-8.0.0a3}/homewizard_energy/v1/const.py
RENAMED
|
File without changes
|
{python_homewizard_energy-8.0.0a2 → python_homewizard_energy-8.0.0a3}/homewizard_energy/v2/cacert.py
RENAMED
|
File without changes
|
{python_homewizard_energy-8.0.0a2 → python_homewizard_energy-8.0.0a3}/homewizard_energy/v2/const.py
RENAMED
|
File without changes
|