网淘吧来吧,欢迎您!

Google Home/Nest

2026-03-31 新闻来源:网淘吧 围观:13
电脑广告
手机广告

Google Home / Nest CLI

使用 curl + jq 通过智能设备管理 (SDM) API 控制 Google Nest 设备。

设置(必需步骤)

  1. 创建 Google Cloud 项目

    Google Home/Nest

  2. 启用 SDM API

    • API 和服务 → 库
    • 搜索 "智能设备管理"
    • 启用它
  3. 创建 OAuth 凭据

    • API 和服务 → 凭据
    • 创建 OAuth 2.0 客户端 ID
    • 下载 JSON 文件
    • 提取client_idclient_secret
  4. 注册您的设备

  5. 获取访问令牌

    # Replace with your values
    curl -s \
      -d "client_id=YOUR_CLIENT_ID" \
      -d "client_secret=YOUR_CLIENT_SECRET" \
      -d "refresh_token=YOUR_REFRESH_TOKEN" \
      -d "grant_type=refresh_token" \
      https://www.googleapis.com/oauth2/v4/token
    

快速开始

# List devices
google-home-cli devices

# Get thermostat info
google-home-cli thermostat "Living Room" --info

# Set temperature (heat/cool/auto)
google-home-cli thermostat "Living Room" --temp 72

# Query camera
google-home-cli camera "Front Door" --status

设备命令

恒温器

  • google-home-cli thermostat <名称>— 显示当前温度/湿度
  • --temp <度数>— 设置目标温度
  • --mode 加热|制冷|自动— 设置HVAC模式
  • --fan 开启|自动— 控制风扇

摄像头与门铃

  • google-home-cli camera <名称>— 获取流/状态
  • --snapshot— 下载当前图像
  • --stream— 启动实时流URL

扬声器与显示屏

  • google-home-cli speaker <名称>— 设备信息
  • --volume 0-100— 设置音量
  • --停止— 停止播放

环境变量

export GOOGLE_HOME_CLIENT_ID="your-client-id"
export GOOGLE_HOME_CLIENT_SECRET="your-client-secret"
export GOOGLE_HOME_ACCESS_TOKEN="your-access-token"

替代方案:直接API调用

# List all devices
curl -s -H "Authorization: Bearer $ACCESS_TOKEN" \
  "https://smartdevicemanagement.googleapis.com/v1/enterprises/YOUR_PROJECT_ID/devices"

# Get device traits
curl -s -H "Authorization: Bearer $ACCESS_TOKEN" \
  "https://smartdevicemanagement.googleapis.com/v1/enterprises/YOUR_PROJECT_ID/devices/YOUR_DEVICE_ID"

辅助脚本

AnestCLI辅助工具位于scripts/nest

# Make it available globally
ln -sf /Users/mitchellbernstein/clawd/skills/google-home/scripts/nest /usr/local/bin/nest

# List devices
nest list

# Get thermostat status
nest status "enterprises/PROJECT_ID/devices/DEVICE_ID"

# Set temperature (Celsius)
nest temp "enterprises/PROJECT_ID/devices/DEVICE_ID" 22

# Set mode
nest mode "enterprises/PROJECT_ID/devices/DEVICE_ID" HEAT

配置

创建~/.config/google-home/config.json

{
  "project_id": "your-google-cloud-project-id",
  "access_token": "your-oauth-access-token"
}

注意事项

  • 令牌会过期;请定期刷新
  • 设备名称使用完整路径:enterprises/PROJECT_ID/devices/DEVICE_ID
  • 温度单位为摄氏度(如需请从华氏度转换)
  • 摄像头流需要额外权限

免责申明
部分文章来自各大搜索引擎,如有侵权,请与我联系删除。
打赏
文章底部电脑广告
手机广告位-内容正文底部
上一篇:App Builder 下一篇:Endurance Coach

相关文章

您是本站第349277名访客 今日有175篇新文章/评论