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,169 @@
1
+ """Home and Rooms request and response models.
2
+
3
+ WORK IN PROGRESS - NOT IMPLEMENTED YET
4
+
5
+ Dataclasses should follow the naming convention of Request/Response + <API Name> + Model.
6
+ Internal models should be named starting with IntResp/IntReq<API Name>Model.
7
+
8
+ Attributes:
9
+ ResponseLoginResultModel: Model for the 'result' field in login response.
10
+ ResponseLoginModel: Model for the login response.
11
+ RequestLoginModel: Model for the login request.
12
+
13
+ Notes:
14
+ All models should inherit `ResponseBaseModel` or `RequestBaseModel`. Use
15
+ `pyvesync.models.base_models.DefaultValues` to set default values.
16
+
17
+ """
18
+
19
+ from __future__ import annotations
20
+
21
+ from dataclasses import dataclass, field
22
+
23
+ from pyvesync.models.base_models import (
24
+ DefaultValues,
25
+ RequestBaseModel,
26
+ ResponseCodeModel,
27
+ )
28
+
29
+
30
+ @dataclass
31
+ class RequestHomeModel(RequestBaseModel):
32
+ """Request model for home data.
33
+
34
+ Inherits from `RequestVeSyncInstanceMixin` to populate fields from the
35
+ VeSync instance. The `VeSync` instance is passed as a
36
+ keyword argument `RequestHomeModel(manager=instance)`.
37
+ """
38
+
39
+ # Arguments set by Manager Instance by passing kw_argument manager
40
+ # these fields should be set to init=False
41
+ accountID: str
42
+ token: str
43
+ userCountryCode: str
44
+ # Non-default constants
45
+ method: str = 'getHomeList'
46
+ # default values
47
+ acceptLanguage: str = DefaultValues.acceptLanguage
48
+ appVersion: str = DefaultValues.appVersion
49
+ timeZone: str = DefaultValues.timeZone
50
+ phoneBrand: str = DefaultValues.phoneBrand
51
+ phoneOS: str = DefaultValues.phoneOS
52
+ traceId: str = field(default_factory=DefaultValues.traceId)
53
+ debugMode: bool = DefaultValues.debugMode
54
+
55
+
56
+ @dataclass
57
+ class ResponseHomeModel(ResponseCodeModel):
58
+ """Model for the home data response.
59
+
60
+ Inherits from `ResponseCodeModel`. The `ResponseCodeModel` class provides the
61
+ `code` and `msg` fields. The `ResponseHomeModel` class provides the `result`
62
+ field containing the home data.
63
+
64
+ Attributes:
65
+ result: dict: The home data.
66
+ """
67
+
68
+ result: IntResponseHomeResultModel | IntResponseHomeInfoResultModel | None
69
+
70
+
71
+ @dataclass
72
+ class RequestHomeInfoModel(RequestBaseModel):
73
+ """Request model for home room information.
74
+
75
+ Inherits from `RequestVeSyncInstanceMixin` to populate fields from the
76
+ VeSync instance. The `VeSync` instance is passed as a
77
+ keyword argument `RequestHomeModel(manager=instance)`.
78
+ """
79
+
80
+ # argument to pass in as positional or keyword argument homeId
81
+ homeId: str
82
+ # Arguments set by Manager Instance by passing kw_argument manager
83
+ # these fields should be set to init=False
84
+ accountID: str = field(init=False)
85
+ token: str = field(init=False)
86
+ userCountryCode: str = field(init=False)
87
+ # Non-default constants
88
+ method: str = 'getHomeDetail'
89
+ # default values
90
+ acceptLanguage: str = DefaultValues.acceptLanguage
91
+ appVersion: str = DefaultValues.appVersion
92
+ timeZone: str = DefaultValues.timeZone
93
+ phoneBrand: str = DefaultValues.phoneBrand
94
+ phoneOS: str = DefaultValues.phoneOS
95
+ traceId: str = field(default_factory=DefaultValues.traceId)
96
+ debugMode: bool = DefaultValues.debugMode
97
+
98
+
99
+ @dataclass
100
+ class ResponseHomeInfoModel(ResponseCodeModel):
101
+ """Model for the home room information response.
102
+
103
+ Inherits from `ResponseCodeModel`. The `ResponseCodeModel` class provides the
104
+ `traceId`, `code`, and `msg` fields. The `ResponseHomeInfoModel` class provides
105
+ the `result` field containing the home room data.
106
+
107
+ Attributes:
108
+ result: dict: The home room data.
109
+ """
110
+
111
+ result: IntResponseHomeInfoResultModel
112
+
113
+
114
+ @dataclass
115
+ class IntResponseHomeInfoResultModel:
116
+ """Internal model for the 'result' field in home room response."""
117
+
118
+ roomInfoList: list[IntResponseHomeListModel]
119
+
120
+
121
+ @dataclass
122
+ class IntResponseRoomListModel:
123
+ """Internal model for the 'roomList' field in home response."""
124
+
125
+ roomID: str
126
+ roomName: str
127
+ deviceList: list[IntResponseRoomDeviceListModel]
128
+ plantComformHumidityRangeLower: int | None = None
129
+ plantComformHumidityRangeHigher: int | None = None
130
+ # group_list = [] # TODO: Create group model # noqa: ERA001
131
+
132
+
133
+ @dataclass
134
+ class IntResponseRoomDeviceListModel:
135
+ """Internal model for the device list in room response."""
136
+
137
+ logicalDeviceType: int
138
+ virDeviceType: int
139
+ cid: str
140
+ uuid: str
141
+ subDeviceNo: int
142
+ deviceName: str
143
+ configModule: str
144
+ deviceRegion: str
145
+ deviceType: str
146
+ type: str
147
+ connectionType: str
148
+ currentFirmwareVersion: str
149
+ deviceStatus: str
150
+ connectionStatus: str
151
+ mode: str | None = None
152
+ subDeviceType: str | None = None
153
+ macid: str | None = None
154
+
155
+
156
+ @dataclass
157
+ class IntResponseHomeResultModel:
158
+ """Internal model for the 'result' field in home response."""
159
+
160
+ homeList: list[IntResponseHomeListModel]
161
+
162
+
163
+ @dataclass
164
+ class IntResponseHomeListModel:
165
+ """Internal model for the 'homeList' field in home response result."""
166
+
167
+ homeId: int
168
+ homeName: str
169
+ nickname: str | None = None
@@ -0,0 +1,202 @@
1
+ """Data models for VeSync Humidifier devices.
2
+
3
+ These models inherit from `ResponseBaseModel` and `RequestBaseModel` from the
4
+ `base_models` module.
5
+
6
+ The `InnerHumidifierBaseResult` class is used as a base class for the inner humidifier
7
+ result models. The correct subclass is determined by the mashumaro discriminator.
8
+ """
9
+
10
+ from __future__ import annotations
11
+
12
+ from dataclasses import dataclass
13
+ from typing import Annotated
14
+
15
+ from mashumaro.config import BaseConfig
16
+ from mashumaro.types import Alias
17
+
18
+ from pyvesync.models.base_models import (
19
+ ResponseBaseModel,
20
+ ResponseCodeModel,
21
+ )
22
+
23
+
24
+ @dataclass
25
+ class ResponseHumidifierBase(ResponseCodeModel):
26
+ """Humidifier Base Response Dict."""
27
+
28
+ result: OuterHumidifierResult
29
+
30
+
31
+ @dataclass
32
+ class OuterHumidifierResult(ResponseBaseModel):
33
+ """Humidifier Result Dict."""
34
+
35
+ code: int
36
+ result: InnerHumidifierBaseResult
37
+
38
+
39
+ @dataclass
40
+ class InnerHumidifierBaseResult(ResponseBaseModel):
41
+ """Base class for inner humidifier results model.
42
+
43
+ All inner results models inherit from this class and are
44
+ correctly subclassed by the mashumaro discriminator.
45
+ """
46
+
47
+ class Config(BaseConfig): # type: ignore[override]
48
+ """Configure the results model to use subclass discriminator."""
49
+
50
+ allow_deserialization_not_by_alias = True
51
+
52
+
53
+ class BypassV2InnerErrorResult(InnerHumidifierBaseResult):
54
+ """Inner Error Result Model."""
55
+
56
+ msg: str
57
+
58
+
59
+ # Inner Result models for individual devices inherit from InnerHumidifierBaseResult
60
+ # and are used to parse the response from the API.
61
+ # The correct subclass is determined by the mashumaro discriminator
62
+
63
+
64
+ @dataclass
65
+ class ClassicLVHumidResult(InnerHumidifierBaseResult):
66
+ """Classic 200S Humidifier Result Model.
67
+
68
+ Inherits from InnerHumidifierBaseResult.
69
+ """
70
+
71
+ enabled: bool
72
+ mist_virtual_level: int
73
+ mist_level: int
74
+ mode: str
75
+ display: Annotated[bool, Alias('indicator_light_status')]
76
+ water_lacks: bool
77
+ humidity: int | None = None
78
+ humidity_high: bool = False
79
+ automatic_stop_reach_target: bool = False
80
+ water_tank_lifted: bool = False
81
+ warm_enabled: bool = False
82
+ warm_level: int | None = None
83
+ night_light_brightness: int | None = None
84
+ configuration: ClassicConfig | None = None
85
+
86
+
87
+ @dataclass
88
+ class ClassicConfig(ResponseBaseModel):
89
+ """Classic 200S Humidifier Configuration Model."""
90
+
91
+ auto_target_humidity: int = 0
92
+ display: Annotated[bool, Alias('indicator_light_status')] = False
93
+ automatic_stop: bool = False
94
+
95
+ class Config(BaseConfig): # type: ignore[override]
96
+ """Configure the results model to use subclass discriminator."""
97
+
98
+ allow_deserialization_not_by_alias = True
99
+ forbid_extra_keys = False
100
+
101
+
102
+ @dataclass
103
+ class LV600SConfig(ResponseBaseModel):
104
+ """LV 600S Humidifier Configuration Model."""
105
+
106
+ auto_target_humidity: int = 0
107
+ display: bool = False
108
+
109
+
110
+ @dataclass
111
+ class LV600SExtension(ResponseBaseModel):
112
+ """LV 600S Humidifier Configuration Model."""
113
+
114
+ timer_remain: int = 0
115
+ schedule_count: int = 0
116
+
117
+
118
+ @dataclass
119
+ class LV600SHumidResult(InnerHumidifierBaseResult):
120
+ """LV600S Humidifier Result Model.
121
+
122
+ Inherits from InnerHumidifierBaseResult.
123
+ """
124
+
125
+ automatic_stop_reach_target: bool
126
+ display: bool
127
+ enabled: bool
128
+ humidity: int
129
+ humidity_high: bool
130
+ mist_level: int
131
+ mist_virtual_level: int
132
+ mode: str
133
+ water_lacks: bool
134
+ water_tank_lifted: bool
135
+ extension: LV600SExtension | None = None
136
+ configuration: LV600SConfig | None = None
137
+
138
+
139
+ # Models for the VeSync Superior 6000S Humidifier
140
+
141
+
142
+ @dataclass
143
+ class Superior6000SResult(InnerHumidifierBaseResult):
144
+ """Superior 6000S Humidifier Result Model.
145
+
146
+ Inherits from InnerHumidifierBaseResult.
147
+ """
148
+
149
+ powerSwitch: int
150
+ humidity: int
151
+ targetHumidity: int
152
+ virtualLevel: int
153
+ mistLevel: int
154
+ workMode: str
155
+ waterLacksState: int
156
+ waterTankLifted: int
157
+ autoStopSwitch: int
158
+ autoStopState: int
159
+ screenSwitch: int
160
+ screenState: int
161
+ scheduleCount: int
162
+ timerRemain: int
163
+ errorCode: int
164
+ autoPreference: int
165
+ childLockSwitch: int
166
+ filterLifePercent: int
167
+ temperature: int
168
+ dryingMode: Superior6000SDryingMode | None = None
169
+
170
+
171
+ @dataclass
172
+ class Superior6000SDryingMode(ResponseBaseModel):
173
+ """Drying Mode Model for Superior 6000S Humidifier."""
174
+
175
+ dryingLevel: int
176
+ autoDryingSwitch: int
177
+ dryingState: int
178
+ dryingRemain: int
179
+
180
+
181
+ # Models for the Levoit 1000S Humidifier
182
+
183
+
184
+ @dataclass
185
+ class Levoit1000SResult(InnerHumidifierBaseResult):
186
+ """Levoit 1000S Humidifier Result Model."""
187
+
188
+ powerSwitch: int
189
+ humidity: int
190
+ targetHumidity: int
191
+ virtualLevel: int
192
+ mistLevel: int
193
+ workMode: str
194
+ waterLacksState: int
195
+ waterTankLifted: int
196
+ autoStopSwitch: int
197
+ autoStopState: int
198
+ screenSwitch: int
199
+ screenState: int
200
+ scheduleCount: int
201
+ timerRemain: int
202
+ errorCode: int
@@ -0,0 +1,220 @@
1
+ """Data models for VeSync outlets."""
2
+
3
+ from __future__ import annotations
4
+
5
+ from dataclasses import dataclass
6
+
7
+ from mashumaro.mixins.orjson import DataClassORJSONMixin
8
+
9
+ from pyvesync.models.base_models import (
10
+ RequestBaseModel,
11
+ ResponseBaseModel,
12
+ ResponseCodeModel,
13
+ )
14
+ from pyvesync.models.bypass_models import (
15
+ RequestBypassV1,
16
+ )
17
+
18
+
19
+ @dataclass
20
+ class Response7AOutlet(ResponseBaseModel):
21
+ """Response model for 7A outlet."""
22
+
23
+ activeTime: int
24
+ energy: float
25
+ deviceStatus: str
26
+ power: float | str
27
+ voltage: float | str
28
+
29
+
30
+ @dataclass
31
+ class ResponseEnergyHistory(ResponseCodeModel):
32
+ """Response model for energy history."""
33
+
34
+ result: ResponseEnergyResult
35
+
36
+
37
+ @dataclass
38
+ class ResponseEnergyResult(ResponseBaseModel):
39
+ """Response model for energy result."""
40
+
41
+ energyConsumptionOfToday: float
42
+ costPerKWH: float
43
+ maxEnergy: float
44
+ totalEnergy: float
45
+ energyInfos: list[EnergyInfo]
46
+
47
+
48
+ @dataclass
49
+ class EnergyInfo:
50
+ """Energy Info list items."""
51
+
52
+ timestamp: int
53
+ energyKWH: float
54
+ money: float
55
+
56
+
57
+ @dataclass
58
+ class Response10ADetails(DataClassORJSONMixin):
59
+ """Response model for Etekcity outlet details."""
60
+
61
+ code: int
62
+ msg: str | None
63
+ deviceStatus: str
64
+ connectionStatus: str
65
+ activeTime: int
66
+ power: float
67
+ voltage: float
68
+ energy: float | None = None
69
+ nightLightStatus: str | None = None
70
+ nightLightAutoMode: str | None = None
71
+ nightLightBrightness: int | None = None
72
+
73
+
74
+ @dataclass
75
+ class ResponseOldEnergy(ResponseCodeModel):
76
+ """Response model for old energy history."""
77
+
78
+ energyConsumptionOfToday: float
79
+ costPerKWH: float
80
+ maxEnergy: float
81
+ totalEnergy: float
82
+ data: list[float]
83
+
84
+
85
+ @dataclass
86
+ class Response15ADetails(ResponseCodeModel):
87
+ """Response for 15A Outlets."""
88
+
89
+ result: Response15AOutletResult
90
+
91
+
92
+ @dataclass
93
+ class Response15AOutletResult(ResponseBaseModel):
94
+ """Response model for 15A outlet."""
95
+
96
+ deviceStatus: str
97
+ connectionStatus: str
98
+ activeTime: int
99
+ power: float
100
+ voltage: float
101
+ energy: float | None = None
102
+ nightLightStatus: str | None = None
103
+ nightLightAutoMode: str | None = None
104
+ nightLightBrightness: int | None = None
105
+
106
+
107
+ @dataclass
108
+ class Request15ADetails(RequestBypassV1):
109
+ """Request data model for 15A outlet Details."""
110
+
111
+
112
+ @dataclass
113
+ class RequestOutdoorStatus(RequestBypassV1):
114
+ """Request model for outlet status."""
115
+
116
+ status: str
117
+ switchNo: str
118
+
119
+
120
+ @dataclass
121
+ class RequestEnergyHistory(RequestBaseModel):
122
+ """Request model for energy history."""
123
+
124
+ acceptLanguage: str
125
+ appVersion: str
126
+ accountID: str
127
+ method: str
128
+ phoneBrand: str
129
+ phoneOS: str
130
+ timeZone: str
131
+ token: str
132
+ traceId: str
133
+ userCountryCode: str
134
+ debugMode: bool
135
+ homeTimeZone: str
136
+ uuid: str
137
+
138
+
139
+ @dataclass
140
+ class Request15AStatus(RequestBypassV1):
141
+ """Request data model for 15A outlet.
142
+
143
+ Inherits from RequestBypassV1.
144
+ """
145
+
146
+ status: str
147
+
148
+
149
+ @dataclass
150
+ class Request15ANightlight(RequestBypassV1):
151
+ """Nightlight request data model for 15A Outlets.
152
+
153
+ Inherits from RequestBypassV1.
154
+ """
155
+
156
+ mode: str
157
+
158
+
159
+ @dataclass
160
+ class ResponseOutdoorDetails(ResponseCodeModel):
161
+ """Response model for outdoor outlet."""
162
+
163
+ result: ResponseOutdoorOutletResult
164
+
165
+
166
+ @dataclass
167
+ class ResponseOutdoorOutletResult(ResponseBaseModel):
168
+ """Response model for outdoor outlet."""
169
+
170
+ deviceStatus: str
171
+ connectionStatus: str
172
+ activeTime: int
173
+ power: float
174
+ voltage: float
175
+ energy: float
176
+ subDevices: list[ResponseOutdoorSubDevices]
177
+
178
+
179
+ @dataclass
180
+ class ResponseOutdoorSubDevices(ResponseBaseModel):
181
+ """Response model for outdoor energy."""
182
+
183
+ subDeviceNo: int
184
+ defaultName: str
185
+ subDeviceName: str
186
+ subDeviceStatus: str
187
+
188
+
189
+ @dataclass
190
+ class ResponseBSDGO1Details(ResponseCodeModel):
191
+ """Response model for BSDGO1 outlet."""
192
+
193
+ result: ResponseBSDGO1OutletResult
194
+
195
+
196
+ @dataclass
197
+ class ResponseBSDGO1OutletResult(ResponseBaseModel):
198
+ """Response model for BSDGO1 outlet."""
199
+
200
+ powerSwitch_1: int
201
+ active_time: int
202
+ connectionStatus: str
203
+ code: int
204
+
205
+
206
+ @dataclass
207
+ class Timer7AItem(ResponseBaseModel):
208
+ """Timer item for 7A outlet."""
209
+
210
+ timerID: str
211
+ counterTimer: int
212
+ action: str
213
+ timerStatus: str
214
+
215
+
216
+ @dataclass
217
+ class ResultESW10Details(ResponseBaseModel):
218
+ """Response model for ESW10 outlet."""
219
+
220
+ enabled: bool