node-red-contrib-symi-modbus 2.5.4 → 2.6.1
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 +9 -4
- package/nodes/serial-port-config.js +15 -0
- package/package.json +1 -2
- package/RELEASE_CHECKLIST.md +0 -106
package/README.md
CHANGED
|
@@ -101,7 +101,7 @@ node-red-restart
|
|
|
101
101
|
1. 拖拽 **从站开关** 节点到流程画布
|
|
102
102
|
2. 选择刚创建的RS-485连接配置
|
|
103
103
|
3. 配置开关面板信息:
|
|
104
|
-
- 面板品牌:
|
|
104
|
+
- 面板品牌: `亖米` (默认)
|
|
105
105
|
- 开关ID: 物理面板地址 (0-255)
|
|
106
106
|
- 按钮编号: 按键编号 (1-8)
|
|
107
107
|
4. 配置映射到的继电器:
|
|
@@ -435,7 +435,7 @@ msg.payload = 1; // 或 0
|
|
|
435
435
|
|
|
436
436
|
## 项目信息
|
|
437
437
|
|
|
438
|
-
**版本**: v2.
|
|
438
|
+
**版本**: v2.6.1
|
|
439
439
|
|
|
440
440
|
**核心功能**:
|
|
441
441
|
- 支持多种Modbus协议(Telnet ASCII、RTU over TCP、Modbus TCP、Modbus RTU串口)
|
|
@@ -443,7 +443,7 @@ msg.payload = 1; // 或 0
|
|
|
443
443
|
- Symi私有协议自动识别(支持两种485开关控制方式)
|
|
444
444
|
- 智能轮询暂停机制(从站上报时自动暂停,处理完成后恢复)
|
|
445
445
|
- MQTT集成(Home Assistant自动发现,实体唯一性保证,QoS=0高性能发布)
|
|
446
|
-
-
|
|
446
|
+
- 物理开关面板双向同步(亖米协议支持,LED反馈同步)
|
|
447
447
|
- 共享连接架构(多个从站开关节点共享同一个串口/TCP连接,支持500+节点)
|
|
448
448
|
- 长期稳定运行(内存管理、自动重连、错误日志限流、异步MQTT发布)
|
|
449
449
|
|
|
@@ -454,7 +454,12 @@ msg.payload = 1; // 或 0
|
|
|
454
454
|
- Node.js: >=14.0.0
|
|
455
455
|
- Node-RED: >=2.0.0
|
|
456
456
|
|
|
457
|
-
**最新更新(v2.
|
|
457
|
+
**最新更新(v2.6.1)**:
|
|
458
|
+
- **串口自动重连**:断开后5秒自动重连,确保长期稳定运行
|
|
459
|
+
- **连接状态管理**:完善的串口和TCP连接状态监控
|
|
460
|
+
- **错误恢复**:串口拔插后自动恢复,无需重启Node-RED
|
|
461
|
+
|
|
462
|
+
**v2.6.0更新**:
|
|
458
463
|
- **双模式支持**:完整支持开关按钮和场景按钮两种模式
|
|
459
464
|
- 开关按钮:独立开/关控制 + SET协议LED反馈
|
|
460
465
|
- 场景按钮:Toggle切换控制 + REPORT协议LED反馈
|
|
@@ -25,6 +25,7 @@ module.exports = function(RED) {
|
|
|
25
25
|
// 共享的连接实例
|
|
26
26
|
node.connection = null; // TCP socket 或 SerialPort
|
|
27
27
|
node.isOpening = false; // 标记是否正在打开连接
|
|
28
|
+
node.isClosing = false; // 标记节点是否正在关闭
|
|
28
29
|
|
|
29
30
|
// 数据监听器列表(每个从站开关节点注册一个)
|
|
30
31
|
node.dataListeners = [];
|
|
@@ -131,6 +132,18 @@ module.exports = function(RED) {
|
|
|
131
132
|
// 监听关闭
|
|
132
133
|
node.connection.on('close', () => {
|
|
133
134
|
node.log('串口已关闭');
|
|
135
|
+
// 自动重连(如果还有监听器在使用)
|
|
136
|
+
setTimeout(() => {
|
|
137
|
+
if (node.dataListeners.length > 0 && !node.isClosing) {
|
|
138
|
+
node.log('检测到串口断开,5秒后尝试重新连接...');
|
|
139
|
+
node.openSerialConnection();
|
|
140
|
+
}
|
|
141
|
+
}, 5000);
|
|
142
|
+
});
|
|
143
|
+
|
|
144
|
+
// 监听断开连接
|
|
145
|
+
node.connection.on('disconnect', () => {
|
|
146
|
+
node.log('串口设备已拔出');
|
|
134
147
|
});
|
|
135
148
|
});
|
|
136
149
|
} catch (err) {
|
|
@@ -226,6 +239,8 @@ module.exports = function(RED) {
|
|
|
226
239
|
|
|
227
240
|
// 节点关闭时清理
|
|
228
241
|
node.on('close', function(done) {
|
|
242
|
+
node.isClosing = true; // 标记正在关闭,防止自动重连
|
|
243
|
+
|
|
229
244
|
// 清空所有监听器
|
|
230
245
|
node.dataListeners = [];
|
|
231
246
|
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "node-red-contrib-symi-modbus",
|
|
3
|
-
"version": "2.
|
|
3
|
+
"version": "2.6.1",
|
|
4
4
|
"description": "Node-RED Modbus节点,支持TCP/串口通信、串口自动搜索、多设备轮询、智能MQTT连接(自动fallback HassOS/Docker环境)、Home Assistant自动发现和物理开关面板双向同步,工控机长期稳定运行",
|
|
5
5
|
"main": "nodes/modbus-master.js",
|
|
6
6
|
"scripts": {
|
|
@@ -42,7 +42,6 @@
|
|
|
42
42
|
"dependencies": {
|
|
43
43
|
"modbus-serial": "^8.0.23",
|
|
44
44
|
"mqtt": "^5.14.1",
|
|
45
|
-
"node-red-contrib-symi-modbus": "file:node-red-contrib-symi-modbus-2.5.4.tgz",
|
|
46
45
|
"serialport": "^12.0.0"
|
|
47
46
|
},
|
|
48
47
|
"repository": {
|
package/RELEASE_CHECKLIST.md
DELETED
|
@@ -1,106 +0,0 @@
|
|
|
1
|
-
# 发布清单 - v2.5.4
|
|
2
|
-
|
|
3
|
-
## ✅ 已完成
|
|
4
|
-
|
|
5
|
-
### 核心功能
|
|
6
|
-
- [x] 开关模式:独立开/关控制 + SET协议LED反馈
|
|
7
|
-
- [x] 场景模式:Toggle切换控制 + REPORT协议LED反馈
|
|
8
|
-
- [x] 精确LED反馈:使用原始deviceAddr和channel
|
|
9
|
-
- [x] 完美状态同步:物理按键 + HA远程控制
|
|
10
|
-
- [x] 防抖机制:200ms全局防抖
|
|
11
|
-
- [x] 防死循环:100ms状态变化检测
|
|
12
|
-
- [x] Fallback机制:HA远程控制自动计算参数
|
|
13
|
-
|
|
14
|
-
### 文档
|
|
15
|
-
- [x] README.md:完整的用户文档
|
|
16
|
-
- [x] TECHNICAL_DESIGN.md:内部技术文档(已排除打包)
|
|
17
|
-
- [x] 两种模式详细对比表格
|
|
18
|
-
- [x] 配置说明和使用示例
|
|
19
|
-
|
|
20
|
-
### 测试验证
|
|
21
|
-
- [x] 开关模式物理按键测试
|
|
22
|
-
- [x] 开关模式HA远程控制测试
|
|
23
|
-
- [x] 场景模式物理按键测试
|
|
24
|
-
- [x] 场景模式HA远程控制测试
|
|
25
|
-
- [x] LED同步测试(所有场景)
|
|
26
|
-
- [x] 长期稳定性验证
|
|
27
|
-
|
|
28
|
-
### 打包部署
|
|
29
|
-
- [x] npm pack成功
|
|
30
|
-
- [x] 本地Node-RED安装测试
|
|
31
|
-
- [x] TECHNICAL_DESIGN.md已排除
|
|
32
|
-
- [x] 包大小:43.4 KB
|
|
33
|
-
- [x] 文件数:15个
|
|
34
|
-
|
|
35
|
-
## 🚀 发布到npm
|
|
36
|
-
|
|
37
|
-
### 发布命令
|
|
38
|
-
```bash
|
|
39
|
-
cd /Volumes/攀旺/cursor/node-red-contrib-symi-modbus
|
|
40
|
-
npm publish node-red-contrib-symi-modbus-2.5.4.tgz
|
|
41
|
-
```
|
|
42
|
-
|
|
43
|
-
### 或者使用账号发布
|
|
44
|
-
```bash
|
|
45
|
-
npm login --registry=https://registry.npmjs.org/
|
|
46
|
-
# 用户名: symi-daguo
|
|
47
|
-
npm publish
|
|
48
|
-
```
|
|
49
|
-
|
|
50
|
-
## 📋 版本信息
|
|
51
|
-
|
|
52
|
-
- **版本号**: 2.5.4
|
|
53
|
-
- **包名**: node-red-contrib-symi-modbus
|
|
54
|
-
- **作者**: symi-daguo
|
|
55
|
-
- **许可证**: MIT
|
|
56
|
-
- **Node.js**: >= 14.0.0
|
|
57
|
-
- **Node-RED**: >= 2.0.0
|
|
58
|
-
|
|
59
|
-
## 🎯 核心亮点
|
|
60
|
-
|
|
61
|
-
1. **双模式完美支持**
|
|
62
|
-
- 开关模式:SET协议 + 独立开/关
|
|
63
|
-
- 场景模式:REPORT协议 + Toggle切换
|
|
64
|
-
|
|
65
|
-
2. **精确LED反馈**
|
|
66
|
-
- 使用原始设备地址
|
|
67
|
-
- Fallback计算参数
|
|
68
|
-
- 100%准确率
|
|
69
|
-
|
|
70
|
-
3. **完美状态同步**
|
|
71
|
-
- 物理按键 ✓
|
|
72
|
-
- HA远程控制 ✓
|
|
73
|
-
- 双向实时同步
|
|
74
|
-
|
|
75
|
-
4. **企业级稳定性**
|
|
76
|
-
- 防抖机制
|
|
77
|
-
- 防死循环
|
|
78
|
-
- 内存管理
|
|
79
|
-
- 7x24小时验证
|
|
80
|
-
|
|
81
|
-
## 📊 性能指标
|
|
82
|
-
|
|
83
|
-
- 支持节点:500+
|
|
84
|
-
- 响应延迟:<100ms
|
|
85
|
-
- 内存占用:<50MB
|
|
86
|
-
- CPU占用:<5%
|
|
87
|
-
- 稳定运行:7x24小时
|
|
88
|
-
|
|
89
|
-
## ⚠️ 注意事项
|
|
90
|
-
|
|
91
|
-
1. TECHNICAL_DESIGN.md仅供内部使用,不会打包到npm
|
|
92
|
-
2. 确保.npmignore正确配置
|
|
93
|
-
3. 发布前确认version号正确
|
|
94
|
-
4. 发布后验证npm页面更新
|
|
95
|
-
|
|
96
|
-
## 📝 发布后任务
|
|
97
|
-
|
|
98
|
-
- [ ] 验证npm包可以正常安装
|
|
99
|
-
- [ ] 检查npm页面显示正确
|
|
100
|
-
- [ ] 更新GitHub Release(如果有)
|
|
101
|
-
- [ ] 通知用户更新
|
|
102
|
-
|
|
103
|
-
---
|
|
104
|
-
**准备发布**: ✅ 所有检查通过,可以发布!
|
|
105
|
-
**发布时间**: 2024-10-30
|
|
106
|
-
**发布者**: symi-daguo
|