You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

寻求Google Nest Hub Gen2通知REST API以集成谷歌日历动态提醒

实现谷歌日历与Google Nest Hub Gen2的动态通知集成

目前Google Home官方没有提供直接的REST API来创建基于谷歌日历的动态通知,但可以通过以下几种间接方案实现需求:

方案1:Google Apps Script + Home Graph API

利用Google Apps Script访问谷歌日历API,结合Home Graph API给Nest Hub发送广播通知:

  1. 准备工作

    • 在Google Cloud Console启用Calendar API和Home Graph API
    • 获取Nest Hub的设备ID(可通过Google Home App的设备详情页查看,或调用Home Graph API的设备列表接口获取)
    • 生成OAuth访问令牌(用于调用Home Graph API)
  2. 编写Apps Script脚本

function checkUpcomingEvents() {
  // 替换为你的日历ID
  const calendarId = "your-calendar-id@group.calendar.google.com";
  // 提前通知的分钟数
  const alertOffset = 15;
  const now = new Date();
  const alertTime = new Date(now.getTime() + alertOffset * 60000);

  // 获取即将到来的日历事件
  const events = Calendar.Events.list(calendarId, {
    timeMin: now.toISOString(),
    timeMax: alertTime.toISOString(),
    singleEvents: true,
    orderBy: "startTime"
  });

  if (events.items.length === 0) return;

  events.items.forEach(event => {
    const eventName = event.summary;
    const message = `提醒:${eventName}将在${alertOffset}分钟后开始`;
    
    // 调用Home Graph API发送广播
    const requestOptions = {
      method: "POST",
      headers: {
        "Authorization": "Bearer YOUR_OAUTH_ACCESS_TOKEN",
        "Content-Type": "application/json"
      },
      payload: JSON.stringify({
        requestId: `cal-alert-${Date.now()}`,
        inputs: [{
          intent: "action.devices.commands.Broadcast",
          payload: { message }
        }],
        devices: [{ id: "your-nest-hub-device-id" }]
      })
    };

    UrlFetchApp.fetch("https://homegraph.googleapis.com/v1/devices:execute", requestOptions);
  });
}
  1. 设置定时触发器
    • 在Apps Script编辑器中,点击左侧"触发器"图标
    • 创建新触发器,选择checkUpcomingEvents函数,设置触发频率为"每分钟"(或根据需求调整)

方案2:IFTTT自动化

通过IFTTT的无代码配置实现日历事件触发Nest Hub通知:

  • 创建新的IFTTT Applet,选择触发器为Google Calendar的"Event starts in X minutes"(设置提前通知时间)
  • 选择动作为Google Assistant的"Broadcast a message",输入包含事件变量的通知内容(比如{{Title}}会自动替换为日历事件标题)
  • 指定目标设备为你的Nest Hub Gen2

方案3:Home Assistant中间层

用Home Assistant集成日历和Nest设备,通过自动化规则实现动态通知:

  • 在Home Assistant中添加Google Calendar集成和Google Nest集成
  • 创建自动化规则:
    • 触发条件:选择"日历事件即将开始",设置提前通知时间
    • 动作:调用"Nest设备发送通知"服务,输入自定义消息内容

内容的提问来源于stack exchange,提问作者Akash Zalke

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.06.29 14:42:57