node-red-contrib-padavan 1.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.
@@ -0,0 +1,27 @@
1
+ module.exports = function(RED) {
2
+ function Devices(config) {
3
+ RED.nodes.createNode(this, config);
4
+ const settings = RED.nodes.getNode(config.settings);
5
+ this.on('input', msg => {
6
+ settings.getClient().then(client => client.getDevices())
7
+ .then(payload => {
8
+ if (!payload)
9
+ return;
10
+ msg.payload = payload;
11
+ msg.numConnectedDevices = payload.length;
12
+ this.status({
13
+ fill: 'green',
14
+ shape: 'dot',
15
+ text: msg.numConnectedDevices
16
+ });
17
+ this.send(msg);
18
+ })
19
+ .catch(({ message, code }) => {
20
+ msg.code = code;
21
+ msg.payload = message;
22
+ this.error(message, msg);
23
+ });
24
+ });
25
+ };
26
+ RED.nodes.registerType('padavan-devices', Devices);
27
+ }
@@ -0,0 +1,27 @@
1
+ <script type="text/html" data-template-name="padavan-history">
2
+ <div class="form-row">
3
+ <label for="node-input-settings"><i class="fa fa-cog"></i> Config</label>
4
+ <input id="node-input-settings" />
5
+ </div>
6
+ <div class="form-row">
7
+ <label for="node-input-name"><i class="fa fa-pencil"></i> Name</label>
8
+ <input type="text" id="node-input-name" />
9
+ </div>
10
+ </script>
11
+ <script type="text/javascript">
12
+ RED.nodes.registerType('padavan-history', {
13
+ category: 'Padavan',
14
+ defaults: {
15
+ settings: { value: null, required: true, type: 'padavan-config' },
16
+ name: { value: '' }
17
+ },
18
+ icon: 'font-awesome/fa-history',
19
+ inputs: 1,
20
+ outputs: 1,
21
+ color: '#49afcd',
22
+ paletteLabel: 'History',
23
+ label: function() {
24
+ return this.name || 'History';
25
+ }
26
+ });
27
+ </script>
@@ -0,0 +1,32 @@
1
+ module.exports = function(RED) {
2
+ function History(config) {
3
+ RED.nodes.createNode(this, config);
4
+ const settings = RED.nodes.getNode(config.settings);
5
+ this.on('input', msg => {
6
+ settings.getClient().then(client => client.getHistory())
7
+ .then(payload => {
8
+ if (!payload)
9
+ return;
10
+ const kb = payload.monthly_history.slice(-1)[0].slice(1).reduce((a, b) => a + b, 0);
11
+ const k = kb > 0 ? Math.floor((Math.log2(kb)/10)) : 0;
12
+ const rank = (k > 0 ? 'MGT'[k - 1] : '') + 'b';
13
+ const count = Math.floor(kb / Math.pow(1024, k));
14
+ msg.networkUsage = count + rank;
15
+ msg.networkUsageMB = parseInt(kb / 1024);
16
+ msg.payload = payload;
17
+ this.status({
18
+ fill: 'green',
19
+ shape: 'dot',
20
+ text: msg.networkUsage
21
+ });
22
+ this.send(msg);
23
+ })
24
+ .catch(({ message, code }) => {
25
+ msg.code = code;
26
+ msg.payload = message;
27
+ this.error(message, msg);
28
+ });
29
+ });
30
+ };
31
+ RED.nodes.registerType('padavan-history', History);
32
+ }
@@ -0,0 +1,12 @@
1
+ <script type="text/markdown" data-help-name="padavan-config">
2
+ ### Input
3
+
4
+ | credentials | Description
5
+ | --- | ---
6
+ | *`repo`* | Repository where firmware builds are hosted
7
+ | *`branch`* | Branch for the device
8
+ | *`token`* | Access token for GitHub
9
+ | `host` | Router IP address
10
+ | `username` | Username for router access
11
+ | `password` | Password for router access
12
+ </script>
@@ -0,0 +1,19 @@
1
+ <script type="text/markdown" data-help-name="padavan-devices">
2
+ Get the list of connected devices
3
+
4
+
5
+ ### Output
6
+
7
+ | msg | type
8
+ | --- | ---
9
+ | `payload` | array
10
+ | `numConnectedDevices` | integer
11
+
12
+
13
+ | payload |
14
+ | --- |
15
+ | `hostname` |
16
+ | `ip` |
17
+ | `mac` |
18
+ | `rssi` |
19
+ </script>
@@ -0,0 +1,25 @@
1
+ <script type="text/markdown" data-help-name="padavan-history">
2
+ Retrieve traffic history
3
+
4
+
5
+ ### Output
6
+
7
+ | msg | type
8
+ | --- | ---
9
+ | `payload` | object
10
+ | `networkUsage` | string
11
+ | `networkUsageMB` | integer
12
+
13
+
14
+ | payload | type | Description
15
+ | --- | --- | ---
16
+ | `daily_history` | array | Daily
17
+ | `monthly_history` | array | Monthly
18
+
19
+
20
+ | \*\_history | Description
21
+ | --- | ---
22
+ | `0` | Year, month, day
23
+ | `1` | Download
24
+ | `2` | Upload
25
+ </script>
@@ -0,0 +1,39 @@
1
+ <script type="text/markdown" data-help-name="padavan-params">
2
+ Retrieve and modify parameters
3
+
4
+
5
+ ### Input
6
+
7
+ | msg | type
8
+ | --- | ---
9
+ | *`payload`* | object
10
+ | `topic` | string
11
+
12
+
13
+ | topic | Description
14
+ | --- | ---
15
+ | *`list`* | Retrieve all parameters
16
+ | *`get`* | Retrieve specific parameters
17
+ | *`set`* | Modify parameters
18
+
19
+
20
+ | payload |
21
+ | --- |
22
+ | *`sid_list`* |
23
+ | *`action_mode`* |
24
+
25
+
26
+ ### Output
27
+
28
+ | msg | type
29
+ | --- | ---
30
+ | `topic` | string
31
+ | `payload` | object
32
+
33
+
34
+ ### Details
35
+
36
+ If `sid_list` is specified, changes will be sent via the web panel.
37
+
38
+ If `action_mode` is not specified, it will be sent as ` Apply `.
39
+ </script>
@@ -0,0 +1,24 @@
1
+ <script type="text/markdown" data-help-name="padavan-speedtest">
2
+ Measure download and upload speeds
3
+
4
+
5
+ ### Output
6
+
7
+ | outputs | Description
8
+ | --- | ---
9
+ | `result` | Result
10
+ | `history` | Result with date and timestamp
11
+ | `progress` | Test start and end
12
+
13
+
14
+ | result.msg | type | Value
15
+ | --- | --- | ---
16
+ | `topic` | string | NetworkControl
17
+ | `payload` | object |
18
+
19
+
20
+ | payload | Description
21
+ | --- | ---
22
+ | `networkDownloadSpeedMbps`| Download speed
23
+ | `networkUploadSpeedMbps` | Upload speed
24
+ </script>
@@ -0,0 +1,79 @@
1
+ <script type="text/markdown" data-help-name="padavan-system">
2
+ Retrieve and manage router status
3
+
4
+
5
+ ### Input
6
+
7
+ | msg | type
8
+ | --- | ---
9
+ | `topic` | string
10
+
11
+
12
+ | topic | Description
13
+ | --- | ---
14
+ | *`status`* | Get current status
15
+ | *`log`* | Get logs
16
+ | *`reboot`* | Reboot
17
+
18
+
19
+ ### Output
20
+
21
+ | msg | type | Value
22
+ | --- | --- | ---
23
+ | `topic` | string | status
24
+ | `payload` | object |
25
+
26
+
27
+ | payload | Description
28
+ | --- | ---
29
+ | `lavg` | System load average over the last 1, 5, and 15 minutes
30
+ | `uptime` | Router uptime
31
+ | `ram` | RAM usage information
32
+ | `swap` | Swap memory status
33
+ | `cpu` | CPU load information
34
+ | `wifi2` | Wi-Fi status on the 2.4 GHz band
35
+ | `wifi5` | Wi-Fi status on the 5 GHz band
36
+ | `logmt` | Timestamp of the last log modification
37
+
38
+
39
+ | uptime |
40
+ | --- |
41
+ | `days` |
42
+ | `hours` |
43
+ | `minutes` |
44
+
45
+
46
+ | ram | Description
47
+ | --- | ---
48
+ | `total` | Total RAM (in KB)
49
+ | `used` | Used RAM
50
+ | `free` | Free RAM
51
+ | `buffers` | RAM used for buffers
52
+ | `cached` | RAM used for cache
53
+
54
+
55
+ | swap |
56
+ | --- |
57
+ | `total` |
58
+ | `used` |
59
+ | `free` |
60
+
61
+
62
+ | cpu | Description
63
+ | --- | ---
64
+ | `busy` | Total time the CPU has been busy
65
+ | `user` | Time spent on user processes
66
+ | `nice` | Time spent on processes with modified priority
67
+ | `system` | Time spent on system processes
68
+ | `idle` | Idle time when the CPU was not busy
69
+ | `iowait` | Time spent waiting for I/O operations
70
+ | `irq` | Time spent on hardware interrupt handling
71
+ | `sirq` | Time spent on software interrupt handling
72
+ | `total` | Total units of time since the system started
73
+
74
+
75
+ | wifi\* | Description
76
+ | --- | ---
77
+ | `state` | Network state
78
+ | `guest` | Guest network state
79
+ </script>
@@ -0,0 +1,33 @@
1
+ <script type="text/markdown" data-help-name="padavan-upgrade">
2
+ Manage firmware updates
3
+
4
+
5
+ ### Input
6
+
7
+ | msg | type
8
+ | --- | ---
9
+ | `topic` | string
10
+
11
+
12
+ | topic | Description
13
+ | --- | ---
14
+ | *`build`* | Build firmware
15
+ | *`changelog`* | List of changes
16
+ | *`upgrade`* | Install firmware
17
+
18
+
19
+ ### Output
20
+
21
+ | msg | type | Value
22
+ | --- | --- | ---
23
+ | `topic` | string | changelog
24
+ | `error` | string |
25
+ | `payload` | object |
26
+
27
+
28
+ | payload | Description
29
+ | --- | ---
30
+ | `from_id` | Current firmware
31
+ | `to_id` | Built firmware
32
+ | `data` | Array of changes
33
+ </script>
@@ -0,0 +1,12 @@
1
+ <script type="text/markdown" data-help-name="padavan-config">
2
+ ### Принимает
3
+
4
+ | credentials | Описание
5
+ | --- | ---
6
+ | *`repo`* | Репозиторий где собираются прошивки
7
+ | *`branch`* | Ветка для устройства
8
+ | *`token`* | Токен для доступа к github
9
+ | `host` | IP роутера
10
+ | `username` | Логин для доступа к роутеру
11
+ | `password` | Пароль для доступа к роутеру
12
+ </script>
@@ -0,0 +1,19 @@
1
+ <script type="text/markdown" data-help-name="padavan-devices">
2
+ Получить список устройств
3
+
4
+
5
+ ### Выводит
6
+
7
+ | msg | type
8
+ | --- | ---
9
+ | `payload` | array
10
+ | `numConnectedDevices` | integer
11
+
12
+
13
+ | payload |
14
+ | --- |
15
+ | `hostname` |
16
+ | `ip` |
17
+ | `mac` |
18
+ | `rssi` |
19
+ </script>
@@ -0,0 +1,25 @@
1
+ <script type="text/markdown" data-help-name="padavan-history">
2
+ Получить историю трафика
3
+
4
+
5
+ ### Выводит
6
+
7
+ | msg | type
8
+ | --- | ---
9
+ | `payload` | object
10
+ | `networkUsage` | string
11
+ | `networkUsageMB` | integer
12
+
13
+
14
+ | payload | type | Описание
15
+ | --- | --- | ---
16
+ | `daily_history` | array | Ежедневно
17
+ | `monthly_history` | array | Ежемесячно
18
+
19
+
20
+ | \*\_history | Описание
21
+ | --- | ---
22
+ | `0` | Год, месяц, день
23
+ | `1` | Загрузка
24
+ | `2` | Отдача
25
+ </script>
@@ -0,0 +1,39 @@
1
+ <script type="text/markdown" data-help-name="padavan-params">
2
+ Получение и изменение параметров
3
+
4
+
5
+ ### Принимает
6
+
7
+ | msg | type
8
+ | --- | ---
9
+ | *`payload`* | object
10
+ | `topic` | string
11
+
12
+
13
+ | topic | Описание
14
+ | --- | ---
15
+ | *`list`* | Получить все параметры
16
+ | *`get`* | Получить определенные параметры
17
+ | *`set`* | Изменить параметры
18
+
19
+
20
+ | payload |
21
+ | --- |
22
+ | *`sid_list`* |
23
+ | *`action_mode`* |
24
+
25
+
26
+ ### Выводит
27
+
28
+ | msg | type
29
+ | --- | ---
30
+ | `topic` | string
31
+ | `payload` | object
32
+
33
+
34
+ ### Подробности
35
+
36
+ Если указан `sid_list`, то изменения будут отправляться через веб-панель.
37
+
38
+ Если не указан `action_mode`, то будет отправляться как ` Apply `.
39
+ </script>
@@ -0,0 +1,24 @@
1
+ <script type="text/markdown" data-help-name="padavan-speedtest">
2
+ Измерить скорость скачивания и загрузки
3
+
4
+
5
+ ### Выводит
6
+
7
+ | outputs | Описание
8
+ | --- | ---
9
+ | `result` | Результат
10
+ | `history` | Результат с датой и timestamp
11
+ | `progress` | Запуск и окончание теста
12
+
13
+
14
+ | result.msg | type | Значение
15
+ | --- | --- | ---
16
+ | `topic` | string | NetworkControl
17
+ | `payload` | object |
18
+
19
+
20
+ | payload | Описание
21
+ | --- | ---
22
+ | `networkDownloadSpeedMbps`| Скорость скачивания
23
+ | `networkUploadSpeedMbps` | Скорость загрузки
24
+ </script>
@@ -0,0 +1,79 @@
1
+ <script type="text/markdown" data-help-name="padavan-system">
2
+ Получение и управление состоянием роутера
3
+
4
+
5
+ ### Принимает
6
+
7
+ | msg | type
8
+ | --- | ---
9
+ | `topic` | string
10
+
11
+
12
+ | topic | Описание
13
+ | --- | ---
14
+ | *`status`* | Получить текущее состояние
15
+ | *`log`* | Получить логи
16
+ | *`reboot`* | Перезагрузить
17
+
18
+
19
+ ### Выводит
20
+
21
+ | msg | type | Значение
22
+ | --- | --- | ---
23
+ | `topic` | string | status
24
+ | `payload` | object |
25
+
26
+
27
+ | payload | Описание
28
+ | --- | ---
29
+ | `lavg` | Средняя загрузка системы за последние 1, 5 и 15 минут
30
+ | `uptime` | Время работы роутера без перезагрузки
31
+ | `ram` | Информация об использовании RAM
32
+ | `swap` | Информация о состоянии подкачки
33
+ | `cpu` | Информация о загрузке процессора
34
+ | `wifi2` | Состояние сети Wi-Fi на частоте 2.4 GHz
35
+ | `wifi5` | Состояние сети Wi-Fi на частоте 5 GHz
36
+ | `logmt` | Метка времени последнего изменения логов
37
+
38
+
39
+ | uptime |
40
+ | --- |
41
+ | `days` |
42
+ | `hours` |
43
+ | `minutes` |
44
+
45
+
46
+ | ram | Описание
47
+ | --- | ---
48
+ | `total` | Общий объём оперативной памяти (в КБ)
49
+ | `used` | Объём использованной памяти
50
+ | `free` | Объём свободной памяти
51
+ | `buffers` | Объём памяти, используемой под буферы
52
+ | `cached` | Объём памяти, используемой под кэш
53
+
54
+
55
+ | swap |
56
+ | --- |
57
+ | `total` |
58
+ | `used` |
59
+ | `free` |
60
+
61
+
62
+ | cpu | Описание
63
+ | --- | ---
64
+ | `busy` | Суммарное время, когда процессор был занят
65
+ | `user` | Время, затраченное процессором на выполнение пользовательских процессов
66
+ | `nice` | Время, затраченное процессором на процессы с изменённым приоритетом
67
+ | `system` | Время, затраченное процессором на выполнение системных процессов
68
+ | `idle` | Время простоя процессора, когда он не был занят
69
+ | `iowait` | Время, которое процессор ждал завершения операций ввода-вывода
70
+ | `irq` | Время, затраченное процессором на обработку аппаратных прерываний
71
+ | `sirq` | Время, затраченное процессором на обработку программных прерываний
72
+ | `total` | Общее количество единиц времени с момента запуска системы
73
+
74
+
75
+ | wifi\* | Описание
76
+ | --- | ---
77
+ | `state` | Состояние сети
78
+ | `guest` | Состояние гостевой сети
79
+ </script>
@@ -0,0 +1,33 @@
1
+ <script type="text/markdown" data-help-name="padavan-upgrade">
2
+ Управление прошивками
3
+
4
+
5
+ ### Принимает
6
+
7
+ | msg | type
8
+ | --- | ---
9
+ | `topic` | string
10
+
11
+
12
+ | topic | Описание
13
+ | --- | ---
14
+ | *`build`* | Собрать прошивку
15
+ | *`changelog`* | Список изменений
16
+ | *`upgrade`* | Установить прошивку
17
+
18
+
19
+ ### Выводит
20
+
21
+ | msg | type | Значение
22
+ | --- | --- | ---
23
+ | `topic` | string | changelog
24
+ | `error` | string |
25
+ | `payload` | object |
26
+
27
+
28
+ | payload | Описание
29
+ | --- | ---
30
+ | `from_id` | Текущая прошивка
31
+ | `to_id` | Собранная прошивка
32
+ | `data` | Массив с изменениями
33
+ </script>
@@ -0,0 +1,60 @@
1
+ <script type="text/html" data-template-name="padavan-params">
2
+ <div class="form-row">
3
+ <label for="node-input-settings"><i class="fa fa-cog"></i> Config</label>
4
+ <input id="node-input-settings" />
5
+ </div>
6
+ <div class="form-row">
7
+ <label for="node-input-name"><i class="fa fa-pencil"></i> Name</label>
8
+ <input type="text" id="node-input-name" />
9
+ </div>
10
+ <div class="form-row">
11
+ <label for="node-input-payload"><i class="fa fa-cogs"></i> Payload</label>
12
+ <input type="text" id="node-input-payload">
13
+ <input type="hidden" id="node-input-payloadType">
14
+ </div>
15
+ <div class="form-row">
16
+ <label for="node-input-topic"><i class="fa fa-envelope-o"></i> Topic</label>
17
+ <input type="text" id="node-input-topic">
18
+ <input type="hidden" id="node-input-topicType">
19
+ </div>
20
+ </script>
21
+ <script type="text/javascript">
22
+ RED.nodes.registerType('padavan-params', {
23
+ category: 'Padavan',
24
+ defaults: {
25
+ settings: { value: null, required: true, type: 'padavan-config' },
26
+ name: { value: '' },
27
+ payload: { value: 'payload' },
28
+ payloadType: { value: 'msg' },
29
+ topic: { value: 'topic' },
30
+ topicType: { value: 'msg' }
31
+ },
32
+ icon: 'font-awesome/fa-cogs',
33
+ inputs: 1,
34
+ outputs: 1,
35
+ color: '#49afcd',
36
+ paletteLabel: 'Params',
37
+ label: function() {
38
+ return this.name || 'Params';
39
+ },
40
+ oneditprepare: function() {
41
+ $('#node-input-payload').typedInput({
42
+ types: [ 'msg', 'str', 'json' ],
43
+ typeField: '#node-input-payloadType'
44
+ });
45
+ $('#node-input-topic').typedInput({
46
+ types: [ 'msg', {
47
+ value: 'action',
48
+ options: [ 'list', 'get', 'set' ]
49
+ }],
50
+ typeField: '#node-input-topicType'
51
+ }).on('change', ev => {
52
+ const el = $('#node-input-payload').parent();
53
+ if (ev.target.value === 'list')
54
+ el.hide();
55
+ else
56
+ el.show();
57
+ });
58
+ }
59
+ });
60
+ </script>
@@ -0,0 +1,35 @@
1
+ module.exports = function(RED) {
2
+ function Params(config) {
3
+ RED.nodes.createNode(this, config);
4
+ const settings = RED.nodes.getNode(config.settings);
5
+ this.on('input', msg => {
6
+ msg.payload = RED.util.evaluateNodeProperty(config.payload, config.payloadType, this, msg);
7
+ msg.topic = RED.util.evaluateNodeProperty(config.topic, config.topicType, this, msg);
8
+ if ([ 'list', 'get', 'set' ].includes(msg.topic))
9
+ settings.getClient().then(client => {
10
+ if (msg.topic === 'list')
11
+ return client.getParams();
12
+ else{
13
+ if (!msg.payload || !Object.keys(msg.payload).length)
14
+ throw new Error('Input payload missing');
15
+ if (msg.topic === 'get')
16
+ return client.getParams(msg.payload);
17
+ else if (msg.topic === 'set')
18
+ return client.setParams(msg.payload);
19
+ }
20
+ })
21
+ .then(payload => {
22
+ if (!payload)
23
+ return;
24
+ msg.payload = payload;
25
+ this.send(msg);
26
+ })
27
+ .catch(({ message, code }) => {
28
+ msg.code = code;
29
+ msg.payload = message;
30
+ this.error(message, msg);
31
+ });
32
+ });
33
+ };
34
+ RED.nodes.registerType('padavan-params', Params);
35
+ }