Install & Compatibility
Where this runs
tested against v0.6 · pip install
no network on importno background threads
Install × environment matrix
Each cell = how many times install + import succeeded across repeated harness runs. Partial = flaky.
glibc = Debian/Ubuntu slim · musl = Alpine Linux
muslpy 3.10–3.910 runs
installs and imports cleanly · install 0.0s · import 0.655s · 32.3MB
glibcpy 3.10–3.910 runs
installs and imports cleanly · install 3.7s · import 0.624s · 33MB
31MB installed
● package 31MB
Code
Verified usage
Verified import paths — ran on the pinned version, not inferred.
MiCloud
✓ from micloud import MiCloud
MiCloudAccessDenied
✓ from micloud.exceptions import MiCloudAccessDenied
This quickstart logs into the Xiaomi Cloud using environment variables for credentials and then retrieves a list of connected devices. It's crucial to specify the correct `server` region matching your Xiaomi account.
import os
from micloud import MiCloud
# It's highly recommended to specify your server region explicitly.
# Common regions: 'de' (Germany, default), 'cn' (China), 'us' (USA), 'ru' (Russia).
# Replace with the region your Xiaomi account is registered in.
MI_CLOUD_SERVER = os.environ.get('MI_CLOUD_SERVER', 'de')
MI_CLOUD_USERNAME = os.environ.get('MI_CLOUD_USERNAME', 'your_email@example.com')
MI_CLOUD_PASSWORD = os.environ.get('MI_CLOUD_PASSWORD', 'your_password')
try:
micloud = MiCloud(MI_CLOUD_USERNAME, MI_CLOUD_PASSWORD, server=MI_CLOUD_SERVER)
micloud.login()
print(f"Successfully logged in to Xiaomi Cloud (server: {MI_CLOUD_SERVER}).")
devices = micloud.get_devices()
if devices:
print(f"Found {len(devices)} devices:")
for device in devices:
print(f" - Name: {device.get('name', 'N/A')}, Model: {device.get('model', 'N/A')}, ID: {device.get('did', 'N/A')}")
else:
print("No devices found associated with this account and server.")
except Exception as e:
print(f"An error occurred: {e}")
print("Please check your credentials, server region, and network connection.")
Errors
Common errors & fixes
ModuleNotFoundError: No module named 'micloud'
The `micloud` package is not installed in your current Python environment.
fixInstall the package using pip: `pip install micloud`
micloud.exceptions.MiCloudAccessDenied: Invalid credentials
The provided username (email/phone) or password for your Xiaomi account is incorrect.
fixDouble-check your Xiaomi account credentials for typos or ensure the account exists and is active. You might also try logging in via the official Xiaomi Home app or website to confirm.
micloud.exceptions.MiCloudException: Unexpected response from server: HTTP 403 (or 'No devices found' when devices are expected)
This often indicates that the specified server region does not match the region your Xiaomi account is registered in. The default server is 'de'.
fixWhen initializing `MiCloud`, explicitly set the `server` parameter to your account's region (e.g., 'cn', 'us', 'ru', 'de'): `micloud = MiCloud(username, password, server='cn')`
Upgrade
Version history
0.6latest on PyPI · released Dec 8, 2022
Audit
Dependencies
requestsrequiredHTTP client for API communication.