node-red-contrib-symi-modbus 2.8.6 → 2.8.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 +15 -15
- package/nodes/modbus-master.js +6 -0
- package/nodes/serial-port-config.js +13 -30
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -63,11 +63,11 @@ node-red-restart
|
|
|
63
63
|
3. **无需连线**:主站和从站通过内部事件自动通信
|
|
64
64
|
|
|
65
65
|
**优势**:
|
|
66
|
-
-
|
|
67
|
-
-
|
|
68
|
-
-
|
|
69
|
-
-
|
|
70
|
-
-
|
|
66
|
+
- 断网也能稳定运行
|
|
67
|
+
- 不依赖外部服务
|
|
68
|
+
- 响应速度更快
|
|
69
|
+
- 配置更简单
|
|
70
|
+
- 无需手动连线(免连线通信)
|
|
71
71
|
|
|
72
72
|
#### 模式2:MQTT模式(推荐用于Home Assistant集成)
|
|
73
73
|
|
|
@@ -85,9 +85,9 @@ node-red-restart
|
|
|
85
85
|
- 基础主题: `modbus/relay` (默认)
|
|
86
86
|
|
|
87
87
|
**优势**:
|
|
88
|
-
-
|
|
89
|
-
-
|
|
90
|
-
-
|
|
88
|
+
- Home Assistant自动发现
|
|
89
|
+
- 支持远程控制
|
|
90
|
+
- 状态持久化存储
|
|
91
91
|
|
|
92
92
|
### 3. 配置主站节点
|
|
93
93
|
|
|
@@ -199,12 +199,12 @@ node-red-restart
|
|
|
199
199
|
- 继电器状态变化会自动反馈到Mesh开关LED
|
|
200
200
|
|
|
201
201
|
**Mesh模式特点**:
|
|
202
|
-
-
|
|
203
|
-
-
|
|
204
|
-
-
|
|
205
|
-
-
|
|
206
|
-
-
|
|
207
|
-
-
|
|
202
|
+
- 无线控制,无需布线
|
|
203
|
+
- 支持1-6路开关
|
|
204
|
+
- 双向同步(按键→继电器,继电器→LED)
|
|
205
|
+
- 设备列表持久化保存
|
|
206
|
+
- 短地址自动更新(如果网关重新配网)
|
|
207
|
+
- 与RS-485开关使用方式完全一致
|
|
208
208
|
|
|
209
209
|
### 6. 配置HomeKit网桥节点(可选)
|
|
210
210
|
|
|
@@ -884,7 +884,7 @@ HomeKit网桥节点无需输入消息,自动同步主站配置和状态。
|
|
|
884
884
|
|
|
885
885
|
## 版本信息
|
|
886
886
|
|
|
887
|
-
**当前版本**: v2.8.
|
|
887
|
+
**当前版本**: v2.8.7 (2025-11-12)
|
|
888
888
|
|
|
889
889
|
**核心特性**:
|
|
890
890
|
- 支持Modbus RTU/TCP协议,兼容标准Modbus设备和TCP转RS485网关
|
package/nodes/modbus-master.js
CHANGED
|
@@ -1539,6 +1539,12 @@ module.exports = function(RED) {
|
|
|
1539
1539
|
node.cleanupTimer = null;
|
|
1540
1540
|
}
|
|
1541
1541
|
|
|
1542
|
+
// 清除MQTT命令队列定时器
|
|
1543
|
+
if (node.mqttCommandTimer) {
|
|
1544
|
+
clearTimeout(node.mqttCommandTimer);
|
|
1545
|
+
node.mqttCommandTimer = null;
|
|
1546
|
+
}
|
|
1547
|
+
|
|
1542
1548
|
// 发布离线状态到MQTT(让HA知道设备离线)
|
|
1543
1549
|
if (node.config.enableMqtt && node.mqttClient && node.mqttClient.connected) {
|
|
1544
1550
|
node.publishOfflineStatus();
|
|
@@ -169,13 +169,21 @@ module.exports = function(RED) {
|
|
|
169
169
|
|
|
170
170
|
// 打开串口连接
|
|
171
171
|
node.openSerialConnection = function() {
|
|
172
|
+
// 如果串口已经打开,直接返回(不要关闭重开)
|
|
172
173
|
if (node.connection && node.connection.isOpen) {
|
|
173
|
-
node.
|
|
174
|
+
node.debug('串口已打开,跳过重复打开');
|
|
174
175
|
return;
|
|
175
176
|
}
|
|
176
177
|
|
|
178
|
+
// 如果正在打开中,跳过
|
|
177
179
|
if (node.isOpening) {
|
|
178
|
-
node.
|
|
180
|
+
node.debug('串口正在打开中,跳过重复打开');
|
|
181
|
+
return;
|
|
182
|
+
}
|
|
183
|
+
|
|
184
|
+
// 如果节点正在关闭,不要打开
|
|
185
|
+
if (node.isClosing) {
|
|
186
|
+
node.debug('节点正在关闭,取消串口打开操作');
|
|
179
187
|
return;
|
|
180
188
|
}
|
|
181
189
|
|
|
@@ -185,33 +193,8 @@ module.exports = function(RED) {
|
|
|
185
193
|
node.reconnectTimer = null;
|
|
186
194
|
}
|
|
187
195
|
|
|
188
|
-
//
|
|
189
|
-
|
|
190
|
-
if (node.connection) {
|
|
191
|
-
try {
|
|
192
|
-
node.connection.removeAllListeners();
|
|
193
|
-
if (node.connection.isOpen) {
|
|
194
|
-
node.connection.close((closeErr) => {
|
|
195
|
-
if (closeErr) {
|
|
196
|
-
node.debug(`串口关闭时出错: ${closeErr.message}`);
|
|
197
|
-
}
|
|
198
|
-
});
|
|
199
|
-
}
|
|
200
|
-
} catch (err) {
|
|
201
|
-
// 忽略清理错误
|
|
202
|
-
}
|
|
203
|
-
node.connection = null;
|
|
204
|
-
}
|
|
205
|
-
|
|
206
|
-
// 如果之前串口是打开的,等待500ms让系统完全释放资源
|
|
207
|
-
const openDelay = needDelay ? 500 : 0;
|
|
208
|
-
|
|
209
|
-
setTimeout(() => {
|
|
210
|
-
// 检查节点是否正在关闭
|
|
211
|
-
if (node.isClosing) {
|
|
212
|
-
node.debug('节点正在关闭,取消串口打开操作');
|
|
213
|
-
return;
|
|
214
|
-
}
|
|
196
|
+
// 只有在连接不存在或已关闭时才创建新连接
|
|
197
|
+
if (!node.connection || !node.connection.isOpen) {
|
|
215
198
|
|
|
216
199
|
node.isOpening = true;
|
|
217
200
|
|
|
@@ -340,7 +323,7 @@ module.exports = function(RED) {
|
|
|
340
323
|
}, delay);
|
|
341
324
|
}
|
|
342
325
|
}
|
|
343
|
-
}
|
|
326
|
+
} // 关闭 if (!node.connection || !node.connection.isOpen)
|
|
344
327
|
};
|
|
345
328
|
|
|
346
329
|
// 获取连接对象(用于Mesh设备发现等场景)
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "node-red-contrib-symi-modbus",
|
|
3
|
-
"version": "2.8.
|
|
3
|
+
"version": "2.8.8",
|
|
4
4
|
"description": "Node-RED Modbus节点,支持TCP/串口通信、串口自动搜索、多设备轮询、可选MQTT集成(支持纯本地模式和MQTT模式)、Home Assistant自动发现、HomeKit网桥、可视化控制看板、自定义协议转换和物理开关面板双向同步,工控机长期稳定运行",
|
|
5
5
|
"main": "nodes/modbus-master.js",
|
|
6
6
|
"scripts": {
|