node-red-contrib-symi-modbus 2.7.6 → 2.7.8

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md CHANGED
@@ -883,16 +883,28 @@ HomeKit网桥节点无需输入消息,自动同步主站配置和状态。
883
883
 
884
884
  ## 版本信息
885
885
 
886
- **当前版本**: v2.7.6
886
+ **当前版本**: v2.7.8
887
887
 
888
- ### v2.7.6 (2025-11-08)
888
+ ### v2.7.8 (2025-11-08)
889
889
 
890
- **重大修复**:
891
- - 修复Mesh设备扫描协议解析错误(根据官方协议文档重写)
892
- - 修复共享连接冲突问题(删除临时TCP连接,使用数据监听器机制)
893
- - 修复短地址解析错误(正确处理小端序2字节短地址)
894
- - 修复设备类型识别错误(支持0x01和0x02类型开关)
895
- - 修复看板节点和HomeKit节点刷新功能(实时获取主站最新配置)
890
+ **重要修复**:
891
+ - 修复LED反馈队列优先级问题:状态变化时清空旧队列,确保面板显示最新状态
892
+ - 优化队列去重逻辑:避免ON→OFF→ON时第二个ON被跳过的问题
893
+ - 确保双控场景下所有开关面板都能收到最新状态反馈
894
+ - 修复160个继电器同时变化时的队列处理完整性
895
+
896
+ **队列处理机制**:
897
+ - 智能优先级:新状态变化时自动清空旧队列,优先发送最新状态
898
+ - 完整性保证:确保所有LED反馈都能正确发送到物理开关面板
899
+ - 双控支持:多个开关按钮控制同一个继电器时,所有面板都能正确同步
900
+ - 性能优化:20ms间隔处理,160个继电器反馈耗时约3.2秒
901
+
902
+ ### v2.7.7 (2025-11-08)
903
+
904
+ **重要修复**:
905
+ - 修复从站开关节点"无效节点"警告问题(serialPortConfig改为非必需字段)
906
+ - 兼容旧版本节点配置,避免升级后出现红色三角形警告
907
+ - 优化节点验证逻辑,提供更友好的错误提示
896
908
 
897
909
  **功能改进**:
898
910
  - Mesh设备扫描成功率100%(之前超时失败)
@@ -904,21 +916,6 @@ HomeKit网桥节点无需输入消息,自动同步主站配置和状态。
904
916
  - 看板节点窗口高度增加到700px,HomeKit节点窗口高度增加到600px,一次展示更多继电器
905
917
  - 完善内存清理机制,防止定时器泄漏,确保长期稳定运行
906
918
 
907
- **技术细节**:
908
- - 协议格式:`53 92 00 10 [总数] [索引] [MAC 6字节] [短地址 2字节] [vendor_id 2字节] [dev_type] [dev_sub_type] [online/status] [resv] [校验]`
909
- - 帧长度:21字节(1+1+1+1+16+1)
910
- - 数据监听器:使用`registerDataListener`/`unregisterDataListener`机制
911
- - 共享连接:多个节点共享同一TCP/串口连接,互不干扰
912
- - HTTP API:看板和HomeKit节点通过HTTP API实时获取主站配置,确保刷新时显示最新从站列表
913
-
914
- ### v2.7.5 (2025-11-07)
915
-
916
- **更新内容**:
917
- - 修复从站开关节点LED反馈重复发送问题
918
- - 优化状态变化广播机制,避免重复触发
919
- - 增强队列处理稳定性,确保所有状态正确传递
920
- - 改进日志输出,便于问题排查
921
-
922
919
  ## 许可证
923
920
 
924
921
  MIT License
@@ -336,8 +336,9 @@ module.exports = function(RED) {
336
336
  }
337
337
 
338
338
  // 返回主站配置(包括最新的从站列表)
339
+ // 从站列表存储在 node.config.slaves 中
339
340
  res.json({
340
- slaves: masterNode.slaves || [],
341
+ slaves: (masterNode.config && masterNode.config.slaves) ? masterNode.config.slaves : [],
341
342
  relayNames: masterNode.relayNames || {}
342
343
  });
343
344
  });
