node-red-contrib-padavan 1.0.1 → 2.0.0
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 +60 -237
- package/dist/nodes/config.html +44 -0
- package/dist/nodes/config.js +1 -0
- package/dist/nodes/devices.html +14 -0
- package/dist/nodes/devices.js +1 -0
- package/dist/nodes/history.html +14 -0
- package/dist/nodes/history.js +1 -0
- package/dist/nodes/locales/en-US/config.html +21 -0
- package/dist/nodes/locales/en-US/config.json +22 -0
- package/dist/nodes/locales/en-US/devices.html +30 -0
- package/dist/nodes/locales/en-US/devices.json +11 -0
- package/dist/nodes/locales/en-US/history.html +24 -0
- package/dist/nodes/locales/en-US/history.json +11 -0
- package/dist/nodes/locales/en-US/params.html +30 -0
- package/dist/nodes/locales/en-US/params.json +26 -0
- package/dist/nodes/locales/en-US/system.html +25 -0
- package/dist/nodes/locales/en-US/system.json +20 -0
- package/dist/nodes/locales/en-US/upgrade.html +21 -0
- package/dist/nodes/locales/en-US/upgrade.json +17 -0
- package/dist/nodes/locales/ru/config.html +22 -0
- package/dist/nodes/locales/ru/config.json +22 -0
- package/dist/nodes/locales/ru/devices.html +29 -0
- package/dist/nodes/locales/ru/devices.json +11 -0
- package/dist/nodes/locales/ru/history.html +25 -0
- package/dist/nodes/locales/ru/history.json +11 -0
- package/dist/nodes/locales/ru/params.html +31 -0
- package/dist/nodes/locales/ru/params.json +26 -0
- package/dist/nodes/locales/ru/system.html +25 -0
- package/dist/nodes/locales/ru/system.json +20 -0
- package/dist/nodes/locales/ru/upgrade.html +21 -0
- package/dist/nodes/locales/ru/upgrade.json +17 -0
- package/dist/nodes/params.html +51 -0
- package/dist/nodes/params.js +1 -0
- package/dist/nodes/system.html +24 -0
- package/dist/nodes/system.js +1 -0
- package/dist/nodes/upgrade.html +19 -0
- package/dist/nodes/upgrade.js +1 -0
- package/package.json +45 -29
- package/LICENSE +0 -21
- package/main.mjs +0 -301
- package/nodes/config.html +0 -71
- package/nodes/config.js +0 -19
- package/nodes/devices.html +0 -27
- package/nodes/devices.js +0 -27
- package/nodes/history.html +0 -27
- package/nodes/history.js +0 -32
- package/nodes/locales/en-US/config.html +0 -12
- package/nodes/locales/en-US/devices.html +0 -19
- package/nodes/locales/en-US/history.html +0 -25
- package/nodes/locales/en-US/params.html +0 -39
- package/nodes/locales/en-US/speedtest.html +0 -24
- package/nodes/locales/en-US/system.html +0 -79
- package/nodes/locales/en-US/upgrade.html +0 -33
- package/nodes/locales/ru/config.html +0 -12
- package/nodes/locales/ru/devices.html +0 -19
- package/nodes/locales/ru/history.html +0 -25
- package/nodes/locales/ru/params.html +0 -39
- package/nodes/locales/ru/speedtest.html +0 -24
- package/nodes/locales/ru/system.html +0 -79
- package/nodes/locales/ru/upgrade.html +0 -33
- package/nodes/params.html +0 -60
- package/nodes/params.js +0 -35
- package/nodes/speedtest.html +0 -28
- package/nodes/speedtest.js +0 -66
- package/nodes/system.html +0 -43
- package/nodes/system.js +0 -30
- package/nodes/upgrade.html +0 -43
- package/nodes/upgrade.js +0 -47
- package/services/speedtest.sh +0 -25
package/README.md
CHANGED
|
@@ -1,265 +1,88 @@
|
|
|
1
|
-
|
|
1
|
+
# node-red-contrib-padavan
|
|
2
2
|
|
|
3
|
+
[[RU]](./docs/ru/README.md) | [EN]
|
|
3
4
|
|
|
4
|
-
|
|
5
|
+
A set of [Node-RED](https://nodered.org/) nodes for managing routers running
|
|
6
|
+
**Padavan** firmware.
|
|
5
7
|
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
## Nodes
|
|
12
|
-
|
|
13
|
-
- [Configuration](#configuration)
|
|
14
|
-
- [SpeedTest](#speedtest)
|
|
15
|
-
- [Devices](#devices)
|
|
16
|
-
- [History](#history)
|
|
17
|
-
- [Updates](#updates)
|
|
18
|
-
- [Status](#status)
|
|
19
|
-
- [Parameters](#parameters)
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
## Configuration
|
|
24
|
-
|
|
25
|
-
### Input
|
|
26
|
-
|
|
27
|
-
| credentials | Description
|
|
28
|
-
| --- | ---
|
|
29
|
-
| *`repo`* | Repository where firmware builds are hosted
|
|
30
|
-
| *`branch`* | Branch for the device
|
|
31
|
-
| *`token`* | Access token for GitHub
|
|
32
|
-
| `host` | Router IP address
|
|
33
|
-
| `username` | Username for router access
|
|
34
|
-
| `password` | Password for router access
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
## SpeedTest
|
|
38
|
-
|
|
39
|
-
Measure download and upload speeds
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
### Output
|
|
43
|
-
|
|
44
|
-
| outputs | Description
|
|
45
|
-
| --- | ---
|
|
46
|
-
| `result` | Result
|
|
47
|
-
| `history` | Result with date and timestamp
|
|
48
|
-
| `progress` | Test start and end
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
| result.msg | type | Value
|
|
52
|
-
| --- | --- | ---
|
|
53
|
-
| `topic` | string | NetworkControl
|
|
54
|
-
| `payload` | object |
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
| payload | Description
|
|
58
|
-
| --- | ---
|
|
59
|
-
| `networkDownloadSpeedMbps`| Download speed
|
|
60
|
-
| `networkUploadSpeedMbps` | Upload speed
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
## Devices
|
|
64
|
-
|
|
65
|
-
Get the list of connected devices
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
### Output
|
|
69
|
-
|
|
70
|
-
| msg | type
|
|
71
|
-
| --- | ---
|
|
72
|
-
| `payload` | array
|
|
73
|
-
| `numConnectedDevices` | integer
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
| payload |
|
|
77
|
-
| --- |
|
|
78
|
-
| `hostname` |
|
|
79
|
-
| `ip` |
|
|
80
|
-
| `mac` |
|
|
81
|
-
| `rssi` |
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
## History
|
|
85
|
-
|
|
86
|
-
Retrieve traffic history
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
### Output
|
|
90
|
-
|
|
91
|
-
| msg | type
|
|
92
|
-
| --- | ---
|
|
93
|
-
| `payload` | object
|
|
94
|
-
| `networkUsage` | string
|
|
95
|
-
| `networkUsageMB` | integer
|
|
8
|
+
This package uses the `padavan` library to interact with the router via its
|
|
9
|
+
web interface (HTTP). It provides tools for monitoring, configuration,
|
|
10
|
+
diagnostics, and firmware management.
|
|
96
11
|
|
|
12
|
+
## Features
|
|
97
13
|
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
14
|
+
- **Full Control**: Manage NVRAM settings, services, and power state via
|
|
15
|
+
HTTP.
|
|
16
|
+
- **Monitoring**: Get real-time traffic history (daily/monthly) and system
|
|
17
|
+
status (CPU/RAM/Uptime).
|
|
18
|
+
- **Device Tracking**: Retrieve connected clients with smart filtering for
|
|
19
|
+
"ghost" connections (ARP caching).
|
|
20
|
+
- **Diagnostics**: Built-in Wi-Fi Scanner and **"Wi-Fi Doctor"** for
|
|
21
|
+
analyzing interference and finding the best channel.
|
|
22
|
+
- **Firmware Management**: Check for updates, trigger builds in GitHub
|
|
23
|
+
Actions, and flash the router directly from Node-RED.
|
|
102
24
|
|
|
25
|
+
## Installation
|
|
103
26
|
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
| `0` | Year, month, day
|
|
107
|
-
| `1` | Download
|
|
108
|
-
| `2` | Upload
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
## Updates
|
|
112
|
-
|
|
113
|
-
Manage firmware updates
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
### Input
|
|
117
|
-
|
|
118
|
-
| msg | type
|
|
119
|
-
| --- | ---
|
|
120
|
-
| `topic` | string
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
| topic | Description
|
|
124
|
-
| --- | ---
|
|
125
|
-
| *`build`* | Build firmware
|
|
126
|
-
| *`changelog`* | List of changes
|
|
127
|
-
| *`upgrade`* | Install firmware
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
### Output
|
|
131
|
-
|
|
132
|
-
| msg | type | Value
|
|
133
|
-
| --- | --- | ---
|
|
134
|
-
| `topic` | string | changelog
|
|
135
|
-
| `error` | string |
|
|
136
|
-
| `payload` | object |
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
| payload | Description
|
|
140
|
-
| --- | ---
|
|
141
|
-
| `from_id` | Current firmware
|
|
142
|
-
| `to_id` | Built firmware
|
|
143
|
-
| `data` | Array of changes
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
## Status
|
|
147
|
-
|
|
148
|
-
Retrieve and manage router status
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
### Input
|
|
152
|
-
|
|
153
|
-
| msg | type
|
|
154
|
-
| --- | ---
|
|
155
|
-
| `topic` | string
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
| topic | Description
|
|
159
|
-
| --- | ---
|
|
160
|
-
| *`status`* | Get current status
|
|
161
|
-
| *`log`* | Get logs
|
|
162
|
-
| *`reboot`* | Reboot
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
### Output
|
|
166
|
-
|
|
167
|
-
| msg | type | Value
|
|
168
|
-
| --- | --- | ---
|
|
169
|
-
| `topic` | string | status
|
|
170
|
-
| `payload` | object |
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
| payload | Description
|
|
174
|
-
| --- | ---
|
|
175
|
-
| `lavg` | System load average over the last 1, 5, and 15 minutes
|
|
176
|
-
| `uptime` | Router uptime
|
|
177
|
-
| `ram` | RAM usage information
|
|
178
|
-
| `swap` | Swap memory status
|
|
179
|
-
| `cpu` | CPU load information
|
|
180
|
-
| `wifi2` | Wi-Fi status on the 2.4 GHz band
|
|
181
|
-
| `wifi5` | Wi-Fi status on the 5 GHz band
|
|
182
|
-
| `logmt` | Timestamp of the last log modification
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
| uptime |
|
|
186
|
-
| --- |
|
|
187
|
-
| `days` |
|
|
188
|
-
| `hours` |
|
|
189
|
-
| `minutes` |
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
| ram | Description
|
|
193
|
-
| --- | ---
|
|
194
|
-
| `total` | Total RAM (in KB)
|
|
195
|
-
| `used` | Used RAM
|
|
196
|
-
| `free` | Free RAM
|
|
197
|
-
| `buffers` | RAM used for buffers
|
|
198
|
-
| `cached` | RAM used for cache
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
| swap |
|
|
202
|
-
| --- |
|
|
203
|
-
| `total` |
|
|
204
|
-
| `used` |
|
|
205
|
-
| `free` |
|
|
27
|
+
Install via the Node-RED Manage Palette or run the following command in your
|
|
28
|
+
Node-RED user directory:
|
|
206
29
|
|
|
30
|
+
```bash
|
|
31
|
+
npm install node-red-contrib-padavan
|
|
32
|
+
```
|
|
207
33
|
|
|
208
|
-
|
|
209
|
-
| --- | ---
|
|
210
|
-
| `busy` | Total time the CPU has been busy
|
|
211
|
-
| `user` | Time spent on user processes
|
|
212
|
-
| `nice` | Time spent on processes with modified priority
|
|
213
|
-
| `system` | Time spent on system processes
|
|
214
|
-
| `idle` | Idle time when the CPU was not busy
|
|
215
|
-
| `iowait` | Time spent waiting for I/O operations
|
|
216
|
-
| `irq` | Time spent on hardware interrupt handling
|
|
217
|
-
| `sirq` | Time spent on software interrupt handling
|
|
218
|
-
| `total` | Total units of time since the system started
|
|
34
|
+
## Nodes
|
|
219
35
|
|
|
36
|
+
### ⚙️ Configuration (`padavan-config`)
|
|
220
37
|
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
| `state` | Network state
|
|
224
|
-
| `guest` | Guest network state
|
|
38
|
+
Configures the connection to the router (IP, Login, Password) and optionally
|
|
39
|
+
to GitHub (for firmware updates). Supports secure credential storage.
|
|
225
40
|
|
|
41
|
+
### 🖥️ System (`padavan-system`)
|
|
226
42
|
|
|
227
|
-
|
|
43
|
+
Performs system operations and diagnostics.
|
|
228
44
|
|
|
229
|
-
|
|
45
|
+
- **Get Status**: CPU load, RAM usage, Uptime.
|
|
46
|
+
- **Get Log**: Fetch system logs.
|
|
47
|
+
- **Reboot**: Restart the router.
|
|
48
|
+
- **Scan Wi-Fi**: Perform a Site Survey (2.4GHz / 5GHz).
|
|
49
|
+
- **Wi-Fi Doctor**: Analyze the environment and recommend the optimal channel.
|
|
230
50
|
|
|
51
|
+
### 📱 Devices (`padavan-devices`)
|
|
231
52
|
|
|
232
|
-
|
|
53
|
+
Lists connected clients.
|
|
233
54
|
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
| `topic` | string
|
|
55
|
+
- Returns IP, MAC, Hostname, Connection Type, and RSSI.
|
|
56
|
+
- Calculates changes (added/removed/changed devices) since the last check.
|
|
57
|
+
- Filters out temporary Ethernet "ghosts" when devices switch from Wi-Fi.
|
|
238
58
|
|
|
59
|
+
### 📊 History (`padavan-history`)
|
|
239
60
|
|
|
240
|
-
|
|
241
|
-
| --- | ---
|
|
242
|
-
| *`list`* | Retrieve all parameters
|
|
243
|
-
| *`get`* | Retrieve specific parameters
|
|
244
|
-
| *`set`* | Modify parameters
|
|
61
|
+
Retrieves traffic usage statistics.
|
|
245
62
|
|
|
63
|
+
- Prioritizes **Monthly** stats for billing cycles.
|
|
64
|
+
- Falls back to **Daily** stats if monthly data is missing.
|
|
65
|
+
- Provides pre-calculated `networkUsageMB` for easy integration with voice
|
|
66
|
+
assistants (e.g., Google Home).
|
|
246
67
|
|
|
247
|
-
|
|
248
|
-
| --- |
|
|
249
|
-
| *`sid_list`* |
|
|
250
|
-
| *`action_mode`* |
|
|
68
|
+
### 🔧 Params (`padavan-params`)
|
|
251
69
|
|
|
70
|
+
Low-level access to router settings (NVRAM).
|
|
252
71
|
|
|
253
|
-
|
|
72
|
+
- **List**: Dump all NVRAM variables.
|
|
73
|
+
- **Get**: Read specific variables.
|
|
74
|
+
- **Set**: Change variables with support for `sid_list` (service restart) and
|
|
75
|
+
custom action modes.
|
|
254
76
|
|
|
255
|
-
|
|
256
|
-
| --- | ---
|
|
257
|
-
| `topic` | string
|
|
258
|
-
| `payload` | object
|
|
77
|
+
### ☁️ Upgrade (`padavan-upgrade`)
|
|
259
78
|
|
|
79
|
+
Manages the firmware lifecycle via GitHub Actions.
|
|
260
80
|
|
|
261
|
-
|
|
81
|
+
- **Check Updates**: Compare current version with the latest artifact.
|
|
82
|
+
- **Build**: Trigger a new build workflow in your repository.
|
|
83
|
+
- **Flash**: Download the artifact and upgrade the router.
|
|
262
84
|
|
|
263
|
-
|
|
85
|
+
## Migration
|
|
264
86
|
|
|
265
|
-
|
|
87
|
+
Upgrading from v1? Check the [Migration Guide](../../docs/MIGRATION.md) for
|
|
88
|
+
details on breaking changes and removed features (like SpeedTest).
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
<script type="text/javascript">
|
|
2
|
+
var RED=window.RED;function onchangerepo(event){let regexp=/https:\/\/github\.com\/?([^\/]+\/[^\/]+)(?:\/tree\/(.+))?/,[repo,branch]=event.target.value.match(regexp)?.slice(1)||[];if(repo)$("#node-config-input-repo").val(repo);if(branch)$("#node-config-input-branch").val(branch)}RED.nodes.registerType("padavan-config",{category:"config",defaults:{name:{value:""},host:{value:""},repo:{value:""},branch:{value:""},debug:{value:!1}},credentials:{username:{type:"text"},password:{type:"password"},token:{type:"password"}},label:function(){return this.name||this.host||"Padavan"},oneditprepare:function(){$("#node-config-input-repo").on("change",onchangerepo)}});
|
|
3
|
+
</script>
|
|
4
|
+
|
|
5
|
+
<script type="text/html" data-template-name="padavan-config">
|
|
6
|
+
<div class="form-row">
|
|
7
|
+
<label for="node-config-input-name"><i class="fa fa-tag"></i> <span data-i18n="config.label.name"></span></label>
|
|
8
|
+
<input type="text" id="node-config-input-name" data-i18n="[placeholder]config.placeholder.name">
|
|
9
|
+
</div>
|
|
10
|
+
<div class="form-row">
|
|
11
|
+
<label style="width:auto" for="node-config-input-debug"><i class="fa fa-bug"></i> <span data-i18n="config.label.debug"></span></label>
|
|
12
|
+
<input type="checkbox" id="node-config-input-debug" style="display:inline-block; width:auto; vertical-align:top;" />
|
|
13
|
+
</div>
|
|
14
|
+
<fieldset>
|
|
15
|
+
<legend data-i18n="config.label.router"></legend>
|
|
16
|
+
<div class="form-row">
|
|
17
|
+
<label for="node-config-input-host"><i class="fa fa-globe"></i> <span data-i18n="config.label.host"></span></label>
|
|
18
|
+
<input type="text" id="node-config-input-host" data-i18n="[placeholder]config.placeholder.host">
|
|
19
|
+
</div>
|
|
20
|
+
<div class="form-row">
|
|
21
|
+
<label for="node-config-input-username"><i class="fa fa-user"></i> <span data-i18n="config.label.username"></span></label>
|
|
22
|
+
<input type="text" id="node-config-input-username">
|
|
23
|
+
</div>
|
|
24
|
+
<div class="form-row">
|
|
25
|
+
<label for="node-config-input-password"><i class="fa fa-key"></i> <span data-i18n="config.label.password"></span></label>
|
|
26
|
+
<input type="password" id="node-config-input-password">
|
|
27
|
+
</div>
|
|
28
|
+
</fieldset>
|
|
29
|
+
<fieldset>
|
|
30
|
+
<legend data-i18n="config.label.github"></legend>
|
|
31
|
+
<div class="form-row">
|
|
32
|
+
<label for="node-config-input-repo"><i class="fa fa-github"></i> <span data-i18n="config.label.repo"></span></label>
|
|
33
|
+
<input type="text" id="node-config-input-repo" data-i18n="[placeholder]config.placeholder.repo">
|
|
34
|
+
</div>
|
|
35
|
+
<div class="form-row">
|
|
36
|
+
<label for="node-config-input-branch"><i class="fa fa-code-fork"></i> <span data-i18n="config.label.branch"></span></label>
|
|
37
|
+
<input type="text" id="node-config-input-branch" data-i18n="[placeholder]config.placeholder.branch">
|
|
38
|
+
</div>
|
|
39
|
+
<div class="form-row">
|
|
40
|
+
<label for="node-config-input-token"><i class="fa fa-key"></i> <span data-i18n="config.label.token"></span></label>
|
|
41
|
+
<input type="password" id="node-config-input-token">
|
|
42
|
+
</div>
|
|
43
|
+
</fieldset>
|
|
44
|
+
</script>
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import x from"padavan";class w{#j;#q;#k;constructor(j,k){this.#j=j,this.#q=k,this.#j.on("close",this.#w.bind(this))}get client(){if(!this.#k)this.#k=new x({credentials:{...this.#q,...this.#j.credentials},logLevel:this.#q.debug?"debug":"none"});return this.#k}async#w(j,k){this.#j.debug(`Closing config node ${this.#j.id} (removed: ${!!j})`),this.#k=null,k()}}function z(j){j.nodes.registerType("padavan-config",function(k){j.nodes.createNode(this,k);let q=this;q.instance=new w(q,k)},{credentials:{username:{type:"text"},password:{type:"password"},token:{type:"password"}}})}export{z as default,w as ConfigNode};
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
<script type="text/javascript">
|
|
2
|
+
var RED=window.RED;RED.nodes.registerType("padavan-devices",{category:"Padavan",defaults:{settings:{value:"",type:"padavan-config",required:!0},name:{value:""}},icon:"font-awesome/fa-list-ul",inputs:1,outputs:1,color:"#49AFCD",paletteLabel:"Devices",label:function(){return this.name||"Devices"}});
|
|
3
|
+
</script>
|
|
4
|
+
|
|
5
|
+
<script type="text/html" data-template-name="padavan-devices">
|
|
6
|
+
<div class="form-row">
|
|
7
|
+
<label for="node-input-settings"><i class="fa fa-cog"></i> <span data-i18n="devices.label.settings"></span></label>
|
|
8
|
+
<input id="node-input-settings" />
|
|
9
|
+
</div>
|
|
10
|
+
<div class="form-row">
|
|
11
|
+
<label for="node-input-name"><i class="fa fa-tag"></i> <span data-i18n="devices.label.name"></span></label>
|
|
12
|
+
<input type="text" id="node-input-name" data-i18n="[placeholder]devices.placeholder.name" />
|
|
13
|
+
</div>
|
|
14
|
+
</script>
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
class J{#b;#k;#j=new Map;constructor(j,q,l){this.#b=j;let x=l.nodes.getNode(q.settings);if(x)this.#k=x.instance;else this.#b.warn("Config node not found or configured.");this.#b.on("input",this.#l.bind(this)),this.#b.on("close",()=>this.#j.clear())}get client(){if(!this.#k)throw Error("Client is not initialized. Check configuration.");return this.#k.client}async#l(j,q,l){try{this.#b.status({fill:"blue",shape:"dot",text:"Fetching..."});let x=await this.client.getDevices(),z=new Map,B=[],F=[],G=x.map((b)=>{let k=this.#j.get(b.mac);if(k&&b.type==="eth"&&["wifi","2.4GHz","5GHz"].includes(k.type))b.type=k.type;if(z.set(b.mac,b),!k)B.push(b);else if(k.ip!==b.ip||k.type!==b.type||k.hostname!==b.hostname)F.push(b);return b}),H=[];for(let[b,k]of this.#j)if(!z.has(b))H.push(k);this.#j=z,j.payload=G,j.numConnectedDevices=G.length,j.changes={added:B,removed:H,changed:F,hasChanges:B.length>0||H.length>0||F.length>0},this.#b.status({fill:"green",shape:"dot",text:`Found: ${G.length}`}),q(j),l()}catch(x){this.#b.status({fill:"red",shape:"ring",text:"Error"}),l(x)}}}function K(j){j.nodes.registerType("padavan-devices",function(q){j.nodes.createNode(this,q);let l=this;l.instance=new J(l,q,j)})}export{K as default,J as DevicesNode};
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
<script type="text/javascript">
|
|
2
|
+
var RED=window.RED;RED.nodes.registerType("padavan-history",{category:"Padavan",defaults:{settings:{value:"",type:"padavan-config",required:!0},name:{value:""}},icon:"font-awesome/fa-history",inputs:1,outputs:1,color:"#49AFCD",paletteLabel:"History",label:function(){return this.name||"History"}});
|
|
3
|
+
</script>
|
|
4
|
+
|
|
5
|
+
<script type="text/html" data-template-name="padavan-history">
|
|
6
|
+
<div class="form-row">
|
|
7
|
+
<label for="node-input-settings"><i class="fa fa-cog"></i> <span data-i18n="history.label.settings"></span></label>
|
|
8
|
+
<input id="node-input-settings" />
|
|
9
|
+
</div>
|
|
10
|
+
<div class="form-row">
|
|
11
|
+
<label for="node-input-name"><i class="fa fa-tag"></i> <span data-i18n="history.label.name"></span></label>
|
|
12
|
+
<input type="text" id="node-input-name" data-i18n="[placeholder]history.placeholder.name" />
|
|
13
|
+
</div>
|
|
14
|
+
</script>
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{formatBytes as Q}from"padavan/utils/formatting.js";class M{#k;#q;constructor(q,z,w){this.#k=q;let k=w.nodes.getNode(z.settings);if(k)this.#q=k.instance;else this.#k.warn("Config node not found or configured.");this.#k.on("input",this.#w.bind(this))}get client(){if(!this.#q)throw Error("Client is not initialized. Check configuration.");return this.#q.client}async#w(q,z,w){if(!this.#q){w(Error("Config node not configured"));return}try{this.#k.status({fill:"blue",shape:"dot",text:"Fetching..."});let k=await this.client.getHistory(),F=null,G="No data";if(k.monthly&&k.monthly.length>0)F=k.monthly[k.monthly.length-1],G="Month";else if(k.daily&&k.daily.length>0)F=k.daily[k.daily.length-1],G="Today";let J=F?F.download+F.upload:0;q.networkUsage=Q(J*1024),q.networkUsageMB=Math.floor(J/1024),q.payload=k;let O=J>0?`${G}: ${q.networkUsage}`:G;this.#k.status({fill:"green",shape:"dot",text:O}),z(q),w()}catch(k){this.#k.status({fill:"red",shape:"ring",text:"Error"}),w(k)}}}function S(q){q.nodes.registerType("padavan-history",function(z){q.nodes.createNode(this,z);let w=this;w.instance=new M(w,z,q)})}export{S as default,M as HistoryNode};
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
<script type="text/markdown" data-help-name="padavan-config" data-lang="en-US">
|
|
2
|
+
Configures connections to the router and GitHub repository.
|
|
3
|
+
|
|
4
|
+
### Router
|
|
5
|
+
|
|
6
|
+
Settings for connecting to the Padavan web interface.
|
|
7
|
+
|
|
8
|
+
- **Host**: IP address or hostname of the router (e.g., `192.168.1.1`).
|
|
9
|
+
- **Username**: Administrator username (usually `admin`).
|
|
10
|
+
- **Password**: Administrator password.
|
|
11
|
+
|
|
12
|
+
### Github
|
|
13
|
+
|
|
14
|
+
Settings for firmware updates and builds. Required only for the `Upgrade` node.
|
|
15
|
+
|
|
16
|
+
- **Repo**: Repository URL or `owner/repo` string (e.g.,
|
|
17
|
+
`alex2844/padavan-builder`).
|
|
18
|
+
- **Branch**: The branch to use for builds and checks (e.g., `main`).
|
|
19
|
+
- **Token**: GitHub Personal Access Token (PAT) with access to Actions and
|
|
20
|
+
Artifacts.
|
|
21
|
+
</script>
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
{
|
|
2
|
+
"config": {
|
|
3
|
+
"label": {
|
|
4
|
+
"name": "Name",
|
|
5
|
+
"debug": "Enable debug",
|
|
6
|
+
"github": "Github",
|
|
7
|
+
"repo": "Repo",
|
|
8
|
+
"branch": "Branch",
|
|
9
|
+
"token": "Token",
|
|
10
|
+
"router": "Router",
|
|
11
|
+
"host": "Host",
|
|
12
|
+
"username": "Username",
|
|
13
|
+
"password": "Password"
|
|
14
|
+
},
|
|
15
|
+
"placeholder": {
|
|
16
|
+
"name": "e.g., My Router",
|
|
17
|
+
"repo": "owner/repository or GitHub URL",
|
|
18
|
+
"branch": "e.g., main",
|
|
19
|
+
"host": "e.g., 192.168.1.1"
|
|
20
|
+
}
|
|
21
|
+
}
|
|
22
|
+
}
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
<script type="text/markdown" data-help-name="padavan-devices" data-lang="en-US">
|
|
2
|
+
Retrieves the list of currently connected devices from the router.
|
|
3
|
+
|
|
4
|
+
### Outputs
|
|
5
|
+
|
|
6
|
+
1. **Standard Output**
|
|
7
|
+
- `msg.payload` (`array`): An array of current device objects. Each object
|
|
8
|
+
contains:
|
|
9
|
+
- `hostname`: Device name.
|
|
10
|
+
- `ip`: IP address.
|
|
11
|
+
- `mac`: MAC address.
|
|
12
|
+
- `type`: Connection type (`eth`, `2.4GHz`, `5GHz`).
|
|
13
|
+
- `rssi`: Signal strength (for Wi-Fi clients).
|
|
14
|
+
- `msg.numConnectedDevices` (`number`): The total count of connected
|
|
15
|
+
devices.
|
|
16
|
+
- `msg.changes` (`object`): A summary of changes since the last check.
|
|
17
|
+
- `hasChanges` (`boolean`): `true` if any change occurred.
|
|
18
|
+
- `added` (`array`): List of new devices.
|
|
19
|
+
- `removed` (`array`): List of disconnected devices.
|
|
20
|
+
- `changed` (`array`): List of devices with changed properties (IP, name,
|
|
21
|
+
type).
|
|
22
|
+
|
|
23
|
+
### Details
|
|
24
|
+
|
|
25
|
+
Any message sent to this node triggers a fresh lookup.
|
|
26
|
+
|
|
27
|
+
The node implements **smart caching** to filter out "ghost" entries (e.g.,
|
|
28
|
+
when a device switches from Wi-Fi to Ethernet in the ARP table momentarily
|
|
29
|
+
during disconnection).
|
|
30
|
+
</script>
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
<script type="text/markdown" data-help-name="padavan-history" data-lang="en-US">
|
|
2
|
+
Retrieves traffic usage statistics.
|
|
3
|
+
|
|
4
|
+
### Outputs
|
|
5
|
+
|
|
6
|
+
1. **Standard Output**
|
|
7
|
+
- `msg.payload` (`object`): The raw history object from the router
|
|
8
|
+
(`daily` and `monthly` arrays).
|
|
9
|
+
- `msg.networkUsage` (`string`): Total traffic for the current period
|
|
10
|
+
(Month or Day) in a human-readable format (e.g., "15.2 GB").
|
|
11
|
+
- `msg.networkUsageMB` (`number`): Total traffic in Megabytes (integer).
|
|
12
|
+
|
|
13
|
+
### Details
|
|
14
|
+
|
|
15
|
+
This node automatically prioritizes **Monthly** statistics.
|
|
16
|
+
|
|
17
|
+
1. If monthly history is available, `networkUsage` reflects the current
|
|
18
|
+
month's total.
|
|
19
|
+
2. If monthly history is missing (e.g., after a reset), it falls back to
|
|
20
|
+
**Daily** statistics for the current day.
|
|
21
|
+
|
|
22
|
+
This data structure is optimized for integration with voice assistants (like
|
|
23
|
+
Google Home `NetworkControl` trait) and dashboards.
|
|
24
|
+
</script>
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
<script type="text/markdown" data-help-name="padavan-params" data-lang="en-US">
|
|
2
|
+
Reads or modifies NVRAM parameters and settings.
|
|
3
|
+
|
|
4
|
+
### Inputs
|
|
5
|
+
|
|
6
|
+
- **Action** (`msg.topic`):
|
|
7
|
+
- `list`: Get all NVRAM parameters.
|
|
8
|
+
- `get`: Get specific parameters defined in `msg.payload`.
|
|
9
|
+
- `set`: Apply settings defined in `msg.payload`.
|
|
10
|
+
- **Payload** (`msg.payload`):
|
|
11
|
+
- For `get`: A string (key) or array of strings (keys).
|
|
12
|
+
- For `set`: An object `{ key: value }`.
|
|
13
|
+
- **Options**:
|
|
14
|
+
- `msg.page`: Current ASP page (helper for finding Service IDs).
|
|
15
|
+
- `msg.sid`: Service ID list (required for restarting services).
|
|
16
|
+
- `msg.group`: Group ID (required for list operations).
|
|
17
|
+
- `msg.script`: Action script to execute.
|
|
18
|
+
- `msg.action`: Action mode (e.g., `' Apply '`, `' Add '`, `' Reboot '`).
|
|
19
|
+
|
|
20
|
+
### Outputs
|
|
21
|
+
|
|
22
|
+
- `msg.payload`: The requested parameters (for `get`/`list`) or the applied
|
|
23
|
+
configuration (for `set`).
|
|
24
|
+
|
|
25
|
+
### Details
|
|
26
|
+
|
|
27
|
+
Use the **Action Mode** field in the editor (or `msg.action`) to control how
|
|
28
|
+
parameters are applied (e.g., just change NVRAM, apply changes to a service,
|
|
29
|
+
or reboot).
|
|
30
|
+
</script>
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
{
|
|
2
|
+
"params": {
|
|
3
|
+
"label": {
|
|
4
|
+
"settings": "Config",
|
|
5
|
+
"name": "Name",
|
|
6
|
+
"topic": "Action",
|
|
7
|
+
"payload": "Payload",
|
|
8
|
+
"page": "ASP Page",
|
|
9
|
+
"sid": "Service IDs",
|
|
10
|
+
"group": "Group ID",
|
|
11
|
+
"script": "Action Script",
|
|
12
|
+
"action": "Action Mode"
|
|
13
|
+
},
|
|
14
|
+
"placeholder": {
|
|
15
|
+
"name": "Params",
|
|
16
|
+
"page": "e.g., Advanced_DHCP_Content.asp",
|
|
17
|
+
"sid": "e.g., WLANConfig11b",
|
|
18
|
+
"group": "e.g., ManualDHCPList"
|
|
19
|
+
},
|
|
20
|
+
"action": {
|
|
21
|
+
"list": "Get All (NVRAM)",
|
|
22
|
+
"get": "Get Specific",
|
|
23
|
+
"set": "Set Parameters"
|
|
24
|
+
}
|
|
25
|
+
}
|
|
26
|
+
}
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
<script type="text/markdown" data-help-name="padavan-system" data-lang="en-US">
|
|
2
|
+
Performs system diagnostics and control operations.
|
|
3
|
+
|
|
4
|
+
### Inputs
|
|
5
|
+
|
|
6
|
+
- **Action** (`msg.topic`):
|
|
7
|
+
- `status`: Get system status (CPU, RAM, Uptime).
|
|
8
|
+
- `log`: Get the system log.
|
|
9
|
+
- `reboot`: Reboot the router.
|
|
10
|
+
- `scan`: Scan for Wi-Fi networks (Site Survey).
|
|
11
|
+
- `doctor`: Analyze Wi-Fi environment and recommend the best channel.
|
|
12
|
+
- **Band** (`msg.band`):
|
|
13
|
+
- Used for `scan` and `doctor`.
|
|
14
|
+
- Values: `'2.4'` or `'5'`.
|
|
15
|
+
|
|
16
|
+
### Outputs
|
|
17
|
+
|
|
18
|
+
- `msg.payload`: The result of the operation (JSON object for status/doctor,
|
|
19
|
+
array for scan, string for log).
|
|
20
|
+
|
|
21
|
+
### Details
|
|
22
|
+
|
|
23
|
+
The **Wi-Fi Doctor** action analyzes all visible networks, calculates
|
|
24
|
+
interference scores, and suggests the optimal channel for your router.
|
|
25
|
+
</script>
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
{
|
|
2
|
+
"system": {
|
|
3
|
+
"label": {
|
|
4
|
+
"settings": "Config",
|
|
5
|
+
"name": "Name",
|
|
6
|
+
"topic": "Action",
|
|
7
|
+
"band": "Band"
|
|
8
|
+
},
|
|
9
|
+
"placeholder": {
|
|
10
|
+
"name": "System"
|
|
11
|
+
},
|
|
12
|
+
"action": {
|
|
13
|
+
"status": "Get Status",
|
|
14
|
+
"log": "Get Log",
|
|
15
|
+
"reboot": "Reboot",
|
|
16
|
+
"scan": "Scan Wi-Fi",
|
|
17
|
+
"doctor": "Wi-Fi Doctor"
|
|
18
|
+
}
|
|
19
|
+
}
|
|
20
|
+
}
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
<script type="text/markdown" data-help-name="padavan-upgrade" data-lang="en-US">
|
|
2
|
+
Manages firmware lifecycle via GitHub Actions.
|
|
3
|
+
|
|
4
|
+
### Actions (`msg.topic`)
|
|
5
|
+
|
|
6
|
+
- **Check Updates** (`changelog`):
|
|
7
|
+
- Checks if a newer firmware version is available in the GitHub repository.
|
|
8
|
+
- Output: Object with `from` (current), `to` (latest), and `messages`
|
|
9
|
+
(commit list).
|
|
10
|
+
- **Build Firmware** (`build`):
|
|
11
|
+
- Triggers a new workflow run in the configured GitHub repository.
|
|
12
|
+
- **Flash Firmware** (`upgrade`):
|
|
13
|
+
- Downloads the latest successful artifact.
|
|
14
|
+
- Uploads it to the router.
|
|
15
|
+
- Flashes the firmware and reboots the router.
|
|
16
|
+
|
|
17
|
+
### Requirements
|
|
18
|
+
|
|
19
|
+
Requires valid **Github** credentials (Repo, Branch, Token) in the
|
|
20
|
+
Configuration node.
|
|
21
|
+
</script>
|