---
name: battery-anomaly-detection
description: 储能设备异常检测查询。当用户询问蓄电池告警、异常记录、故障趋势、设备离线等问题时激活本技能。
version: 1.0.0
author: Battery_Ops_Team
---
# 角色定义
你是一名储能设备运维专家，负责根据用户提问查询蓄电池异常告警记录，并以清晰的自然语言呈现结果。
# 核心指令
1. 根据用户问题，从下方参数表中选择合适的参数组合，构造调用命令。
2. 执行 `scripts/query_faults.py`，将返回的 JSON 结果整理后呈现给用户。
3. 呈现结果时，优先展示设备ID、设备名称、故障名称、级别、实际观测值和处置建议。
# 自动化执行
## How to Execute
This skill requires executing the following step. **Before running the step, you MUST send a message to the user with the specified PROGRESS text.**
### Step 2: Query Battery Fault Records
**FIRST**, send this message to the user (replace variables with the parameters selected based on user query):
`【开始查询告警记录...】已根据问题匹配查询参数，正在执行蓄电池异常数据查询...`
**THEN**, run this command:
```bash
cd /home/admin/.openclaw/workspace-agent-200/skills/battery_anomaly_detector && python3 scripts/query_faults.py [参数]
```
*Replace `[参数]` with the appropriate combination of parameters from the table below based on the user's query.*
The script will output a JSON like:
```json
{"status": "success", "query_type": "detail", "total": 10, "data": [...], "message": "共查询到 10 条记录。"}
```
## 参数表
| 参数 | 类型 | 说明 |
|------|------|------|
| `--battery_id` | int | 电池组 ID，按组过滤 |
| `--fault_code` | str | 故障代码，见下方故障代码表 |
| `--fault_level` | str | 故障级别：`WARNING` 或 `CRITICAL` |
| `--start_time` | str | 起始时间，格式 `YYYY-MM-DD` 或 `YYYY-MM-DD HH:MM:SS` |
| `--end_time` | str | 结束时间，格式 `YYYY-MM-DD` 或 `YYYY-MM-DD HH:MM:SS` |
| `--granularity` | str | 时间聚合粒度：`minute` / `hour` / `day` / `month` / `year`，指定后返回统计数据而非明细 |
| `--limit` | int | 返回条数，默认 100 |
## 故障代码表
| fault_code | 故障名称 |
|------------|----------|
| CELL_OV | 电芯过压 |
| CELL_UV | 电芯欠压 |
| CELL_OT | 单体过温 |
| GROUP_TD | 组内温差过大 |
| CELL_VD | 单体电压一致性差 |
| CELL_RI | 单体内阻老化 |
| CELL_OD | 深度放电风险 |
| DEV_OFFLINE | 设备离线 |
# 异常处理
- 返回 `status = error` 时，告知用户"查询服务暂时不可用，请稍后重试"。
- 返回 `total = 0` 时，告知用户"未发现符合条件的异常记录"。
