Home Assistant 将通知消息发送到企业微信

学习笔记作者:admin日期:2025-06-05点击:41

摘要:通过企业微信群机器人或自建应用,将 Home Assistant 的通知消息发送至企业微信。

Home Assistant 发送通知到企业微信

      本文介绍了如何在 Home Assistant 中通过企业微信(WeCom)的群机器人或自建应用发送通知。

方法一:使用群机器人

      1. 获取企业微信群机器人的 Webhook 地址。

https://qyapi.weixin.qq.com/cgi-bin/webhook/send?key=你的key

      2. 配置 Home Assistant:

notify:
  - name: wecom_bot
    platform: webhook
    webhook_endpoint: wecom_notify

      3. 配置自动化发送消息:

- alias: "发送消息到企业微信群机器人"
  trigger:
    - platform: event
      event_type: homeassistant_start
  action:
    - service: notify.wecom_bot
      data:
        message: "Hello, 企业微信!Home Assistant 已启动。"
        data:
          webhook_url: "https://qyapi.weixin.qq.com/cgi-bin/webhook/send?key=你的key"

方法二:使用自建应用

      1. 获取企业微信的 CorpID 和 Secret。

notify:
  - name: enterprise_wechat_notify
    platform: enterprise_wechat
    corp_id: "你的 CorpID"
    secret: "你的 Secret"
    agent_id: "你的 AgentId"
    to_user: "UserID1|UserID2"

      2. 使用自动化发送消息:

- service: notify.enterprise_wechat_notify
  data:
    message: "检测到异常温度!"
    title: "警报通知"

关键词

      Home Assistant, 企业微信, 群机器人, 自建应用, Webhook

上一篇      下一篇