Registry / crm-productivity / micloud

micloud

JSON →
library0.6pypypi✓ verified 85d ago

The `micloud` library provides a Python interface to connect to Xiaomi's cloud services, allowing programmatic interaction with Xiaomi IoT devices registered to an account. It is currently at version 0.6 and has an irregular release cadence based on feature additions and bug fixes.

pip install micloud
INSTALL
IMPORT
SIG · MICLOUD
M
micloud
crm-productivitypythonv0.6
Install
3.7s avg
Import
640ms
Disk
31MB
Pass rate
10/ 10
Env Coverage10 / 10
glibc
3.93.13
musl
3.93.13
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
musl
py 3.103.910 runs
installs and imports cleanly · install 0.0s · import 0.655s · 32.3MB
glibc
py 3.103.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.")
Debug
Known issues
breakingAs of v0.4, failed login attempts due to invalid credentials now raise a specific `MiCloudAccessDenied` exception. Code that previously caught generic exceptions for authentication failures might need an update.
fix
Update your error handling to catch `micloud.exceptions.MiCloudAccessDenied` specifically when dealing with login failures.
affects: >=0.4
gotchaThe `MiCloud` constructor defaults the `server` parameter to 'de' (Germany). If your Xiaomi account is registered to a different region (e.g., US, CN, RU), you must explicitly specify it, or you may encounter 'no devices found' or login issues.
fix
Pass the correct server region to the `MiCloud` constructor: `MiCloud(username, password, server='cn')`. Common server codes include 'cn' (China), 'us' (USA), 'ru' (Russia), 'de' (Germany).
affects: All versions
gotchaVersions prior to 0.5 may experience issues with ARC4 encryption, potentially leading to connection failures or incorrect data for some devices or specific API calls.
fix
Upgrade to `micloud` version 0.5 or newer to ensure correct encryption handling: `pip install --upgrade micloud`.
affects: <0.5
Errors
Common errors & fixes
ModuleNotFoundError: No module named 'micloud'
The `micloud` package is not installed in your current Python environment.
fix
Install 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.
fix
Double-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'.
fix
When 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.
Agent activity
101 hits · last 30 days
node
91
OpenAI (training)
1
Resources
micloud — pip install micloud · libregistry