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
212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 | |
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. |