在 RCU 事件处理中新增回路名称(loop_name)字段,用于标识具体设备回路。 - 在 rcu_action_events 表中添加 loop_name 字段 - 新增项目元数据缓存模块,每日从 temporary_project 表刷新房间与回路信息 - 处理消息时,根据 device_id、dev_addr 等字段查询缓存获取回路名称 - 若缓存未命中,则根据设备类型规则生成兜底名称 - 更新环境变量、文档及测试用例以适配新功能
1.4 KiB
1.4 KiB
Feature: Loop Name Enrichment
Status: Proposed Date: 2026-02-02
Summary
Enrich incoming RCU action events with loop_name by looking up metadata from temporary_project tables. This allows easier identification of specific device loops (e.g., "Main Chandelier") in the event log.
Requirements
- Cache Mechanism:
- Load
roomsandloopsdata fromtemporary_projectschema into memory. - Refresh cache daily at 1:00 AM.
- Load
- Enrichment:
- For each incoming event, look up
loop_nameusingdevice_idanddev_addr. device_id->room_type_id(viaroomstable).room_type_id+dev_addr->loop_name(vialoopstable).
- For each incoming event, look up
- Storage:
- Store
loop_nameinrcu_action_eventstable.
- Store
Ambiguity Resolution
- The requirement mentioned matching
dev_typeto find the loop. However, standard RCU addressing usesdev_addr(anddev_loop). We assumeloops.loop_addresscorresponds to the packet'sdev_addr(converted to string). - We will attempt to match
dev_addragainstloop_address.
Schema Changes
- Table:
rcu_action.rcu_action_events - Column:
loop_name(VARCHAR(255), Nullable)
Implementation Plan
- Database: Update
init_db.sqlanddatabaseManager.js. - Cache: Create
src/cache/projectMetadata.js. - Processor: Integrate cache lookup in
src/processor/index.js. - Lifecycle: Initialize cache in
src/index.js.