node-red-contrib-symi-modbus 2.9.4 → 2.9.5

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,14 @@ HomeKit网桥节点无需输入消息,自动同步主站配置和状态。
888
888
 
889
889
  ## 版本信息
890
890
 
891
- **当前版本**: v2.9.4 (2025-12-15)
891
+ **当前版本**: v2.9.5 (2025-12-15)
892
+
893
+ **v2.9.5 更新内容**:
894
+ - **重要修复**:重启Node-RED时设备自动动作问题
895
+ - 修复重启后继电器会自动动作一次的bug
896
+ - 问题根因:首次轮询(source='init')时modbus-slave-switch向下游发送状态消息,触发下游节点执行控制命令
897
+ - 解决方案:首次轮询时只同步内部状态和LED反馈,不发送消息到下游节点
898
+ - 现在重启Node-RED不会导致任何继电器动作,只会同步指示灯状态
892
899
 
893
900
  **v2.9.4 更新内容**:
894
901
  - **重要修复**:场景按钮LED反馈不同步问题
@@ -730,8 +730,10 @@ module.exports = function(RED) {
730
730
  // 检查状态是否真正变化
731
731
  const stateChanged = (node.currentState !== value);
732
732
 
733
- // 区分触发源:按键触发时LED反馈已在handleRs485Data中发送
733
+ // 区分触发源
734
734
  const isButtonPress = (triggerSource === 'button-press' || triggerSource === 'scene-trigger');
735
+ const isInit = (data.source === 'init'); // 首次轮询
736
+ const isPolling = (data.source === 'polling'); // 轮询变化
735
737
 
736
738
  // 更新当前状态
737
739
  node.currentState = value;
@@ -747,14 +749,22 @@ module.exports = function(RED) {
747
749
  // 更新节点状态显示
748
750
  node.updateStatus();
749
751
 
750
- // 输出状态消息
752
+ // 首次轮询时只同步内部状态和LED反馈,不发送消息到下游
753
+ // 避免重启Node-RED时触发下游节点导致继电器动作
754
+ if (isInit) {
755
+ node.debug(`首次轮询状态同步:从站${slave} 线圈${coil} = ${value ? 'ON' : 'OFF'}(不发送到下游)`);
756
+ return;
757
+ }
758
+
759
+ // 输出状态消息(仅在非首次轮询时发送)
751
760
  node.send({
752
761
  payload: value,
753
762
  topic: `switch_${node.config.switchId}_btn${node.config.buttonNumber}`,
754
763
  switchId: node.config.switchId,
755
764
  button: node.config.buttonNumber,
756
765
  targetSlave: node.config.targetSlaveAddress,
757
- targetCoil: node.config.targetCoilNumber
766
+ targetCoil: node.config.targetCoilNumber,
767
+ source: isPolling ? 'polling' : triggerSource // 传递触发源
758
768
  });
759
769
  }
760
770
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "node-red-contrib-symi-modbus",
3
- "version": "2.9.4",
3
+ "version": "2.9.5",
4
4
  "description": "Node-RED Modbus节点,支持TCP/串口通信、串口自动搜索、多设备轮询、可选MQTT集成(支持纯本地模式和MQTT模式)、Home Assistant自动发现、HomeKit网桥、可视化控制看板、自定义协议转换和物理开关面板双向同步,工控机长期稳定运行",
5
5
  "main": "nodes/modbus-master.js",
6
6
  "scripts": {