ClawSkills logoClawSkills

Homey - Home Automation

通过 CLI 控制 Homey 家庭自动化中心。当您需要控制智能家居设备(灯光、恒温器、插座等)、检查设备状态、列出区域时使用

介绍

# Homey CLI

用于控制 Homey 家庭自动化中心的、安全且对代理友好的 CLI。

## 此技能提供的内容

- **设备控制**:开关设备、调暗灯光、更改颜色、设定温度 - **设备检查**:列出设备、检查状态、读取功能 - **区域管理**:列出区域及每个区域的设备 - **流程控制**:列出并触发流程 - **清单**:获取完整的中心概览

## 设置

### 1. 安装依赖

```bash cd skills/homey-cli npm install ```

### 2. 创建 Homey 应用凭据

1. 访问 https://tools.developer.homey.app/tools/app 2. 创建一个新应用,并填写: - **回调 URL**:`http://localhost:8787/callback` - 记下您的 **Client ID** 和 **Client Secret**

### 3. 配置环境

创建 `.env` 文件:

```bash export HOMEY_CLIENT_ID="your-client-id" export HOMEY_CLIENT_SECRET="your-client-secret" export HOMEY_REDIRECT_URL="http://localhost:8787/callback" ```

### 4. 登录

```bash bash run.sh auth login ```

请在浏览器中按照 OAuth 流程操作。令牌将存储在 `~/.config/homey-cli/` 中。

## 使用方法

### 列出 Homey 设备

```bash bash run.sh homey list ```

### 选择活动 Homey

```bash bash run.sh homey use <homeyId> ```

### 设备操作

```bash # List all devices bash run.sh devices list

# List devices as JSON bash run.sh devices list --json

# Get specific device bash run.sh devices get <deviceId>

# Read capability value bash run.sh devices read <deviceId> onoff

# Control devices bash run.sh devices on <deviceId> bash run.sh devices off <deviceId> bash run.sh devices dim <deviceId> 0.4 bash run.sh devices color <deviceId> #FF8800 bash run.sh devices temperature <deviceId> 21.5 ```

### 流程操作

```bash # List flows bash run.sh flows list

# Trigger flow bash run.sh flows trigger <flowId> ```

### 完整清单

```bash bash run.sh inventory --json ```

## 安全模型

出于安全考虑,写入操作受**功能白名单**限制:

- 默认允许:`onoff`、`dim`、`light_hue`、`light_saturation`、`light_temperature`、`target_temperature` - 覆盖方式:`export HOMEY_CLI_ALLOWED_CAPABILITIES=onoff,dim,target_temperature`

破坏性操作(如删除设备、修改流程、更改应用设置)**不受支持**。

## 常见查询

当用户询问时: - “打开厨房的灯” → 列出设备,找到匹配项,使用 `devices on <deviceId>` - “将客厅灯光调暗至 50%” → 找到设备,使用 `devices dim <deviceId> 0.5` - “卧室的温度是多少?” → 找到设备,使用 `devices read <deviceId> measure_temperature` - “列出我所有的灯” → 使用 `devices list --json` 并按类别/功能进行筛选

## 配置存储

- **令牌**:`~/.config/homey-cli/credentials.json` - **活动 Homey**:`~/.config/homey-cli/config.json`

## 故障排除

- **身份验证错误**:重新运行 `bash run.sh auth login` - **未找到设备**:使用 `bash run.sh devices list` 检查设备名称/ID - **功能不被允许**:添加到 `HOMEY_CLI_ALLOWED_CAPABILITIES` 或检查其是否为只读功能

更多产品