管理和控制小米/米家智能家居设备,直接调用 mijiaAPI CLI 命令通过小米云端 API 控制设备。支持设备发现、开关控制、亮度调节、颜色设置等功能。当用户需要控制小米智能设备(如台灯、灯泡、插座等)、获取设备列表或查看设备状态时使用此技能。
npx skills add https://github.com/dean2021/mijia-device-manager --skill mijia-device-manager
此技能用于管理和控制小米/米家智能家居设备,直接调用 mijiaAPI CLI 通过小米云端 API 控制设备。
pip install mijiaAPI
python -m mijiaAPI --list_homes
python -m mijiaAPI --list_homes
运行后会显示二维码,使用米家 APP 扫描即可完成登录。
python -m mijiaAPI -l
输出中每条设备信息包含 did,后续控制命令使用该值。
# 开灯
python -m mijiaAPI set --did "123456789" --prop_name "on" --value True
# 设置亮度
python -m mijiaAPI set --did "123456789" --prop_name "brightness" --value 50
# 获取状态
python -m mijiaAPI get --did "123456789" --prop_name "brightness"
python -m mijiaAPI --help
python -m mijiaAPI get --help
python -m mijiaAPI set --help
常用命令示例:
# 列出所有设备
python -m mijiaAPI -l
# 从列表中找到 did
python -m mijiaAPI -l | grep did
# 列出所有家庭
python -m mijiaAPI --list_homes
# 获取设备属性
python -m mijiaAPI get --did "123456789" --prop_name "brightness"
# 设置设备属性
python -m mijiaAPI set --did "123456789" --prop_name "on" --value True
python -m mijiaAPI set --did "123456789" --prop_name "brightness" --value 50
# 执行场景
python -m mijiaAPI --run_scene "回家"
常见设备属性名称:
| 属性名 | 说明 | 类型 | 示例值 |
|--------|------|------|--------|
| on | 开关状态 | bool | True/False |
| brightness | 亮度 | int | 0-100 |
| color-temperature | 色温 | int | 2700-6500 |
| color | 颜色 | int | RGB值 |
注意: 不同设备支持的属性不同,操作前先使用 --get_device_info DEVICE_MODEL 获取设备属性信息,确认可操作的属性后再执行控制命令。DEVICE_MODEL 可通过 --list_devices 获取。
操作步骤:
python -m mijiaAPI -l 列出设备,确认 did 与 DEVICE_MODEL。python -m mijiaAPI --get_device_info DEVICE_MODEL 获取可用属性与范围。get 或 set 命令完成查询或控制。问题:无法登录或提示认证失败
rm ~/.config/mijia-api/auth.json
python -m mijiaAPI --list_homes
问题:找不到设备
-l 命令查看准确的设备名称问题:不知道 did
python -m mijiaAPI -l 列出设备,在输出中找到设备的 did 字段问题:属性设置失败
--get_device_info DEVICE_MODEL 获取属性信息)问题:想知道某个设备都有哪些属性
--list_devices 获取 DEVICE_MODEL,再用 --get_device_info DEVICE_MODEL 获取属性信息,例如: python -m mijiaAPI --get_device_info yeelink.light.lamp27
Guide for creating high-quality MCP (Model Context Protocol) servers that enable LLMs to interact with external services through well-designed tools. Use when building MCP servers to integrate external APIs or services, whether in Python (FastMCP) or Node/TypeScript (MCP SDK).
Automatically creates user-facing changelogs from git commits by analyzing commit history, categorizing changes, and transforming technical commits into clear, customer-friendly release notes. Turns hours of manual changelog writing into minutes of automated generation.
Use when implementation is complete, all tests pass, and you need to decide how to integrate the work - guides completion of development work by presenting structured options for merge, PR, or cleanup
Guide for creating high-quality MCP (Model Context Protocol) servers that enable LLMs to interact with external services through well-designed tools. Use when building MCP servers to integrate external APIs or services, whether in Python (FastMCP) or Node/TypeScript (MCP SDK).
React Native and Expo best practices for building performant mobile apps. Use when building React Native components, optimizing list performance, implementing animations, or working with native modules. Triggers on tasks involving React Native, Expo, mobile performance, or native platform APIs.
React and Next.js performance optimization guidelines from Vercel Engineering. This skill should be used when writing, reviewing, or refactoring React/Next.js code to ensure optimal performance patterns. Triggers on tasks involving React components, Next.js pages, data fetching, bundle optimization, or performance improvements.
Next.js best practices - file conventions, RSC boundaries, data patterns, async APIs, metadata, error handling, route handlers, image/font optimization, bundling
Use when starting feature work that needs isolation from current workspace or before executing implementation plans - creates isolated git worktrees with smart directory selection and safety verification
Take dean2021/mijia-device-manager from the repository into ~/.claude/skills for personal
use, or into .claude/skills inside a project.
The agent identifies a skill by the name field in its header. Two skills with the
same name cannot sit side by side — one of them will be ignored.
The instructions reference pip.
Without those the skill loads but fails at the first command.