pyvesync 3.0.0__py3-none-any.whl

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 (50) hide show
  1. pyvesync/__init__.py +5 -0
  2. pyvesync/base_devices/__init__.py +35 -0
  3. pyvesync/base_devices/bulb_base.py +330 -0
  4. pyvesync/base_devices/fan_base.py +392 -0
  5. pyvesync/base_devices/fryer_base.py +68 -0
  6. pyvesync/base_devices/humidifier_base.py +462 -0
  7. pyvesync/base_devices/outlet_base.py +327 -0
  8. pyvesync/base_devices/purifier_base.py +525 -0
  9. pyvesync/base_devices/switch_base.py +271 -0
  10. pyvesync/base_devices/thermostat_base.py +283 -0
  11. pyvesync/base_devices/vesyncbasedevice.py +572 -0
  12. pyvesync/const.py +825 -0
  13. pyvesync/device_container.py +373 -0
  14. pyvesync/device_map.py +1172 -0
  15. pyvesync/devices/__init__.py +1 -0
  16. pyvesync/devices/vesyncbulb.py +1126 -0
  17. pyvesync/devices/vesyncfan.py +233 -0
  18. pyvesync/devices/vesynchumidifier.py +808 -0
  19. pyvesync/devices/vesynckitchen.py +651 -0
  20. pyvesync/devices/vesyncoutlet.py +954 -0
  21. pyvesync/devices/vesyncpurifier.py +990 -0
  22. pyvesync/devices/vesyncswitch.py +415 -0
  23. pyvesync/devices/vesyncthermostat.py +171 -0
  24. pyvesync/models/__init__.py +11 -0
  25. pyvesync/models/base_models.py +129 -0
  26. pyvesync/models/bulb_models.py +197 -0
  27. pyvesync/models/bypass_models.py +289 -0
  28. pyvesync/models/fan_models.py +47 -0
  29. pyvesync/models/fryer_models.py +34 -0
  30. pyvesync/models/home_models.py +169 -0
  31. pyvesync/models/humidifier_models.py +202 -0
  32. pyvesync/models/outlet_models.py +220 -0
  33. pyvesync/models/purifier_models.py +261 -0
  34. pyvesync/models/switch_models.py +101 -0
  35. pyvesync/models/thermostat_models.py +134 -0
  36. pyvesync/models/vesync_models.py +439 -0
  37. pyvesync/utils/__init__.py +1 -0
  38. pyvesync/utils/colors.py +250 -0
  39. pyvesync/utils/device_mixins.py +362 -0
  40. pyvesync/utils/enum_utils.py +26 -0
  41. pyvesync/utils/errors.py +867 -0
  42. pyvesync/utils/helpers.py +700 -0
  43. pyvesync/utils/logs.py +525 -0
  44. pyvesync/vesync.py +638 -0
  45. pyvesync/vesynchome.py +152 -0
  46. pyvesync-3.0.0.dist-info/METADATA +567 -0
  47. pyvesync-3.0.0.dist-info/RECORD +50 -0
  48. pyvesync-3.0.0.dist-info/WHEEL +5 -0
  49. pyvesync-3.0.0.dist-info/licenses/LICENSE +21 -0
  50. pyvesync-3.0.0.dist-info/top_level.txt +1 -0
