qingping sdk for python in asyncio with binary protocol parser
Project description
✨ qingping_sdk ✨
Usage
import os
import time
from qingping_sdk import Client
async def main():
async with Client(os.getenv("APP_KEY"), os.getenv("APP_SECRET")) as client:
device = await client.get_devices()
print(device)
mac = device["devices"][0]["info"]["mac"]
print(
await client.get_history_data(
mac, int(time.time()) - 3600, int(time.time())
)
)
print(
await client.get_history_events(
mac, int(time.time()) - 3600, int(time.time())
)
)
d = await client.change_settings(
[mac], 60, 60
)
alert = await client.get_alert(mac)
print(alert)
print(await client.delete_alert(mac, [alert["alert_configs"][0]["id"]]))
print("---groups----")
print(await client.get_groups())
print("---sn----")
print(await client.get_device_info([mac], ["sn"]))
asyncio.run(main())
Public functions
class Client:
def __init__(self, app_key: str, app_secret: str, endpoint: str = None, api_endpoint: str = None, client_session: Incomplete | None = None, close_on_exit: bool = True, loop: asyncio.AbstractEventLoop = None, **kw) -> None: ...
async def aclose(self) -> None: ...
async def __aenter__(self): ...
async def __aexit__(self, exc_type, exc_val, exc_tb): ...
async def send_request(self, method: str = 'GET', url: str = None, params: dict = None, json: dict = None): ...
async def bind_device(self, device_token: str, product_id: int, timestamp: int = None) -> Device: ...
async def delete_device(self, mac: list[str], timestamp: int = None): ...
async def get_devices(self, group_id: int = None, offset: int = None, limit: int = None, role: str = None, timestamp: int = None) -> DeviceResponse: ...
async def get_history_data(self, mac: str, start_time: int, end_time: int, timestamp: int = None, offset: int = None, limit: int = None) -> HistoryDataResponse: ...
async def get_history_events(self, mac: str, start_time: int, end_time: int, timestamp: int = None, offset: int = None, limit: int = None) -> HistoryEventResponse: ...
async def change_settings(self, mac: list[str], report_interval: int, collect_interval: int, timestamp: int = None): ...
async def add_alert(self, mac: str, alert_config: AlertConfig, timestamp: int = None): ...
async def get_alert(self, mac: str, timestamp: int = None) -> GetAlertResponse: ...
async def change_alert(self, mac: str, alert_config: AlertConfig, timestamp: int = None): ...
async def delete_alert(self, mac: str, config_id: list[int], timestamp: int = None): ...
async def get_groups(self, timestamp: int = None) -> GetGroupsResponse: ...
async def get_device_info(self, mac_list: list[str], profile: list[str], timestamp: int = None) -> DeviceInfoResponse: ...
@dataclass
class Event:
sop: bytes
cmd: int
length: int
payload: bytes
checksum: int
@property
def keys(self) -> dict: ...
@keys.setter
def keys(self, value) -> None: ...
def to_bytes(self) -> bytes: ...
def __init__(self, sop, cmd, length, payload, checksum) -> None: ...
def parse_history_data(data: bytes): ...
def build_history_data(time: int, internal: int, history: list) -> bytes: ...
class Connection:
def __init__(self) -> None: ...
def feed_data(self, data: bytes) -> Generator[Event, None, None]: ...
def send(self, event: Event) -> bytes: ...
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
qingping_sdk-0.0.2.tar.gz
(9.8 kB
view details)
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file qingping_sdk-0.0.2.tar.gz.
File metadata
- Download URL: qingping_sdk-0.0.2.tar.gz
- Upload date:
- Size: 9.8 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.0.1 CPython/3.10.15
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
9e92b97eb4adb2bff9fd0d8a139f5c171dce4138692d6b4a2cce53f879701f89
|
|
| MD5 |
07182ed24fff12122fb8b367ffb65024
|
|
| BLAKE2b-256 |
6ecda03e6d9e70658c0606f3f7a4b8984faf05f83a53d32975dada6f0bc143ee
|
File details
Details for the file qingping_sdk-0.0.2-py3-none-any.whl.
File metadata
- Download URL: qingping_sdk-0.0.2-py3-none-any.whl
- Upload date:
- Size: 9.5 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.0.1 CPython/3.10.15
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
244accc0357597751f6b48dcc5fba8146172a5c584448bacdb140283d4050ecb
|
|
| MD5 |
55201677a2abfa7cc63eb222da49a914
|
|
| BLAKE2b-256 |
d2237e435a5df9985e980d74dafe003f5410ead290e80594c1e28e745337a913
|