SuperAPI AI Directory

mijia-control

Control Xiaomi/Mijia smart home devices (lights, AC, heaters, robots, cameras), with a web dashboard, REST API, CLI, energy monitoring and automation rules.

Open website

About this tool

MijiaPilot - A fully bridged home smart home platform for the Xiaomi-Mijia ecosystem × MCP × CLI × AI Agent × HomeKit.

I. Purpose For users who want unified management and automation of Xiaomi/Mijia ecosystem devices, it provides multiple entry points for control such as a Web interface, API, command line, and AI Agent, and can bridge Mijia devices to the Apple Home app and Siri.

II. Main Capabilities

  • Web management interface: device control, home/scene management, energy consumption statistics, automation rules, dark mode, mobile adaptation.
  • RESTful API: JWT authentication, complete Swagger documentation (/api/docs/), supports third-party integration.
  • CLI tool: mijia-control command line, supports login, device list, property read/write, scene execution.
  • Real-time communication: SocketIO pushes device status changes.
  • Device grouping/favorites: custom groups for managing devices, quickly favorite frequently used devices.
  • Scheduled automation rules: supports cron, interval, sunrise/sunset and other trigger methods.
  • Energy consumption statistics dashboard: records and displays energy consumption data by device (daily/hourly granularity).
  • API Token management: create and manage access tokens for third-party applications.
  • MCP Server: built-in MCP protocol support, AI Agents such as Claude Code / Hermes Agent can call it directly.
  • HomeKit bridge: control Mijia devices through the Apple Home app and Siri, supporting lights, plugs, sensors, thermostats, etc.
  • BLE Bluetooth sensors: PC Bluetooth directly connects to Xiaomi BLE temperature and humidity meters, local real-time data collection, supports automation linkage.
  • Multi-user & permissions: user registration and login, admin backend, rate limiting protection.

III. Usage

  1. Copy .env.example to .env and fill in the actual configuration.
  2. Start the Web service (python run.py), visit http://127.0.0.1:5000 , and after registering an account you can use it.
  3. Complete API documentation: after startup, visit /api/docs/.
  4. MCP Server: make sure the Web service is started, obtain the Token (MIJIA_TOKEN), and use it in AI Agents compatible with the MCP protocol such as Claude Code.
  5. HomeKit Bridge: implemented via HAP-Python, add or set environment variables in .env, obtain a JWT Token, add the device in the iPhone Home app by scanning the QR code or manually entering the PIN; after pairing, the device appears as a "Mijia Smart Home" bridge. Windows users need to install Bonjour Print Services or use Docker to run the Bridge.
  6. BLE Bluetooth sensors: requires the PC to have Bluetooth functionality (built-in support on Windows 10/11), set MIJIA_TOKEN, supports data display, history queries, and automation linkage (for example, automatically turn on the air conditioner when temperature > 30°C). For detailed documentation, see docs/ble.md.
  7. CLI: after installing and activating the virtual environment, use the mijia-control command, and you can also call flask mijia <command> through the Flask CLI.

IV. Applicable Scenarios

  • Unified management of Mijia devices and energy consumption through the Web panel.
  • Integrate Mijia control into your own system with the REST API or CLI.
  • Let AI Agents directly control Mijia devices through MCP.
  • Control Mijia devices with the Apple Home app and Siri through HomeKit.
  • Use BLE Bluetooth direct-connected sensors to achieve local data collection and automation linkage.

V. Limitations and Notes

  • This project is open source under the GPL-3.0 license, inheriting the license agreement from the upstream mijiaAPI.
  • The underlying layer uses the Python SDK provided by Do1e/mijia-api (mijiaAPI v3.0+), used for device communication, property read/write, and scene execution with the Xiaomi cloud.
  • v1.0.3 fixes the SQLite default value of the SQLAlchemy database URI; under Werkzeug 3.1+ security restrictions, run.py adds allow_unsafe_werkzeug=True only guarantees startup in the development environment.
  • SQLite is used as a fallback only when DATABASE_URL is not configured; when switching from MySQL to SQLite for the first time or creating a new SQLite database, you need to run flask db upgrade to create the tables, and register a user via the Web interface or /api/auth/register, then bind a Xiaomi account before device control features can be used.
  • When a device model is not in the built-in rules, the Bridge will automatically infer the type from spec_data; if it is inaccurate, you can create homekit_mapping.yaml to customize the mapping. Available categories include light, outlet, switch, temperature_sensor, thermostat, heater, camera, and ignored.
  • Specific charging, pricing, platform support, and usage results are not yet provided.