@@ -0,0 +1,392 @@
1
+ """Fan Devices Base Class (NOT purifiers or humidifiers)."""
2
+
3
+ from __future__ import annotations
4
+
5
+ import logging
6
+ from abc import abstractmethod
7
+ from typing import TYPE_CHECKING
8
+
9
+ from typing_extensions import deprecated
10
+
11
+ from pyvesync.base_devices.vesyncbasedevice import DeviceState, VeSyncBaseToggleDevice
12
+ from pyvesync.const import FanFeatures, FanModes
13
+
14
+ if TYPE_CHECKING:
15
+ from pyvesync import VeSync
16
+ from pyvesync.device_map import FanMap
17
+ from pyvesync.models.vesync_models import ResponseDeviceDetailsModel
18
+
19
+
20
+ logger = logging.getLogger(__name__)
21
+
22
+
23
+ class FanState(DeviceState):
24
+ """Base state class for Purifiers.
25
+
26
+ Not all attributes are supported by all devices.
27
+
28
+
29
+ Attributes:
30
+ display_set_status (str): Display set status.
31
+ display_status (str): Display status.
32
+ displaying_type (str): Displaying type.
33
+ fan_level (int): Fan level.
34
+ fan_set_level (int): Fan set level.
35
+ humidity (int): Humidity level.
36
+ mode (str): Mode of device.
37
+ mute_set_status (str): Mute set status.
38
+ mute_status (str): Mute status.
39
+ oscillation_set_status (str): Oscillation set status.
40
+ oscillation_status (str): Oscillation status.
41
+ sleep_change_fan_level (str): Sleep change fan level.
42
+ sleep_fallasleep_remain (str): Sleep fall asleep remain.
43
+ sleep_oscillation_switch (str): Sleep oscillation switch.
44
+ sleep_preference_type (str): Sleep preference type.
45
+ temperature (int): Temperature.
46
+ thermal_comfort (int): Thermal comfort.
47
+ timer (Timer): Timer object.
48
+ """
49
+
50
+ __slots__ = (
51
+ 'display_set_status',
52
+ 'display_status',
53
+ 'displaying_type',
54
+ 'fan_level',
55
+ 'fan_set_level',
56
+ 'humidity',
57
+ 'mode',
58
+ 'mute_set_status',
59
+ 'mute_status',
60
+ 'oscillation_set_status',
61
+ 'oscillation_status',
62
+ 'sleep_change_fan_level',
63
+ 'sleep_fallasleep_remain',
64
+ 'sleep_oscillation_switch',
65
+ 'sleep_preference_type',
66
+ 'temperature',
67
+ 'thermal_comfort',
68
+ )
69
+
70
+ def __init__(
71
+ self,
72
+ device: VeSyncFanBase,
73
+ details: ResponseDeviceDetailsModel,
74
+ feature_map: FanMap,
75
+ ) -> None:
76
+ """Initialize Purifier State.
77
+
78
+ Args:
79
+ device (VeSyncFanBase): Device object.
80
+ details (ResponseDeviceDetailsModel): Device details.
81
+ feature_map (FanMap): Feature map.
82
+ """
83
+ super().__init__(device, details, feature_map)
84
+ self.mode: str = FanModes.UNKNOWN
85
+ self.fan_level: int | None = None
86
+ self.fan_set_level: int | None = None
87
+ self.humidity: int | None = None
88
+ self.temperature: int | None = None
89
+ self.thermal_comfort: int | None = None
90
+ self.sleep_preference_type: str | None = None
91
+ self.sleep_fallasleep_remain: str | None = None
92
+ self.sleep_oscillation_switch: str | None = None
93
+ self.sleep_change_fan_level: str | None = None
94
+ self.mute_status: str | None = None
95
+ self.mute_set_status: str | None = None
96
+ self.oscillation_status: str | None = None
97
+ self.oscillation_set_status: str | None = None
98
+ self.display_status: str | None = None
99
+ self.display_set_status: str | None = None
100
+ self.displaying_type: str | None = None
101
+
102
+
103
+ class VeSyncFanBase(VeSyncBaseToggleDevice):
104
+ """Base device for VeSync tower fans.
105
+
106
+ Inherits from
107
+ [VeSyncBaseToggleDevice][pyvesync.base_devices.vesyncbasedevice.VeSyncBaseToggleDevice]
108
+ and [VeSyncBaseDevice][pyvesync.base_devices.vesyncbasedevice.VeSyncBaseDevice].
109
+
110
+ Attributes:
111
+ fan_levels (list[int]): Fan levels supported by device.
112
+ modes (list[str]): Modes supported by device.
113
+ sleep_preferences (list[str]): Sleep preferences supported by device.
114
+ """
115
+
116
+ __slots__ = (
117
+ 'fan_levels',
118
+ 'modes',
119
+ 'sleep_preferences',
120
+ )
121
+
122
+ def __init__(
123
+ self,
124
+ details: ResponseDeviceDetailsModel,
125
+ manager: VeSync,
126
+ feature_map: FanMap,
127
+ ) -> None:
128
+ """Initialize VeSync Tower Fan Base Class.
129
+
130
+ Args:
131
+ details (ResponseDeviceDetailsModel): Device details.
132
+ manager (VeSync): Manager.
133
+ feature_map (FanMap): Feature map.
134
+
135
+ See Also:
136
+ See [device_map][pyvesync.device_map] for configured features and modes.
137
+ """
138
+ super().__init__(details, manager, feature_map)
139
+ self.features: list[str] = feature_map.features
140
+ self.state: FanState = FanState(self, details, feature_map)
141
+ self.modes: list[str] = feature_map.modes
142
+ self.fan_levels: list[int] = feature_map.fan_levels
143
+ self.sleep_preferences: list[str] = feature_map.sleep_preferences
144
+
145
+ @property
146
+ def supports_oscillation(self) -> bool:
147
+ """Return True if device supports oscillation."""
148
+ return FanFeatures.OSCILLATION in self.features
149
+
150
+ @property
151
+ def supports_mute(self) -> bool:
152
+ """Return True if device supports mute."""
153
+ return FanFeatures.SOUND in self.features
154
+
155
+ @property
156
+ def supports_displaying_type(self) -> bool:
157
+ """Return True if device supports displaying type."""
158
+ return FanFeatures.DISPLAYING_TYPE in self.features
159
+
160
+ async def toggle_display(self, toggle: bool) -> bool:
161
+ """Toggle Display on/off.
162
+
163
+ Args:
164
+ toggle (bool): Display state.
165
+
166
+ Returns:
167
+ bool: Success of request.
168
+ """
169
+ del toggle
170
+ return False
171
+
172
+ async def turn_on_display(self) -> bool:
173
+ """Turn on Display.
174
+
175
+ Returns:
176
+ bool: Success of request
177
+ """
178
+ return await self.toggle_display(True)
179
+
180
+ async def turn_off_display(self) -> bool:
181
+ """Turn off Display.
182
+
183
+ Returns:
184
+ bool: Success of request
185
+ """
186
+ return await self.toggle_display(False)
187
+
188
+ @abstractmethod
189
+ async def set_mode(self, mode: str) -> bool:
190
+ """Set Purifier Mode.
191
+
192
+ Args:
193
+ mode (str): Mode to set, varies by device type.
194
+
195
+ Returns:
196
+ bool: Success of request.
197
+ """
198
+
199
+ @abstractmethod
200
+ async def set_fan_speed(self, speed: int | None = None) -> bool:
201
+ """Set Purifier Fan Speed.
202
+
203
+ Args:
204
+ speed (int, optional): Fan speed level according to device specs.
205
+
206
+ Returns:
207
+ bool: Success of request.
208
+ """
209
+
210
+ async def set_auto_mode(self) -> bool:
211
+ """Set Purifier to Auto Mode.
212
+
213
+ Returns:
214
+ bool: Success of request.
215
+
216
+ Note:
217
+ This method is not supported by all devices, will return
218
+ false with warning debug message if not supported.
219
+ """
220
+ if FanModes.AUTO in self.modes:
221
+ return await self.set_mode(FanModes.AUTO)
222
+ logger.warning('Auto mode not supported for this device.')
223
+ return False
224
+
225
+ async def set_advanced_sleep_mode(self) -> bool:
226
+ """Set Purifier to Advanced Sleep Mode.
227
+
228
+ Returns:
229
+ bool: Success of request.
230
+
231
+ Note:
232
+ This method is not supported by all devices, will return
233
+ false with warning debug message if not supported.
234
+ """
235
+ if FanModes.ADVANCED_SLEEP in self.modes:
236
+ return await self.set_mode(FanModes.ADVANCED_SLEEP)
237
+ logger.warning('Advanced Sleep mode not supported for this device.')
238
+ return False
239
+
240
+ async def set_sleep_mode(self) -> bool:
241
+ """Set Purifier to Sleep Mode.
242
+
243
+ This is also referred to as Advanced Sleep Mode on some devices.
244
+
245
+ Returns:
246
+ bool: Success of request.
247
+
248
+ Note:
249
+ This method is not supported by all devices, will return
250
+ false with warning debug message if not supported.
251
+ """
252
+ if FanModes.ADVANCED_SLEEP in self.modes:
253
+ return await self.set_mode(FanModes.ADVANCED_SLEEP)
254
+ logger.warning('Sleep mode not supported for this device.')
255
+ return False
256
+
257
+ async def set_manual_mode(self) -> bool:
258
+ """Set Purifier to Manual Mode - Normal Mode.
259
+
260
+ Returns:
261
+ bool: Success of request.
262
+
263
+ Note:
264
+ This method is not supported by all devices, will return
265
+ false with warning debug message if not supported.
266
+ """
267
+ if FanModes.NORMAL in self.modes:
268
+ return await self.set_mode(FanModes.NORMAL)
269
+ logger.warning('Manual mode not supported for this device.')
270
+ return False
271
+
272
+ async def set_normal_mode(self) -> bool:
273
+ """Set Purifier to Normal Mode.
274
+
275
+ Returns:
276
+ bool: Success of request.
277
+
278
+ Note:
279
+ This method is not supported by all devices, will return
280
+ false with warning debug message if not supported.
281
+ """
282
+ if FanModes.NORMAL in self.modes:
283
+ return await self.set_mode(FanModes.NORMAL)
284
+ logger.warning('Normal mode not supported for this device.')
285
+ return False
286
+
287
+ async def set_turbo_mode(self) -> bool:
288
+ """Set Purifier to Turbo Mode.
289
+
290
+ Returns:
291
+ bool: Success of request.
292
+
293
+ Note:
294
+ This method is not supported by all devices, will return
295
+ false with warning debug message if not supported.
296
+ """
297
+ if FanModes.TURBO in self.modes:
298
+ return await self.set_mode(FanModes.TURBO)
299
+ logger.warning('Turbo mode not supported for this device.')
300
+ return False
301
+
302
+ async def toggle_oscillation(self, toggle: bool) -> bool:
303
+ """Toggle Oscillation on/off.
304
+
305
+ Args:
306
+ toggle (bool): Oscillation state.
307
+
308
+ Returns:
309
+ bool: true if success.
310
+ """
311
+ del toggle
312
+ if self.supports_oscillation:
313
+ logger.debug('Oscillation not configured for this device.')
314
+ else:
315
+ logger.debug('Oscillation not supported for this device.')
316
+ return False
317
+
318
+ async def turn_on_oscillation(self) -> bool:
319
+ """Set toggle_oscillation to on."""
320
+ return await self.toggle_oscillation(True)
321
+
322
+ async def turn_off_oscillation(self) -> bool:
323
+ """Set toggle_oscillation to off."""
324
+ return await self.toggle_oscillation(False)
325
+
326
+ async def toggle_mute(self, toggle: bool) -> bool:
327
+ """Toggle mute on/off.
328
+
329
+ Parameters:
330
+ toggle : bool
331
+ True to turn mute on, False to turn off
332
+
333
+ Returns:
334
+ bool : True if successful, False if not
335
+ """
336
+ del toggle
337
+ if self.supports_mute:
338
+ logger.debug('Mute not configured for this device.')
339
+ else:
340
+ logger.debug('Mute not supported for this device.')
341
+ return False
342
+
343
+ async def turn_on_mute(self) -> bool:
344
+ """Set toggle_mute to on."""
345
+ return await self.toggle_mute(True)
346
+
347
+ async def turn_off_mute(self) -> bool:
348
+ """Set toggle_mute to off."""
349
+ return await self.toggle_mute(False)
350
+
351
+ async def toggle_displaying_type(self, toggle: bool) -> bool:
352
+ """Toggle displaying type on/off.
353
+
354
+ This functionality is unknown but was in the API calls.
355
+
356
+ Args:
357
+ toggle (bool): Displaying type state.
358
+
359
+ Returns:
360
+ bool: true if success.
361
+ """
362
+ del toggle
363
+ if self.supports_displaying_type:
364
+ logger.debug('Displaying type not configured for this device.')
365
+ else:
366
+ logger.debug('Displaying type not supported for this device.')
367
+ return False
368
+
369
+ @deprecated('Use `set_normal_mode` method instead')
370
+ async def normal_mode(self) -> bool:
371
+ """Set mode to normal."""
372
+ return await self.set_normal_mode()
373
+
374
+ @deprecated('Use `set_manual_mode` method instead')
375
+ async def manual_mode(self) -> bool:
376
+ """Adapter to set mode to normal."""
377
+ return await self.set_normal_mode()
378
+
379
+ @deprecated('Use `set_advanced_sleep_mode` method instead')
380
+ async def advanced_sleep_mode(self) -> bool:
381
+ """Set advanced sleep mode."""
382
+ return await self.set_mode('advancedSleep')
383
+
384
+ @deprecated('Use `set_sleep_mode` method instead')
385
+ async def sleep_mode(self) -> bool:
386
+ """Adapter to set advanced sleep mode."""
387
+ return await self.set_advanced_sleep_mode()
388
+
389
+ @deprecated('Use `set_mode` method instead')
390
+ async def mode_toggle(self, mode: str) -> bool:
391
+ """Set mode to specified mode."""
392
+ return await self.set_mode(mode)
@@ -0,0 +1,68 @@
1
+ """Air Purifier Base Class."""
2
+
3
+ from __future__ import annotations
4
+
5
+ import logging
6
+ from typing import TYPE_CHECKING
7
+
8
+ from pyvesync.base_devices.vesyncbasedevice import DeviceState, VeSyncBaseDevice
9
+
10
+ if TYPE_CHECKING:
11
+ from pyvesync import VeSync
12
+ from pyvesync.device_map import AirFryerMap
13
+ from pyvesync.models.vesync_models import ResponseDeviceDetailsModel
14
+
15
+
16
+ logger = logging.getLogger(__name__)
17
+
18
+
19
+ class FryerState(DeviceState):
20
+ """State class for Air Fryer devices.
21
+
22
+ Note: This class is a placeholder for future functionality and does not currently
23
+ implement any specific features or attributes.
24
+ """
25
+
26
+ __slots__ = ()
27
+
28
+ def __init__(
29
+ self,
30
+ device: VeSyncFryer,
31
+ details: ResponseDeviceDetailsModel,
32
+ feature_map: AirFryerMap,
33
+ ) -> None:
34
+ """Initialize FryerState.
35
+
36
+ Args:
37
+ device (VeSyncFryer): The device object.
38
+ details (ResponseDeviceDetailsModel): The device details.
39
+ feature_map (AirFryerMap): The feature map for the device.
40
+
41
+ """
42
+ super().__init__(device, details, feature_map)
43
+ self.device: VeSyncFryer = device
44
+ self.features: list[str] = feature_map.features
45
+
46
+
47
+ class VeSyncFryer(VeSyncBaseDevice):
48
+ """Base class for VeSync Air Fryer devices."""
49
+
50
+ __slots__ = ()
51
+
52
+ def __init__(
53
+ self,
54
+ details: ResponseDeviceDetailsModel,
55
+ manager: VeSync,
56
+ feature_map: AirFryerMap,
57
+ ) -> None:
58
+ """Initialize VeSyncFryer.
59
+
60
+ Args:
61
+ details (ResponseDeviceDetailsModel): The device details.
62
+ manager (VeSync): The VeSync manager.
63
+ feature_map (AirFryerMap): The feature map for the device.
64
+
65
+ Note:
66
+ This is a bare class as there is only one supported air fryer model.
67
+ """
68
+ super().__init__(details, manager, feature_map)