Async Python client for Xthings Cloud API
Project description
ha-xthings-cloud
Async Python client for the Xthings Cloud API, designed for Home Assistant integration.
Installation
pip install ha-xthings-cloud
Usage
API Client
import aiohttp
from ha_xthings_cloud import XthingsCloudApiClient
async with aiohttp.ClientSession() as session:
client = XthingsCloudApiClient(session)
# Login (supports 2FA)
result = await client.async_login("user@example.com", "password")
# Get devices
devices = await client.async_get_devices()
# Control devices
await client.async_switch_on("device-uuid")
await client.async_brite_brightness("device-uuid", 80)
await client.async_lock_lock("device-uuid")
WebSocket (Real-time Push)
from ha_xthings_cloud import XthingsCloudWebSocket
def on_status(device_uuid, status):
print(f"Device {device_uuid}: {status}")
async def on_token_expired():
# refresh token logic
pass
ws = XthingsCloudWebSocket(session, token, on_status, on_token_expired)
await ws.async_start()
KVS Signaling (Camera WebRTC)
from ha_xthings_cloud import KvsSignalingClient
kvs = KvsSignalingClient(session, region, channel_arn, credentials)
answer_sdp = await kvs.async_get_answer_sdp(offer_sdp, on_ice_candidate=callback)
Features
- Async HTTP client with
aiohttp.ClientSessioninjection - Authentication: login, token refresh, 2FA (email/phone)
- Device control: Switch, Plug, Light (brightness/HS color/color temp), Lock, Camera
- WebSocket: real-time device status push with auto-reconnect
- KVS Signaling: AWS Kinesis Video Streams WebRTC SDP exchange with SigV4 auth
- FRP remote access configuration
API Reference
XthingsCloudApiClient
| Method | Description |
|---|---|
async_login(email, password, ...) |
Login with optional 2FA |
async_refresh_token(refresh_token) |
Refresh auth token |
async_get_devices() |
Get device list |
async_get_device_status(device_id) |
Get single device status |
async_switch_on/off(device_id) |
Switch control |
async_plug_on/off(device_id) |
Plug control |
async_brite_on/off(device_id) |
Light on/off |
async_brite_brightness(device_id, brightness) |
Light brightness (0-100) |
async_brite_color(device_id, color) |
Light color (HS/color temp) |
async_lock_lock/unlock(device_id) |
Lock control |
async_get_camera_webrtc(device_id) |
Get camera KVS credentials |
async_get_frp_config(client_id) |
Get FRP remote access config |
XthingsCloudWebSocket
| Method | Description |
|---|---|
async_start() |
Start WebSocket with auto-reconnect |
async_stop() |
Stop WebSocket connection |
KvsSignalingClient
| Method | Description |
|---|---|
async_get_answer_sdp(offer_sdp, on_ice_candidate) |
SDP offer/answer exchange |
async_send_ice_candidate(candidate, sdp_mid, sdp_mline_index) |
Send ICE candidate |
async_get_ice_server_config() |
Get TURN/STUN servers |
async_close() |
Close signaling connection |
License
Apache-2.0
Project details
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
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 ha_xthings_cloud-1.0.0.tar.gz.
File metadata
- Download URL: ha_xthings_cloud-1.0.0.tar.gz
- Upload date:
- Size: 11.2 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
0fb69fa87473ecd9f4b81e5bff69ad9a879ab63f2720c5320e160b69532de73a
|
|
| MD5 |
0d834ff1197840b7fd87d60838f7ee52
|
|
| BLAKE2b-256 |
3e24fe020886cd85370017ac371c5ff8ea3a550dc6cd29c5ad6c6b1ed3a17c5d
|
Provenance
The following attestation bundles were made for ha_xthings_cloud-1.0.0.tar.gz:
Publisher:
workflows.yml on XthingsJacobs/ha-xthings-cloud
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
ha_xthings_cloud-1.0.0.tar.gz -
Subject digest:
0fb69fa87473ecd9f4b81e5bff69ad9a879ab63f2720c5320e160b69532de73a - Sigstore transparency entry: 1269440115
- Sigstore integration time:
-
Permalink:
XthingsJacobs/ha-xthings-cloud@c25a9430417970be581711e77b0cb8cd7e03deba -
Branch / Tag:
refs/tags/v1.0.0 - Owner: https://github.com/XthingsJacobs
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
workflows.yml@c25a9430417970be581711e77b0cb8cd7e03deba -
Trigger Event:
release
-
Statement type:
File details
Details for the file ha_xthings_cloud-1.0.0-py3-none-any.whl.
File metadata
- Download URL: ha_xthings_cloud-1.0.0-py3-none-any.whl
- Upload date:
- Size: 12.4 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
ce1be536f67a8312984e468ccb067d0b5b86aa15371a0444400822e50930e21f
|
|
| MD5 |
740dd1633380a1a7be6793bdb6e3f6b2
|
|
| BLAKE2b-256 |
334bfc45b29946962b4eb56ac1b61218f6849616754aa9bb04cf973b50d0cade
|
Provenance
The following attestation bundles were made for ha_xthings_cloud-1.0.0-py3-none-any.whl:
Publisher:
workflows.yml on XthingsJacobs/ha-xthings-cloud
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
ha_xthings_cloud-1.0.0-py3-none-any.whl -
Subject digest:
ce1be536f67a8312984e468ccb067d0b5b86aa15371a0444400822e50930e21f - Sigstore transparency entry: 1269440209
- Sigstore integration time:
-
Permalink:
XthingsJacobs/ha-xthings-cloud@c25a9430417970be581711e77b0cb8cd7e03deba -
Branch / Tag:
refs/tags/v1.0.0 - Owner: https://github.com/XthingsJacobs
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
workflows.yml@c25a9430417970be581711e77b0cb8cd7e03deba -
Trigger Event:
release
-
Statement type: