{"library":"micloud","title":"Mi Cloud Connect Library","description":"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.","language":"python","status":"active","last_verified":"Thu Apr 16","install":{"commands":["pip install micloud"],"cli":null},"imports":["from micloud import MiCloud","from micloud.exceptions import MiCloudAccessDenied"],"auth":{"required":false,"env_vars":[]},"quickstart":{"code":"import os\nfrom micloud import MiCloud\n\n# It's highly recommended to specify your server region explicitly.\n# Common regions: 'de' (Germany, default), 'cn' (China), 'us' (USA), 'ru' (Russia).\n# Replace with the region your Xiaomi account is registered in.\nMI_CLOUD_SERVER = os.environ.get('MI_CLOUD_SERVER', 'de') \nMI_CLOUD_USERNAME = os.environ.get('MI_CLOUD_USERNAME', 'your_email@example.com')\nMI_CLOUD_PASSWORD = os.environ.get('MI_CLOUD_PASSWORD', 'your_password')\n\ntry:\n    micloud = MiCloud(MI_CLOUD_USERNAME, MI_CLOUD_PASSWORD, server=MI_CLOUD_SERVER)\n    micloud.login()\n    print(f\"Successfully logged in to Xiaomi Cloud (server: {MI_CLOUD_SERVER}).\")\n    \n    devices = micloud.get_devices()\n    if devices:\n        print(f\"Found {len(devices)} devices:\")\n        for device in devices:\n            print(f\"  - Name: {device.get('name', 'N/A')}, Model: {device.get('model', 'N/A')}, ID: {device.get('did', 'N/A')}\")\n    else:\n        print(\"No devices found associated with this account and server.\")\n\nexcept Exception as e:\n    print(f\"An error occurred: {e}\")\n    print(\"Please check your credentials, server region, and network connection.\")\n","lang":"python","description":"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.","tag":null,"tag_description":null,"last_tested":null,"results":[]},"compatibility":null}