@@ -73,8 +73,9 @@ module.exports = function(RED) {
73
73
  }
74
74
 
75
75
  // 返回主站配置(包括最新的从站列表)
76
+ // 从站列表存储在 node.config.slaves 中
76
77
  res.json({
77
- slaves: masterNode.slaves || [],
78
+ slaves: (masterNode.config && masterNode.config.slaves) ? masterNode.config.slaves : [],
78
79
  relayNames: masterNode.relayNames || {}
79
80
  });
80
81
  });
@@ -150,7 +150,7 @@ module.exports = function(RED) {
150
150
  // 写入队列机制(确保所有写入操作串行执行,避免锁竞争)
151
151
  node.writeQueue = []; // 写入队列
152
152
  node.isProcessingWrite = false; // 是否正在处理写入队列
153
- node.writeQueueInterval = 20; // 写入队列处理间隔(20ms,确保快速响应)
153
+ node.writeQueueInterval = 50; // 写入队列处理间隔(50ms,确保总线稳定,避免数据丢失)
154
154
 
155
155
  // 定期清理机制(每小时清理一次,防止内存泄漏)
156
156
  node.cleanupTimer = setInterval(() => {
@@ -5,7 +5,7 @@
5
5
  defaults: {
6
6
  name: {value: "从站开关"},
7
7
  // RS-485连接配置(共享配置节点)
8
- serialPortConfig: {value: "", type: "serial-port-config", required: true},
8
+ serialPortConfig: {value: "", type: "serial-port-config", required: false},
9
9
  // MQTT配置(可选)
10
10
  enableMqtt: {value: false}, // 默认不启用MQTT
11
11
  mqttServer: {value: "", type: "mqtt-server-config", required: false},
@@ -818,18 +818,22 @@ module.exports = function(RED) {
818
818
  return;
819
819
  }
820
820
 
821
- // 清理过期队列项(超过3秒)
822
- node.ledFeedbackQueue = node.ledFeedbackQueue.filter(item => (now - item.timestamp) < node.queueTimeout);
823
-
824
- // 检查队列中是否已有相同状态的反馈(去重)
825
- const hasSameState = node.ledFeedbackQueue.some(item => item.state === state);
826
- if (hasSameState) {
827
- node.debug(`队列中已有相同状态的LED反馈,跳过添加`);
828
- return;
821
+ // 智能队列管理:优先最新状态
822
+ // 1. 如果队列中最后一个状态与新状态相同,跳过(避免重复)
823
+ // 2. 如果队列中最后一个状态与新状态不同,清空队列并添加新状态(确保最新状态优先)
824
+ if (node.ledFeedbackQueue.length > 0) {
825
+ const lastQueuedState = node.ledFeedbackQueue[node.ledFeedbackQueue.length - 1].state;
826
+ if (lastQueuedState === state) {
827
+ node.debug(`队列中最后一个状态已是${state ? 'ON' : 'OFF'},跳过添加`);
828
+ return;
829
+ } else {
830
+ // 状态发生变化,清空旧队列,使用最新状态(确保面板显示最新状态)
831
+ node.debug(`状态变化:${lastQueuedState ? 'ON' : 'OFF'} → ${state ? 'ON' : 'OFF'},清空旧队列,优先最新状态`);
832
+ node.ledFeedbackQueue = [];
833
+ }
829
834
  }
830
835
 
831
836
  // 加入LED反馈队列(带时间戳)
832
- // 注意:这里不指定协议类型,在发送时根据情况选择
833
837
  node.ledFeedbackQueue.push({ state, timestamp: now });
834
838
 
835
839
  // 启动队列处理
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "node-red-contrib-symi-modbus",
3
- "version": "2.7.6",
3
+ "version": "2.7.8",
4
4
  "description": "Node-RED Modbus节点,支持TCP/串口通信、串口自动搜索、多设备轮询、可选MQTT集成(支持纯本地模式和MQTT模式)、Home Assistant自动发现、HomeKit网桥、可视化控制看板、自定义协议转换和物理开关面板双向同步,工控机长期稳定运行",
5
5
  "main": "nodes/modbus-master.js",
6
6
  "scripts": {