AgentSkillsCN

iot-sensor-anomaly-detector

当用户需要通过对比实时IoT传感器数据与预设的运行参数范围,识别异常的传感器读数时,此技能会从BigQuery中查询时间序列传感器数据,从Excel配置文件中加载参数范围,执行范围验证,并以CSV格式生成异常报告,其中包含时间戳、机器ID、传感器类型、读数以及正常范围等字段。触发条件包括IoT传感器数据分析、异常检测、运行参数验证、工厂监控、BigQuery传感器查询、Excel配置文件处理以及CSV报告生成。

SKILL.md
--- frontmatter
name: iot-sensor-anomaly-detector
description: When the user needs to identify abnormal sensor readings by comparing real-time IoT sensor data against predefined operating parameter ranges. This skill queries time-series sensor data from BigQuery, loads parameter ranges from Excel configuration files, performs range validation, and generates anomaly reports in CSV format with timestamp, machine_id, sensor_type, reading, and normal_range fields. Triggers include IoT sensor data analysis, anomaly detection, operating parameter validation, factory monitoring, BigQuery sensor queries, Excel configuration file processing, and CSV report generation.

Instructions

Overview

This skill identifies sensor readings that fall outside predefined normal operating ranges. It queries time-series sensor data from BigQuery, compares readings against parameter ranges defined in an Excel configuration file, and generates a CSV anomaly report.

Core Workflow

1. Initial Setup & Discovery

  • Locate the Excel configuration file: Search for machine_operating_parameters.xlsx in the workspace.
  • Verify BigQuery dataset: Confirm the machine_operating dataset exists.
  • Identify Cloud Storage bucket: Find the bucket with prefix iot_anomaly_reports for report upload.

2. Data Acquisition

  • Read parameter ranges: Load the "Operating Parameters" sheet from the Excel file. Extract machine_id, sensor_type, min_value, and max_value columns.
  • Query sensor data: Execute a BigQuery query to retrieve sensor readings (timestamp, machine_id, sensor_type, reading) for the specified time range.

3. Data Processing & Anomaly Detection

  • Merge datasets: Join sensor data with parameter ranges using machine_id and sensor_type as keys.
  • Identify anomalies: Flag readings where reading < min_value OR reading > max_value.
  • Format output: Create normal_range column as "min - max" string.

4. Report Generation & Delivery

  • Create CSV report: Generate anomaly_report.csv with columns: timestamp, machine_id, sensor_type, reading, normal_range.
  • Save locally: Store the report in the workspace.
  • Upload to Cloud Storage: Transfer the report to the identified iot_anomaly_reports bucket.

5. Cleanup

  • Remove any temporary files or tables created during processing.

Key Requirements

  • Timestamp format: Preserve the exact timestamp format from BigQuery (e.g., 2025-08-19 11:33:59.878906+00).
  • Error handling: Gracefully handle missing sheets in Excel, unmatched sensor-parameter pairs, and data type mismatches.
  • Efficiency: Process potentially large datasets efficiently using appropriate data structures.

Common Variations

  • Different time ranges: The skill should adapt to user-specified start/end times.
  • Alternative file locations: The Excel file may be in different directories.
  • Multiple sensor types: The skill handles various sensor types defined in the configuration.

Output

The primary output is anomaly_report.csv containing all readings outside normal ranges, sorted by timestamp.