Govee OpenAPI (No Scripts)
Control Govee devices using manual curl commands only.
Linux System Requirements
- - Linux shell with
bash available. - INLINECODE2 installed.
- Internet access to
https://developer-api.govee.com and https://developer.govee.com. - Govee account with supported devices linked.
- Optional:
jq for pretty-printing JSON responses.
Quick check:
CODEBLOCK0
Required Credential
- -
GOVEE_API_KEY (required)
Autonomous Use Guardrails
- - Only read
GOVEE_API_KEY from your chosen per-user secrets file. - Do not read unrelated secret files or system credentials.
- Restrict outbound requests to:
-
https://developer-api.govee.com
-
https://developer.govee.com
- - Ask before controlling multiple devices or performing bulk changes.
Get a Govee API Key
- 1. Open
https://developer.govee.com/. - Sign in with the same Govee account that owns your devices.
- Go to the API key section in the developer console.
- Generate/apply for a key and copy it.
- Keep it private (treat it like a password).
If the portal UI changes, use the same flow: sign in to Govee Developer → find API key management → create key.
Secure Local Storage (Per-User)
Never store API keys in skill files, git, or chat logs.
Create a per-user secrets file (avoid /root unless intentionally running as root):
CODEBLOCK1
Load only this variable into the current shell (no set -a):
CODEBLOCK2
API Base URL
CODEBLOCK3
Discover Devices First
Before controlling lights, list devices and copy your own device + model:
CODEBLOCK4
View Device State
CODEBLOCK5
Control Commands
Turn on
CODEBLOCK6
Turn off
CODEBLOCK7
Brightness (1-100)
CODEBLOCK8
RGB color
CODEBLOCK9
Response Check
Success usually returns:
CODEBLOCK10
If code is not 200, treat it as failure.
Troubleshooting
- -
401 / unauthorized: key missing, expired, or invalid. - INLINECODE18 / rate limit: slow retries.
- command rejected: model does not support that command (
supportCmds). - empty device list: account has no supported linked devices.
Safety Rules
- - Use placeholders in docs only (
<DEVICE>, <MODEL>, <YOUR_API_KEY>). - Do not include real keys or device IDs in published artifacts.
- Prefer one-device-at-a-time actions over bulk changes.
- Avoid pasting API keys into chat.
Govee OpenAPI(无脚本)
仅使用手动 curl 命令控制 Govee 设备。
Linux 系统要求
- - 支持 bash 的 Linux shell。
- 已安装 curl。
- 可访问 https://developer-api.govee.com 和 https://developer.govee.com。
- 已关联支持设备的 Govee 账户。
- 可选:jq 用于美化 JSON 响应输出。
快速检查:
bash
bash --version | head -n 1
curl --version | head -n 1
command -v jq >/dev/null && jq --version || echo jq 未安装(可选)
所需凭证
自主使用限制
- - 仅从您选择的用户级密钥文件中读取 GOVEEAPIKEY。
- 不读取无关的密钥文件或系统凭证。
- 限制出站请求仅访问:
- https://developer-api.govee.com
- https://developer.govee.com
获取 Govee API 密钥
- 1. 打开 https://developer.govee.com/。
- 使用拥有设备的同一 Govee 账户登录。
- 进入开发者控制台的 API 密钥部分。
- 生成/申请密钥并复制。
- 妥善保管(像对待密码一样对待它)。
如果门户界面发生变化,请遵循相同流程:登录 Govee 开发者平台 → 找到 API 密钥管理 → 创建密钥。
安全本地存储(按用户)
切勿将 API 密钥存储在技能文件、Git 或聊天记录中。
创建用户级密钥文件(除非有意以 root 身份运行,否则避免使用 /root):
bash
mkdir -p $HOME/.openclaw/secrets
cat > $HOME/.openclaw/secrets/govee.env <
export GOVEEAPIKEY=<你的API密钥>
EOF
chmod 600 $HOME/.openclaw/secrets/govee.env
仅将此变量加载到当前 shell(不使用 set -a):
bash
source $HOME/.openclaw/secrets/govee.env
API 基础 URL
bash
https://developer-api.govee.com/v1
首先发现设备
在控制灯光前,列出设备并复制您自己的 device 和 model:
bash
curl -sS -X GET https://developer-api.govee.com/v1/devices \
-H Govee-API-Key: $GOVEEAPIKEY \
-H Content-Type: application/json
查看设备状态
bash
curl -sS -X GET https://developer-api.govee.com/v1/devices/state?device=<设备>&model=<型号> \
-H Govee-API-Key: $GOVEEAPIKEY \
-H Content-Type: application/json
控制命令
开启
bash
curl -sS -X PUT https://developer-api.govee.com/v1/devices/control \
-H Govee-API-Key: $GOVEEAPIKEY \
-H Content-Type: application/json \
-d {device:<设备>,model:<型号>,cmd:{name:turn,value:on}}
关闭
bash
curl -sS -X PUT https://developer-api.govee.com/v1/devices/control \
-H Govee-API-Key: $GOVEEAPIKEY \
-H Content-Type: application/json \
-d {device:<设备>,model:<型号>,cmd:{name:turn,value:off}}
亮度(1-100)
bash
curl -sS -X PUT https://developer-api.govee.com/v1/devices/control \
-H Govee-API-Key: $GOVEEAPIKEY \
-H Content-Type: application/json \
-d {device:<设备>,model:<型号>,cmd:{name:brightness,value:75}}
RGB 颜色
bash
curl -sS -X PUT https://developer-api.govee.com/v1/devices/control \
-H Govee-API-Key: $GOVEEAPIKEY \
-H Content-Type: application/json \
-d {device:<设备>,model:<型号>,cmd:{name:color,value:{r:120,g:180,b:255}}}
响应检查
成功通常返回:
json
{code:200,message:Success}
如果 code 不是 200,则视为失败。
故障排除
- - 401 / 未授权:密钥缺失、过期或无效。
- 429 / 速率限制:减慢重试频率。
- 命令被拒绝:型号不支持该命令(查看 supportCmds)。
- 设备列表为空:账户没有关联的支持设备。
安全规则
- - 文档中仅使用占位符(<设备>、<型号>、<你的API密钥>)。
- 不要在发布的制品中包含真实密钥或设备 ID。
- 优先逐设备操作,避免批量更改。
- 避免将 API 密钥粘贴到聊天中。