Home Assistant 接入 Echobell:为智能家居添加即时告警

通过 REST 命令和 Webhook 将 Home Assistant 连接到 Echobell,为安防事件、温度告警和自动化触发获取分级推送通知或来电提醒。

Home Assistant 接入 Echobell:为智能家居添加即时告警

Home Assistant 内置的手机通知会和其他所有通知混在一起。Echobell 增加了优先级分层——普通推送、时间敏感,或真实来电——让关键的智能家居事件不再被淹没。集成无需自定义组件:只需一个 REST 命令和你的 Webhook URL。

基础配置

  1. 下载 Echobell 并创建频道(如"家庭告警")
  2. 从频道设置中复制 Webhook URL
  3. configuration.yaml 中添加 REST 命令:
rest_command:
  echobell_home:
    url: "https://hook.echobell.one/t/YOUR_TOKEN"
    method: POST
    content_type: "application/json"
    payload: '{"title": "{{ title }}", "message": "{{ message }}"}'
  1. 重启 Home Assistant
  2. 在任意自动化中调用该服务

用一个简单的门磁传感器自动化测试:

automation:
  - alias: "Door Open Test"
    trigger:
      - platform: state
        entity_id: binary_sensor.front_door
        to: "on"
    action:
      - service: rest_command.echobell_home
        data:
          title: "Front Door"
          message: "Door opened at {{ now().strftime('%H:%M') }}"

实用自动化示例

温度监控来电告警

对于保护食品、设备或人身安全的传感器——将 Echobell 频道类型设置为来电,让它像电话一样响铃:

automation:
  - alias: "Freezer Temperature Alert"
    trigger:
      - platform: numeric_state
        entity_id: sensor.freezer_temperature
        above: -10
        for:
          minutes: 15
    action:
      - service: rest_command.echobell_home
        data:
          title: "⚠️ Freezer Temperature Alert"
          message: "Freezer is at {{ states('sensor.freezer_temperature') }}°C for 15+ minutes"
          severity: "critical"

智能安防告警

通过 Webhook 传入上下文变量,再用 Echobell 条件 在频道侧进行过滤:

automation:
  - alias: "Smart Security Alert"
    trigger:
      - platform: state
        entity_id:
          - binary_sensor.motion_living_room
          - binary_sensor.motion_bedroom
        to: "on"
    action:
      - service: rest_command.echobell_home
        data:
          title: "Security Event"
          message: "{{ trigger.to_state.attributes.friendly_name }} detected motion"
          alarm_state: "{{ states('alarm_control_panel.home_alarm') }}"
          hour: "{{ now().hour }}"

频道条件:alarm_state == "armed_away" || (hour >= 22 || hour <= 7)

仅在布防状态或夜间时段发送告警——过滤掉白天的运动噪音,无需禁用自动化。

家电完成提醒

automation:
  - alias: "Laundry Done"
    trigger:
      - platform: state
        entity_id: sensor.washer_power
        to: "0"
        for:
          minutes: 3
    action:
      - service: rest_command.echobell_home
        data:
          title: "🧺 Laundry Complete"
          message: "Washing machine finished. Don't let it sit!"

早晨日报

automation:
  - alias: "Morning Home Report"
    trigger:
      - platform: time
        at: "08:00:00"
    action:
      - service: rest_command.echobell_home
        data:
          title: "Good Morning - Home Status"
          message: >
            Temperature: {{ states('sensor.living_room_temperature') }}°C
            Humidity: {{ states('sensor.living_room_humidity') }}%
            Energy yesterday: {{ states('sensor.daily_energy') }} kWh
            All windows: {% if is_state('binary_sensor.window_group', 'off') %}Closed{% else %}OPEN{% endif %}

进阶功能

附加上下文链接

externalLink 变量可在 Echobell 的通知历史中添加可点击的链接:

action:
  - service: rest_command.echobell_home
    data:
      title: "Motion at Front Door"
      message: "Check the camera feed"
      externalLink: "https://my-home-assistant.duckdns.org/lovelace/security"

多频道策略

使用不同通知类型的独立频道:

  1. 家庭日常(普通):家电、每日日报
  2. 家庭监控(时间敏感):温度、湿度、能耗峰值
  3. 家庭安防(来电):布防状态下的运动、门窗传感器、严重故障

保护 Webhook URL

使用 Home Assistant 密钥存储,避免 Webhook URL 暴露在配置文件中:

# secrets.yaml
echobell_webhook: "https://hook.echobell.one/t/YOUR_TOKEN"

# configuration.yaml
rest_command:
  echobell_home:
    url: !secret echobell_webhook

包含高级模板和故障排查的完整技术文档,请参见 Home Assistant 集成指南。其他集成请参考 GitHub Actions 通知Grafana 监控告警