Mijia Smart Home Control
Control Xiaomi Mijia smart devices via the mijiaAPI.
Setup
Before using this skill, you need to:
- 1. Install dependencies:
CODEBLOCK0
- 2. Set your device ID as an environment variable:
CODEBLOCK1
- 3. First run will prompt for Xiaomi account login via QR code.
Finding Device IDs
To find your device IDs, use the mijia-api library:
CODEBLOCK2
How to Use
Skill path: INLINECODE0
Lamp Control Commands
CODEBLOCK3
Natural Language Understanding
When the user says the following, execute the corresponding command:
| User Says | Command |
|---|
| Turn on the light / open lamp | INLINECODE1 |
| Turn off the light / close lamp |
scripts/lamp_cli.py off |
| Toggle the light |
scripts/lamp_cli.py toggle |
| Brighter / more bright | Check status first, then increase by 20-30% |
| Dimmer / less bright | Check status first, then decrease by 20-30% |
| Full brightness / maximum |
scripts/lamp_cli.py brightness 100 |
| Minimum brightness |
scripts/lamp_cli.py brightness 1 |
| Warm light |
scripts/lamp_cli.py temp 2700 |
| Cool light / white light |
scripts/lamp_cli.py temp 6500 |
| Reading mode |
scripts/lamp_cli.py mode reading |
| Computer mode |
scripts/lamp_cli.py mode computer |
| Night mode |
scripts/lamp_cli.py mode night |
| Lamp status / what's the light status |
scripts/lamp_cli.py status |
Before Executing
- 1. Navigate to skill directory: INLINECODE12
- Ensure
MIJIA_LAMP_DID environment variable is set - Run with uv: INLINECODE14
- Report the result to the user after execution
米家智能家居控制
通过mijiaAPI控制小米米家智能设备。
设置
使用此技能前,你需要:
- 1. 安装依赖:
bash
cd /path/to/mijia-skill
uv sync
- 2. 将设备ID设置为环境变量:
bash
export MIJIA
LAMPDID=your
deviceid
- 3. 首次运行将通过二维码提示登录小米账号。
查找设备ID
要查找设备ID,请使用mijia-api库:
python
from mijiaAPI import mijiaAPI
api = mijiaAPI()
api.login()
devices = api.getdevicelist()
for d in devices:
print(f{d[name]}: {d[did]})
使用方法
技能路径:~/.clawdbot/skills/mijia
灯具控制命令
bash
导航到技能目录
cd ~/.claude/skills/mijia
检查状态
uv run python scripts/lamp_cli.py status
开/关
uv run python scripts/lamp_cli.py on
uv run python scripts/lamp_cli.py off
uv run python scripts/lamp_cli.py toggle
调节亮度(1-100%)
uv run python scripts/lamp_cli.py brightness 50
调节色温(2700-6500K)
uv run python scripts/lamp_cli.py temp 4000
设置模式
uv run python scripts/lamp_cli.py mode reading # 阅读模式
uv run python scripts/lamp_cli.py mode computer # 电脑模式
uv run python scripts/lamp_cli.py mode night # 夜间阅读
uv run python scripts/lamp_cli.py mode antiblue # 防蓝光模式
uv run python scripts/lamp_cli.py mode work # 工作模式
uv run python scripts/lamp_cli.py mode candle # 烛光效果
uv run python scripts/lamp_cli.py mode twinkle # 闪烁提醒
自然语言理解
当用户说出以下内容时,执行相应命令:
| 用户指令 | 命令 |
|---|
| 打开灯 | scripts/lampcli.py on |
| 关灯 |
scripts/lampcli.py off |
| 切换灯光 | scripts/lamp_cli.py toggle |
| 更亮一些 | 先检查状态,然后增加20-30% |
| 更暗一些 | 先检查状态,然后减少20-30% |
| 最亮 / 最大亮度 | scripts/lamp_cli.py brightness 100 |
| 最低亮度 | scripts/lamp_cli.py brightness 1 |
| 暖光 | scripts/lamp_cli.py temp 2700 |
| 冷光 / 白光 | scripts/lamp_cli.py temp 6500 |
| 阅读模式 | scripts/lamp_cli.py mode reading |
| 电脑模式 | scripts/lamp_cli.py mode computer |
| 夜间模式 | scripts/lamp_cli.py mode night |
| 灯光状态 / 灯的状态 | scripts/lamp_cli.py status |
执行前
- 1. 导航到技能目录:cd ~/.clawdbot/skills/mijia
- 确保已设置MIJIALAMPDID环境变量
- 使用uv运行:uv run python scripts/lamp_cli.py
- 执行后将结果报告给用户