python-homewizard-energy 10.2.0__tar.gz → 10.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-10.2.0 → python_homewizard_energy-10.3.0}/PKG-INFO +3 -3
- {python_homewizard_energy-10.2.0 → python_homewizard_energy-10.3.0}/README.md +2 -2
- {python_homewizard_energy-10.2.0 → python_homewizard_energy-10.3.0}/homewizard_energy/homewizard_energy.py +3 -0
- {python_homewizard_energy-10.2.0 → python_homewizard_energy-10.3.0}/homewizard_energy/models.py +16 -0
- {python_homewizard_energy-10.2.0 → python_homewizard_energy-10.3.0}/homewizard_energy/v1/__init__.py +26 -4
- {python_homewizard_energy-10.2.0 → python_homewizard_energy-10.3.0}/homewizard_energy/v2/__init__.py +13 -0
- {python_homewizard_energy-10.2.0 → python_homewizard_energy-10.3.0}/pyproject.toml +1 -1
- {python_homewizard_energy-10.2.0 → python_homewizard_energy-10.3.0}/LICENSE +0 -0
- {python_homewizard_energy-10.2.0 → python_homewizard_energy-10.3.0}/homewizard_energy/__init__.py +0 -0
- {python_homewizard_energy-10.2.0 → python_homewizard_energy-10.3.0}/homewizard_energy/const.py +0 -0
- {python_homewizard_energy-10.2.0 → python_homewizard_energy-10.3.0}/homewizard_energy/errors.py +0 -0
- {python_homewizard_energy-10.2.0 → python_homewizard_energy-10.3.0}/homewizard_energy/py.typed +0 -0
- {python_homewizard_energy-10.2.0 → python_homewizard_energy-10.3.0}/homewizard_energy/utils.py +0 -0
- {python_homewizard_energy-10.2.0 → python_homewizard_energy-10.3.0}/homewizard_energy/v1/const.py +0 -0
- {python_homewizard_energy-10.2.0 → python_homewizard_energy-10.3.0}/homewizard_energy/v2/cacert.py +0 -0
- {python_homewizard_energy-10.2.0 → python_homewizard_energy-10.3.0}/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.
|
|
3
|
+
Version: 10.3.0
|
|
4
4
|
Summary: Asynchronous Python client for the HomeWizard Energy
|
|
5
5
|
License: Apache-2.0
|
|
6
6
|
License-File: LICENSE
|
|
@@ -73,8 +73,8 @@ async def main():
|
|
|
73
73
|
# Get all data and remap v1 data to new v2 structure
|
|
74
74
|
print(await api.combined())
|
|
75
75
|
|
|
76
|
-
# Turn on the Energy Socket outlet
|
|
77
|
-
await api.
|
|
76
|
+
# Turn on the Energy Socket outlet (works with both v1 and v2 API)
|
|
77
|
+
await api.system(power_on=True)
|
|
78
78
|
|
|
79
79
|
|
|
80
80
|
asyncio.run(main())
|
|
@@ -46,8 +46,8 @@ async def main():
|
|
|
46
46
|
# Get all data and remap v1 data to new v2 structure
|
|
47
47
|
print(await api.combined())
|
|
48
48
|
|
|
49
|
-
# Turn on the Energy Socket outlet
|
|
50
|
-
await api.
|
|
49
|
+
# Turn on the Energy Socket outlet (works with both v1 and v2 API)
|
|
50
|
+
await api.system(power_on=True)
|
|
51
51
|
|
|
52
52
|
|
|
53
53
|
asyncio.run(main())
|
|
@@ -91,11 +91,14 @@ class HomeWizardEnergy:
|
|
|
91
91
|
"""Get the latest telegram."""
|
|
92
92
|
raise NotImplementedError
|
|
93
93
|
|
|
94
|
+
# pylint: disable-next=too-many-arguments,too-many-positional-arguments
|
|
94
95
|
async def system(
|
|
95
96
|
self,
|
|
96
97
|
cloud_enabled: bool | None = None,
|
|
97
98
|
status_led_brightness_pct: int | None = None,
|
|
98
99
|
api_v1_enabled: bool | None = None,
|
|
100
|
+
power_on: bool | None = None,
|
|
101
|
+
switch_lock: bool | None = None,
|
|
99
102
|
) -> System:
|
|
100
103
|
"""Get/set the system."""
|
|
101
104
|
raise NotImplementedError
|
{python_homewizard_energy-10.2.0 → python_homewizard_energy-10.3.0}/homewizard_energy/models.py
RENAMED
|
@@ -102,6 +102,18 @@ class CombinedModels:
|
|
|
102
102
|
self.system = System()
|
|
103
103
|
self.system.status_led_brightness_pct = (self.state.brightness / 255) * 100
|
|
104
104
|
|
|
105
|
+
## state.power_on -> system.power_on
|
|
106
|
+
if self.state is not None and self.state.power_on is not None:
|
|
107
|
+
if self.system is None:
|
|
108
|
+
self.system = System()
|
|
109
|
+
self.system.power_on = self.state.power_on
|
|
110
|
+
|
|
111
|
+
## state.switch_lock -> system.switch_lock
|
|
112
|
+
if self.state is not None and self.state.switch_lock is not None:
|
|
113
|
+
if self.system is None:
|
|
114
|
+
self.system = System()
|
|
115
|
+
self.system.switch_lock = self.state.switch_lock
|
|
116
|
+
|
|
105
117
|
|
|
106
118
|
def get_verification_hostname(model: str, serial_number: str) -> str:
|
|
107
119
|
"""Helper method to convert device model and serial to identifier
|
|
@@ -595,6 +607,8 @@ class SystemUpdate(UpdateBaseModel):
|
|
|
595
607
|
cloud_enabled: bool | None = field(default=None)
|
|
596
608
|
status_led_brightness_pct: int | None = field(default=None)
|
|
597
609
|
api_v1_enabled: bool | None = field(default=None)
|
|
610
|
+
power_on: bool | None = field(default=None)
|
|
611
|
+
switch_lock: bool | None = field(default=None)
|
|
598
612
|
|
|
599
613
|
|
|
600
614
|
@dataclass(kw_only=True)
|
|
@@ -609,6 +623,8 @@ class System(BaseModel):
|
|
|
609
623
|
uptime_s: int | None = field(default=None)
|
|
610
624
|
status_led_brightness_pct: int | None = field(default=None)
|
|
611
625
|
api_v1_enabled: bool | None = field(default=None)
|
|
626
|
+
power_on: bool | None = field(default=None)
|
|
627
|
+
switch_lock: bool | None = field(default=None)
|
|
612
628
|
|
|
613
629
|
@classmethod
|
|
614
630
|
def __post_deserialize__(cls, obj: System) -> System:
|
{python_homewizard_energy-10.2.0 → python_homewizard_energy-10.3.0}/homewizard_energy/v1/__init__.py
RENAMED
|
@@ -68,11 +68,14 @@ class HomeWizardEnergyV1(HomeWizardEnergy):
|
|
|
68
68
|
return telegram
|
|
69
69
|
|
|
70
70
|
@optional_method
|
|
71
|
+
# pylint: disable-next=too-many-arguments,too-many-positional-arguments
|
|
71
72
|
async def system(
|
|
72
73
|
self,
|
|
73
74
|
cloud_enabled: bool | None = None,
|
|
74
75
|
status_led_brightness_pct: int | None = None,
|
|
75
76
|
api_v1_enabled: bool | None = None,
|
|
77
|
+
power_on: bool | None = None,
|
|
78
|
+
switch_lock: bool | None = None,
|
|
76
79
|
) -> System:
|
|
77
80
|
"""Return the system object."""
|
|
78
81
|
|
|
@@ -80,10 +83,29 @@ class HomeWizardEnergyV1(HomeWizardEnergy):
|
|
|
80
83
|
if api_v1_enabled is not None:
|
|
81
84
|
raise UnsupportedError("Setting api_v1_enabled is not supported in v1")
|
|
82
85
|
|
|
83
|
-
# Legacy: route 'status_led_brightness_pct'
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
86
|
+
# Legacy: route 'status_led_brightness_pct', 'power_on' and 'switch_lock'
|
|
87
|
+
# to state, as v1 exposes these via the state endpoint
|
|
88
|
+
if (
|
|
89
|
+
status_led_brightness_pct is not None
|
|
90
|
+
or power_on is not None
|
|
91
|
+
or switch_lock is not None
|
|
92
|
+
):
|
|
93
|
+
state = await self.state(
|
|
94
|
+
power_on=power_on,
|
|
95
|
+
switch_lock=switch_lock,
|
|
96
|
+
brightness=(
|
|
97
|
+
status_led_brightness_pct * 2.55
|
|
98
|
+
if status_led_brightness_pct is not None
|
|
99
|
+
else None
|
|
100
|
+
),
|
|
101
|
+
)
|
|
102
|
+
return System(
|
|
103
|
+
status_led_brightness_pct=(
|
|
104
|
+
state.brightness / 2.55 if state.brightness is not None else None
|
|
105
|
+
),
|
|
106
|
+
power_on=state.power_on,
|
|
107
|
+
switch_lock=state.switch_lock,
|
|
108
|
+
)
|
|
87
109
|
|
|
88
110
|
if cloud_enabled is not None:
|
|
89
111
|
# Executing the update
|
{python_homewizard_energy-10.2.0 → python_homewizard_energy-10.3.0}/homewizard_energy/v2/__init__.py
RENAMED
|
@@ -119,18 +119,31 @@ class HomeWizardEnergyV2(HomeWizardEnergy):
|
|
|
119
119
|
cloud_enabled: bool | None = None,
|
|
120
120
|
status_led_brightness_pct: int | None = None,
|
|
121
121
|
api_v1_enabled: bool | None = None,
|
|
122
|
+
power_on: bool | None = None,
|
|
123
|
+
switch_lock: bool | None = None,
|
|
122
124
|
) -> System:
|
|
123
125
|
"""Return the system object."""
|
|
124
126
|
|
|
127
|
+
if (
|
|
128
|
+
(power_on is not None or switch_lock is not None)
|
|
129
|
+
and self._device is not None
|
|
130
|
+
and self._device.supports_state() is False
|
|
131
|
+
):
|
|
132
|
+
raise UnsupportedError("Setting power_on or switch_lock is not supported")
|
|
133
|
+
|
|
125
134
|
if (
|
|
126
135
|
cloud_enabled is not None
|
|
127
136
|
or status_led_brightness_pct is not None
|
|
128
137
|
or api_v1_enabled is not None
|
|
138
|
+
or power_on is not None
|
|
139
|
+
or switch_lock is not None
|
|
129
140
|
):
|
|
130
141
|
data = SystemUpdate(
|
|
131
142
|
cloud_enabled=cloud_enabled,
|
|
132
143
|
status_led_brightness_pct=status_led_brightness_pct,
|
|
133
144
|
api_v1_enabled=api_v1_enabled,
|
|
145
|
+
power_on=power_on,
|
|
146
|
+
switch_lock=switch_lock,
|
|
134
147
|
).to_dict()
|
|
135
148
|
status, response = await self._request(
|
|
136
149
|
"/api/system", method=METH_PUT, data=data
|
|
File without changes
|
{python_homewizard_energy-10.2.0 → python_homewizard_energy-10.3.0}/homewizard_energy/__init__.py
RENAMED
|
File without changes
|
{python_homewizard_energy-10.2.0 → python_homewizard_energy-10.3.0}/homewizard_energy/const.py
RENAMED
|
File without changes
|
{python_homewizard_energy-10.2.0 → python_homewizard_energy-10.3.0}/homewizard_energy/errors.py
RENAMED
|
File without changes
|
{python_homewizard_energy-10.2.0 → python_homewizard_energy-10.3.0}/homewizard_energy/py.typed
RENAMED
|
File without changes
|
{python_homewizard_energy-10.2.0 → python_homewizard_energy-10.3.0}/homewizard_energy/utils.py
RENAMED
|
File without changes
|
{python_homewizard_energy-10.2.0 → python_homewizard_energy-10.3.0}/homewizard_energy/v1/const.py
RENAMED
|
File without changes
|
{python_homewizard_energy-10.2.0 → python_homewizard_energy-10.3.0}/homewizard_energy/v2/cacert.py
RENAMED
|
File without changes
|
{python_homewizard_energy-10.2.0 → python_homewizard_energy-10.3.0}/homewizard_energy/v2/const.py
RENAMED
|
File without changes
|