Skip to content

90001-wecom-alarm-90001 平台能力对接文档

能力简介

Source file does not provide it

项目
项目名称wecom-alarm-90001
厂商Source file does not provide it
型号wecom-alarm-90001
业务代码90001
对接模式Source file does not provide it
协议Source file does not provide it

模型清单

可使用下列名称或 ID 在 ThinkLink 中搜索对应模型。

模型类型名称id_name平台模型 ID
ThinkLink Model[WECOM NOTIFY] 90001wecom_notify_90001109185132828454912

产品特点与适用范围

本项目面向“notification”场景。能力边界、字段和可部署模型均以当前 descriptor、requirements 与模型源文件为准。

部署与采集信息

| DTU | Not applicable | | 供电 | Source file does not provide it | | LoRaWAN Class | Source file does not provide it | | 接口 | Source file does not provide it | | 波特率 | Not applicable |

遥测与寄存器定义

源文件未提供独立遥测字段表;请以模型清单中的当前物模型为准。

参数定义

无项目专用参数定义。

Requirements 证据

以下关键事实由 requirements 源文件提取;原始行号用于复核。

类别来源事实来源
协议/数据- Webhook URL 必须配置在平台 系统管理 → 服务器配置 → 组织参数,Key = wecom_webhook_url,Value = 完整 webhook 地址(含 key= 部分)requirement/requirements.md:43
协议/数据- 建议每季度通过企业微信群机器人设置"重置 webhook 地址"轮换;轮换后同步更新组织参数 valuerequirement/requirements.md:47
协议/数据| type | action(无 thing model,无寄存器读写) |requirement/requirements.md:59

物模型与 RPC 代码

id_name: wecom_notify_90001 · ID: 109185132828454912

javascript
// wecom_notify_90001 — 企业微信群机器人告警推送 RPC
//
// 与平台内置 ALARM RPC 同构入参 (name/action/title/level/desc),
// 触发模型可一份 params 同时喂给 alarm 与 wecom_notify。
//
// webhook URL 由平台 "系统管理 → 服务器配置 → 组织参数" 中的
// wecom_webhook_url 提供,仅组织管理员可见。脚本本身不持密钥。
//
// 参考: $THINKLINK_DOCS_ROOT/docs/zh/AN/WeComAlertIntegration.md §3.4 (= tkl-docs/claude/docs/zh/AN/...)

function rpc_script({ device, params, alarms, logger, org_params }) {
    let webhook = org_params?.wecom_webhook_url;
    if (!webhook) {
        logger.error("wecom_webhook_url not configured in org_params");
        return null;
    }

    let name   = params.name;
    let action = params.action;
    let title  = params.title || name || "";
    let level  = params.level || "mid";
    let desc   = params.desc  || "";

    if (action === "clear") {
        // 仅当该 alarm_name 当前处于活跃状态时才推送恢复通知,
        // 避免条件持续正常的情况下,每次上行都触发一条 clear 消息
        if (!alarms || alarms[name] === undefined) {
            return null;
        }
    } else if (action !== "new") {
        return null;
    }

    let levelColor = {
        urgent: "warning",
        high:   "warning",
        mid:    "comment",
        low:    "info"
    }[level] || "info";

    let header = action === "new" ? "### 设备告警" : "### 告警恢复";

    let content = [
        header,
        "> **设备名称**:" + device.name,
        "> **设备 EUI**:`" + device.eui + "`",
        "> **告警事件**:`" + name + "`",
        "> **告警标题**:" + title,
        "> **告警等级**:<font color=\"" + levelColor + "\">" + level.toUpperCase() + "</font>",
        "> **" + (action === "new" ? "告警内容" : "恢复说明") + "**:" + (desc || "无"),
        "> **时间**:" + new Date().toLocaleString("zh-CN", { timeZone: "Asia/Shanghai" })
    ].join("\n");

    return [
        {
            sleepTimeMs: 0,
            type: "axios",
            dnMsg: {
                method: "POST",
                url: webhook,
                headers: { "Content-Type": "application/json" },
                data: {
                    msgtype: "markdown",
                    markdown: { content: content }
                },
                timeout: 5000
            }
        }
    ];
}

// === 本地调试 ===
// 模拟一次 "new" 告警调用 (运行 node wecom_notify_90001.js 查看输出结构)
const testResult = rpc_script({
    device: { name: "测试温度计-01", eui: "0011223344556677" },
    params: {
        name:   "overheat_alarm",
        action: "new",
        title:  "过热告警: [测试温度计-01]",
        level:  "high",
        desc:   "温度 78℃,超过阈值 60℃"
    },
    alarms: {},
    org_params: { wecom_webhook_url: "https://qyapi.weixin.qq.com/cgi-bin/webhook/send?key=test-key" },
    logger: console
});
console.log(JSON.stringify(testResult, null, 2));

物模型字段定义

模型未提供 telemetry_config 字段表。

RPC 参数定义

无 RPC 入参模板。

触发器定义

无项目专用触发器。

第三方平台数据订阅

MQTT Topic: /v32/{Organization Account}/tkl/up/telemetry/{eui}

json
{
  "eui": "6353012af10a9331",
  "active_time": "2026-07-13T08:35:48.000Z",
  "thingModelId": "Use the platform model ID from the model inventory",
  "thingModelIdName": "Use the current telemetry model id_name",
  "telemetry_data": {
    "snr": 13.5,
    "rssi": -51,
    "battery": 3.37
  }
}

模板选择与验证

在 ThinkLink 平台按项目名称、业务代码或模型清单中的 id_name、ID 搜索并绑定模型。部署后使用真实上行帧核对字段、单位、RPC 和触发器行为。

补充说明

需求与决策依据:requirement/requirements.md