用途:通过本地网络 API 用命令行控制 Philips Hue 智能灯,可用于开关灯、调节亮度与色彩、激活场景,以及按房间或区域批量控制。
准备条件:先安装命令行工具 openhue,命令为 brew install openhue/tap/openhue-cli(文档见 https://www.openhue.io/)。首次使用需运行 openhue setup 注册 Hue Bridge,按提示按下桥接器上的物理按钮,凭据会保存到 ~/.config/openhue/。Hue Bridge 必须处于同一本地网络;初次设置后无需云账号。
主要能力: 灯光发现:openhue get lights 列出全部灯(id、名称、状态),get rooms 列出房间,get zones 列出区域,get scenes 列出场景。 灯光控制:openhue set light "Name" --on 开灯,--off 关灯,--brightness 80 调亮度(1-100),--color-temp 4000 调色温(开尔文 2000-6500),--hue 120 --sat 100 调颜色(hue 0-360,sat 0-100)。 房间或分组控制:openhue set room "Living Room" --on、--off、--brightness 50 等。 场景:openhue set scene "Relax" 按名称激活场景,如 Relax、Movie、Energize。
常见用法示例:关闭卧室灯使用 openhue set room "Bedroom" --off;客厅设为暖光 30% 亮度使用 openhue set room "Living Room" --on --brightness 30 --color-temp 2700;激活电影场景使用 openhue set scene "Movie";查看所有场景使用 openhue get scenes;办公室亮白光使用 openhue set room "Office" --on --brightness 100 --color-temp 6500。常用色温:2000K 烛光/极暖,2700K 暖白,4000K 中性白,6500K 冷白/日光。
使用规则与限制:先检查是否已安装,运行 which openhue;未安装则给出 brew install 命令并停止。若未完成设置(无配置),应提示用户先运行 openhue setup。房间和灯的名称区分大小写,需用 openhue get rooms 确认准确名称。亮度范围为 1-100,不是 0-255。命令失败时检查 Bridge IP 在本地网络中是否仍可达。响应应简洁,只列出所做更改,而非原始 API 输出。其他平台、价格与更多高级功能暂未提供。