node-red-contrib-symi-modbus 2.7.7 → 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,7 +883,21 @@ HomeKit网桥节点无需输入消息,自动同步主站配置和状态。
883
883
 
884
884
  ## 版本信息
885
885
 
886
- **当前版本**: v2.7.7
886
+ **当前版本**: v2.7.8
887
+
888
+ ### v2.7.8 (2025-11-08)
889
+
890
+ **重要修复**:
891
+ - 修复LED反馈队列优先级问题:状态变化时清空旧队列,确保面板显示最新状态
892
+ - 优化队列去重逻辑:避免ON→OFF→ON时第二个ON被跳过的问题
893
+ - 确保双控场景下所有开关面板都能收到最新状态反馈
894
+ - 修复160个继电器同时变化时的队列处理完整性
895
+
896
+ **队列处理机制**:
897
+ - 智能优先级:新状态变化时自动清空旧队列,优先发送最新状态
898
+ - 完整性保证:确保所有LED反馈都能正确发送到物理开关面板
899
+ - 双控支持:多个开关按钮控制同一个继电器时,所有面板都能正确同步
900
+ - 性能优化:20ms间隔处理,160个继电器反馈耗时约3.2秒
887
901
 
888
902
  ### v2.7.7 (2025-11-08)
889
903
 
@@ -892,10 +906,6 @@ HomeKit网桥节点无需输入消息,自动同步主站配置和状态。
892
906
  - 兼容旧版本节点配置,避免升级后出现红色三角形警告
893
907
  - 优化节点验证逻辑,提供更友好的错误提示
894
908
 
895
- **说明**:
896
- - 如果您的从站开关节点显示红色三角形警告,请双击节点重新选择RS-485连接配置并保存
897
- - 升级到v2.7.7后,所有节点将正常工作,不再显示"无效节点"警告
898
-
899
909
  **功能改进**:
900
910
  - Mesh设备扫描成功率100%(之前超时失败)
901
911
  - 与symi-gateway节点完美共存(不再冲突)
@@ -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(() => {
@@ -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.7",
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": {