Echobell

Home Assistant 集成 - 智能家居自动化警报和 IoT 通知

将 Echobell 与 Home Assistant 集成以获取智能家居即时通知的完整指南。设置安防系统、温度传感器、运动检测、门锁和自动化触发器的 Webhook 警报,支持推送通知或电话提醒。

Home Assistant 集成

Home Assistant是一个强大的开源家庭自动化平台,注重本地控制和隐私保护。通过将 Echobell 与 Home Assistant 集成,您可以在智能家居发生重要事件时立即收到通知或电话,例如安全警报、温度阈值超标或自动化触发器。

本指南将介绍如何使用 Webhook 或 RESTful 通知服务设置 Home Assistant 自动化,向您的 Echobell 通知频道发送通知。

前提条件

在开始之前,请确保您具备:

  • iOS 设备上已安装Echobell 应用
  • 有效的 Echobell 频道(如果没有,请在应用中创建)
  • 正在运行的 Home Assistant 实例(建议 2023.1 或更高版本)
  • 访问 Home Assistant 配置的权限

方法一:使用 Webhook 触发器(推荐)

使用 Webhook 方法是最灵活的方式,允许您发送自定义数据并在通知中使用模板变量

获取Echobell Webhook URL

  1. 打开 Echobell 应用并导航到您的频道
  2. 点击您的频道查看详情
  3. 在 Triggers 部分找到 Webhook URL
  4. 复制 URL,格式类似:https://hook.echobell.one/t/YOUR_TOKEN

创建 Home Assistant 自动化

在 Home Assistant 中,您可以使用rest_command服务触发 Echobell 通知。首先,在configuration.yaml中添加 REST 命令:

rest_command:
  echobell_notify:
    url: "https://hook.echobell.one/t/YOUR_TOKEN"
    method: POST
    content_type: "application/json"
    payload: '{"title": "{{ title }}", "message": "{{ message }}"}'

YOUR_TOKEN替换为您实际的 Echobell Webhook 令牌。

添加后,重启 Home Assistant 以加载新配置。

在自动化中使用

现在您可以从任何自动化中调用此服务。以下是门被打开时发送通知的示例:

automation:
  - alias: "Door Open Alert"
    trigger:
      - platform: state
        entity_id: binary_sensor.front_door
        to: "on"
    action:
      - service: rest_command.echobell_notify
        data:
          title: "安全警报"
          message: "前门于 {{ now().strftime('%H:%M') }} 被打开"

配置通知模板

在 Echobell 频道设置中,配置通知模板以显示 Webhook 数据:

  • 标题模板{{title}}
  • 内容模板{{message}}

这确保了当自动化触发时,您将收到包含自定义标题和消息的通知。

方法二:使用 RESTful 通知平台

如需更紧密的集成,您可以将 Echobell 配置为 Home Assistant 的通知服务。

配置

configuration.yaml中添加:

notify:
  - name: echobell
    platform: rest
    resource: https://hook.echobell.one/t/YOUR_TOKEN
    method: POST_JSON
    data:
      title: "{{ title }}"
      message: "{{ message }}"

YOUR_TOKEN替换为您的 Echobell Webhook 令牌并重启 Home Assistant。

使用通知服务

现在您可以像使用其他通知服务一样使用 Echobell:

automation:
  - alias: "Low Battery Alert"
    trigger:
      - platform: numeric_state
        entity_id: sensor.phone_battery
        below: 20
    action:
      - service: notify.echobell
        data:
          title: "电量不足警告"
          message: "手机电量仅剩 {{ states('sensor.phone_battery') }}%"

下一步

Echobell 与 Home Assistant 集成成功后:

相关资源