node-red-contrib-symi-modbus 2.9.2 → 2.9.3

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
@@ -888,7 +888,16 @@ HomeKit网桥节点无需输入消息,自动同步主站配置和状态。
888
888
 
889
889
  ## 版本信息
890
890
 
891
- **当前版本**: v2.9.2 (2025-12-15)
891
+ **当前版本**: v2.9.3 (2025-12-15)
892
+
893
+ **v2.9.3 更新内容**:
894
+ - **重要修复**:场景按钮LED反馈不同步问题
895
+ - 修复场景按钮帧使用特殊通道(如0x0F)导致LED反馈失效的问题
896
+ - 场景模式保持使用配置计算的按键通道,不被帧中的特殊标识覆盖
897
+ - 解决"部署后场景按钮可以同步一次,点击其他开关后不再同步"的问题
898
+ - **优化**:场景按钮匹配逻辑
899
+ - 增加场景模式帧的特殊匹配:通道0x0F或isSceneMode标识
900
+ - 同一面板的场景按钮现在能正确识别和处理
892
901
 
893
902
  **v2.9.2 更新内容**:
894
903
  - **稳定性增强**:全局防抖缓存定期清理机制
@@ -903,23 +912,6 @@ HomeKit网桥节点无需输入消息,自动同步主站配置和状态。
903
912
  - 确认所有连接资源正确释放
904
913
  - 支持断电断网后自动恢复运行
905
914
 
906
- **v2.9.1 更新内容**:
907
- - **重要修复**:RS-485开关指示灯同步问题
908
- - 修复TCP粘包导致的协议帧解析失败问题
909
- - 新增`parseAllFrames`函数,正确处理多个帧粘在一起的情况
910
- - 根据协议的`dataLen`字段精确提取帧边界,确保每个帧都被正确解析
911
- - **重要修复**:Modbus控制看板部署失效问题
912
- - 修复主站更新后重新部署导致看板无法正确显示的问题
913
- - 部署时自动清空并重新初始化状态缓存
914
- - 新增`refresh` API,点击刷新按钮从主站获取真实继电器状态
915
- - **优化**:控制看板刷新功能
916
- - 刷新按钮现在会主动从主站获取最新的继电器状态
917
- - 确保显示的状态与实际继电器状态同步
918
- - **优化**:指示灯反馈队列间隔调整为50ms
919
- - TCP/串口写入间隔从40ms调整为50ms
920
- - 触发源面板优先处理,确保按键响应流畅
921
- - 按线圈顺序陆续反馈所有有动作的继电器指示灯
922
-
923
915
  **核心特性**:
924
916
  - 支持Modbus RTU/TCP协议,兼容标准Modbus设备和TCP转RS485网关
925
917
  - 支持Symi RS-485开关和蓝牙Mesh开关,实现双向状态同步
@@ -795,16 +795,26 @@ module.exports = function(RED) {
795
795
  // 检查是否是我们监听的开关面板和按钮
796
796
  // switchId对应本地地址(物理面板地址)
797
797
  // buttonNumber对应实际按键编号(1-8)
798
- if (buttonEvent.raw.localAddr === node.config.switchId && actualButtonNumber === node.config.buttonNumber) {
799
- // 保存原始的deviceAddr和channel,用于LED反馈
800
- const oldDeviceAddr = node.buttonDeviceAddr;
801
- const oldChannel = node.buttonChannel;
802
- node.buttonDeviceAddr = buttonEvent.deviceAddr;
803
- node.buttonChannel = buttonEvent.channel;
804
-
805
- // 输出调试日志,对比计算值和实际值
806
- if (oldDeviceAddr !== buttonEvent.deviceAddr || oldChannel !== buttonEvent.channel) {
807
- node.log(`按键事件更新LED反馈地址:计算值(设备${oldDeviceAddr} 通道${oldChannel}) → 实际值(设备${buttonEvent.deviceAddr} 通道${buttonEvent.channel})`);
798
+ //
799
+ // 重要:场景按钮的帧通道可能是特殊标识(如0x0F),而不是实际按键通道
800
+ // 因此需要额外判断:如果是场景模式且localAddr匹配,也应该处理
801
+ const isSceneModeFrame = buttonEvent.isSceneMode || buttonEvent.channel === 0x0F;
802
+ const isMatchedByButtonNumber = (buttonEvent.raw.localAddr === node.config.switchId && actualButtonNumber === node.config.buttonNumber);
803
+ const isMatchedBySceneMode = (buttonEvent.raw.localAddr === node.config.switchId && node.config.buttonType === 'scene' && isSceneModeFrame);
804
+
805
+ if (isMatchedByButtonNumber || isMatchedBySceneMode) {
806
+ // 只有开关模式才更新deviceAddrchannel为实际值
807
+ // 场景模式保持使用配置计算的值,因为场景帧的通道(如0x0F)是特殊标识,不是LED反馈通道
808
+ if (!isSceneModeFrame && node.config.buttonType !== 'scene') {
809
+ const oldDeviceAddr = node.buttonDeviceAddr;
810
+ const oldChannel = node.buttonChannel;
811
+ node.buttonDeviceAddr = buttonEvent.deviceAddr;
812
+ node.buttonChannel = buttonEvent.channel;
813
+
814
+ // 输出调试日志,对比计算值和实际值
815
+ if (oldDeviceAddr !== buttonEvent.deviceAddr || oldChannel !== buttonEvent.channel) {
816
+ node.log(`按键事件更新LED反馈地址:计算值(设备${oldDeviceAddr} 通道${oldChannel}) → 实际值(设备${buttonEvent.deviceAddr} 通道${buttonEvent.channel})`);
817
+ }
808
818
  }
809
819
 
810
820
  // 判断按钮类型:优先使用协议解析结果,其次使用配置
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "node-red-contrib-symi-modbus",
3
- "version": "2.9.2",
3
+ "version": "2.9.3",
4
4
  "description": "Node-RED Modbus节点,支持TCP/串口通信、串口自动搜索、多设备轮询、可选MQTT集成(支持纯本地模式和MQTT模式)、Home Assistant自动发现、HomeKit网桥、可视化控制看板、自定义协议转换和物理开关面板双向同步,工控机长期稳定运行",
5
5
  "main": "nodes/modbus-master.js",
6
6
  "scripts": {