Device Mixins↲
The pyvesync.utils.device_mixins
modules are used to add boilerplate code for the common API requests that are used by different devices.
Please reference Development for more information on how to use the device mixins.
Bypass V1 Mixins and functions↲
pyvesync.utils.device_mixins.BypassV1Mixin ↲
Mixin for bypass V1 API.
Overrides the _build_request
method and request_keys
attribute for devices
that use the Bypass V1 API- /cloud/v1/deviceManaged/bypass. The primary method to
call is call_bypassv1_api
, which is a wrapper for setting up the request body and
calling the API. The bypass
endpoint can also be overridden for specific API calls.
Source code in src\pyvesync\utils\device_mixins.py
283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 |
|
request_keys
class-attribute
↲
request_keys: list[str] = [
'acceptLanguage',
'appVersion',
'phoneBrand',
'phoneOS',
'accountID',
'cid',
'configModule',
'debugMode',
'traceId',
'timeZone',
'token',
'userCountryCode',
'uuid',
'configModel',
'deviceId',
]
Inherited From BypassV1Mixin
call_bypassv1_api
async
↲
call_bypassv1_api(
request_model: type[RequestBypassV1],
update_dict: dict | None = None,
method: str = 'bypass',
endpoint: str = 'bypass',
) -> dict | None
Inherited From BypassV1Mixin
Send ByPass V1 API request.
This uses the _build_request
method to send API requests to the Bypass V1 API.
The endpoint can be overridden with the endpoint
argument.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
request_model
|
type[RequestBypassV1]
|
The request model to use. |
required |
update_dict
|
dict
|
Additional keys to add on. |
None
|
method
|
str
|
The method to use in the outer body. |
'bypass'
|
endpoint
|
str | None
|
The last part of the url path, defaults to
|
'bypass'
|
Returns:
Name | Type | Description |
---|---|---|
bytes |
dict | None
|
The response from the API request. |
Source code in src\pyvesync\utils\device_mixins.py
pyvesync.utils.device_mixins.process_bypassv1_result ↲
process_bypassv1_result(
device: VeSyncBaseDevice,
logger: Logger,
method: str,
resp_dict: dict | None,
model: type[T_MODEL],
) -> T_MODEL | None
Process the Bypass V1 API response.
This will gracefully handle errors in the response and error codes, logging them as needed. The return value is the built model.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
device
|
VeSyncBaseDevice
|
The device object. |
required |
logger
|
Logger
|
The logger to use for logging. |
required |
method
|
str
|
The method used in the payload. |
required |
resp_dict
|
dict | str
|
The api response. |
required |
model
|
type[T_MODEL]
|
The model to use for the response. |
required |
Returns:
Name | Type | Description |
---|---|---|
dict |
T_MODEL | None
|
The response data |
Source code in src\pyvesync\utils\device_mixins.py
Bypass V2 Mixins and functions↲
pyvesync.utils.device_mixins.BypassV2Mixin ↲
Mixin for bypass V2 API.
Overrides the _build_request
method and request_keys
attribute for devices
that use the Bypass V2 API- /cloud/v2/deviceManaged/bypassV2.
Source code in src\pyvesync\utils\device_mixins.py
request_keys
class-attribute
↲
request_keys: list[str] = [
'acceptLanguage',
'appVersion',
'phoneBrand',
'phoneOS',
'accountID',
'cid',
'configModule',
'debugMode',
'traceId',
'timeZone',
'token',
'userCountryCode',
'configModel',
'deviceId',
]
Inherited From BypassV2Mixin
call_bypassv2_api
async
↲
call_bypassv2_api(
payload_method: str,
data: dict | None = None,
method: str = 'bypassV2',
endpoint: str = 'bypassV2',
) -> dict | None
Inherited From BypassV2Mixin
Send Bypass V2 API request.
This uses the _build_request
method to send API requests to the Bypass V2 API.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
payload_method
|
str
|
The method to use in the payload dict. |
required |
data
|
dict | None
|
The data to send in the request. |
None
|
method
|
str
|
The method to use in the outer body. |
'bypassV2'
|
endpoint
|
str | None
|
The last part of the API url, defaults to
|
'bypassV2'
|
Returns:
Name | Type | Description |
---|---|---|
bytes |
dict | None
|
The response from the API request. |
Source code in src\pyvesync\utils\device_mixins.py
pyvesync.utils.device_mixins.process_bypassv2_result ↲
process_bypassv2_result(
device: VeSyncBaseDevice,
logger: Logger,
method: str,
resp_dict: dict | None,
model: type[T_MODEL],
) -> T_MODEL | None
Process the Bypass V1 API response.
This will gracefully handle errors in the response and error codes, logging them as needed. The return dictionary is the inner result value of the API response.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
device
|
VeSyncBaseDevice
|
The device object. |
required |
logger
|
Logger
|
The logger to use for logging. |
required |
method
|
str
|
The method used in the payload. |
required |
resp_dict
|
dict | str
|
The api response. |
required |
model
|
type[T_MODEL]
|
The model to use for the response. |
required |
Returns:
Name | Type | Description |
---|---|---|
T_MODEL |
T_MODEL | None
|
An instance of the inner result model. |