meross-cli 0.1.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/CHANGELOG.md +28 -0
- package/LICENSE +21 -0
- package/README.md +110 -0
- package/cli/commands/control/execute.js +23 -0
- package/cli/commands/control/index.js +12 -0
- package/cli/commands/control/menu.js +193 -0
- package/cli/commands/control/params/generic.js +229 -0
- package/cli/commands/control/params/index.js +56 -0
- package/cli/commands/control/params/light.js +188 -0
- package/cli/commands/control/params/thermostat.js +166 -0
- package/cli/commands/control/params/timer.js +242 -0
- package/cli/commands/control/params/trigger.js +206 -0
- package/cli/commands/dump.js +35 -0
- package/cli/commands/index.js +34 -0
- package/cli/commands/info.js +221 -0
- package/cli/commands/list.js +112 -0
- package/cli/commands/mqtt.js +187 -0
- package/cli/commands/sniffer/device-sniffer.js +217 -0
- package/cli/commands/sniffer/fake-app.js +233 -0
- package/cli/commands/sniffer/index.js +7 -0
- package/cli/commands/sniffer/message-queue.js +65 -0
- package/cli/commands/sniffer/sniffer-menu.js +676 -0
- package/cli/commands/stats.js +90 -0
- package/cli/commands/status/device-status.js +1403 -0
- package/cli/commands/status/hub-status.js +72 -0
- package/cli/commands/status/index.js +50 -0
- package/cli/commands/status/subdevices/hub-smoke-detector.js +82 -0
- package/cli/commands/status/subdevices/hub-temp-hum-sensor.js +43 -0
- package/cli/commands/status/subdevices/hub-thermostat-valve.js +83 -0
- package/cli/commands/status/subdevices/hub-water-leak-sensor.js +27 -0
- package/cli/commands/status/subdevices/index.js +23 -0
- package/cli/commands/test/index.js +185 -0
- package/cli/config/users.js +108 -0
- package/cli/control-registry.js +875 -0
- package/cli/helpers/client.js +89 -0
- package/cli/helpers/meross.js +106 -0
- package/cli/menu/index.js +10 -0
- package/cli/menu/main.js +648 -0
- package/cli/menu/settings.js +789 -0
- package/cli/meross-cli.js +547 -0
- package/cli/tests/README.md +365 -0
- package/cli/tests/test-alarm.js +144 -0
- package/cli/tests/test-child-lock.js +248 -0
- package/cli/tests/test-config.js +133 -0
- package/cli/tests/test-control.js +189 -0
- package/cli/tests/test-diffuser.js +505 -0
- package/cli/tests/test-dnd.js +246 -0
- package/cli/tests/test-electricity.js +209 -0
- package/cli/tests/test-encryption.js +281 -0
- package/cli/tests/test-garage.js +259 -0
- package/cli/tests/test-helper.js +313 -0
- package/cli/tests/test-hub-mts100.js +355 -0
- package/cli/tests/test-hub-sensors.js +489 -0
- package/cli/tests/test-light.js +253 -0
- package/cli/tests/test-presence.js +497 -0
- package/cli/tests/test-registry.js +419 -0
- package/cli/tests/test-roller-shutter.js +628 -0
- package/cli/tests/test-runner.js +415 -0
- package/cli/tests/test-runtime.js +234 -0
- package/cli/tests/test-screen.js +133 -0
- package/cli/tests/test-sensor-history.js +146 -0
- package/cli/tests/test-smoke-config.js +138 -0
- package/cli/tests/test-spray.js +131 -0
- package/cli/tests/test-temp-unit.js +133 -0
- package/cli/tests/test-template.js +238 -0
- package/cli/tests/test-thermostat.js +919 -0
- package/cli/tests/test-timer.js +372 -0
- package/cli/tests/test-toggle.js +342 -0
- package/cli/tests/test-trigger.js +279 -0
- package/cli/utils/display.js +86 -0
- package/cli/utils/terminal.js +137 -0
- package/package.json +53 -0
|
@@ -0,0 +1,90 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
const chalk = require('chalk');
|
|
4
|
+
const { createDebugUtils } = require('meross-iot');
|
|
5
|
+
|
|
6
|
+
function showStats(manager) {
|
|
7
|
+
const debug = createDebugUtils(manager);
|
|
8
|
+
const statsEnabled = debug.isStatsEnabled();
|
|
9
|
+
const mqttStats = debug.getMqttStats();
|
|
10
|
+
const httpStats = debug.getHttpStats();
|
|
11
|
+
|
|
12
|
+
console.log(`\n${chalk.bold.underline('Statistics')}\n`);
|
|
13
|
+
|
|
14
|
+
const statsInfo = [
|
|
15
|
+
['Tracking', statsEnabled ? chalk.green('Enabled') : chalk.red('Disabled')]
|
|
16
|
+
];
|
|
17
|
+
|
|
18
|
+
const maxLabelLength = Math.max(...statsInfo.map(([label]) => label.length));
|
|
19
|
+
statsInfo.forEach(([label, value]) => {
|
|
20
|
+
const padding = ' '.repeat(maxLabelLength - label.length);
|
|
21
|
+
console.log(` ${chalk.gray.bold(label)}:${padding} ${value}`);
|
|
22
|
+
});
|
|
23
|
+
|
|
24
|
+
if (!statsEnabled) {
|
|
25
|
+
console.log(`\n ${chalk.yellow('Statistics tracking is disabled. Use "stats on" to enable it.')}\n`);
|
|
26
|
+
return;
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
if (mqttStats) {
|
|
30
|
+
const delayedStats = debug.getDelayedMqttStats();
|
|
31
|
+
const droppedStats = debug.getDroppedMqttStats();
|
|
32
|
+
|
|
33
|
+
const sent = mqttStats.globalStats.totalCalls;
|
|
34
|
+
const delayed = delayedStats ? delayedStats.globalStats.totalCalls : 0;
|
|
35
|
+
const dropped = droppedStats ? droppedStats.globalStats.totalCalls : 0;
|
|
36
|
+
const total = sent + delayed + dropped;
|
|
37
|
+
|
|
38
|
+
console.log(`\n ${chalk.bold.underline('MQTT Statistics')}`);
|
|
39
|
+
const mqttInfo = [
|
|
40
|
+
['Total Calls', chalk.cyan(total)],
|
|
41
|
+
['Sent', sent],
|
|
42
|
+
['Delayed', delayed],
|
|
43
|
+
['Dropped', dropped]
|
|
44
|
+
];
|
|
45
|
+
const mqttMaxLabelLength = Math.max(...mqttInfo.map(([label]) => label.length));
|
|
46
|
+
mqttInfo.forEach(([label, value]) => {
|
|
47
|
+
const padding = ' '.repeat(mqttMaxLabelLength - label.length);
|
|
48
|
+
console.log(` ${chalk.gray.bold(label)}:${padding} ${value}`);
|
|
49
|
+
});
|
|
50
|
+
} else {
|
|
51
|
+
console.log(`\n ${chalk.bold.underline('MQTT Statistics')}`);
|
|
52
|
+
console.log(` ${chalk.gray.bold('Not available (stats not enabled)')}`);
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
if (httpStats) {
|
|
56
|
+
console.log(`\n ${chalk.bold.underline('HTTP Statistics')}`);
|
|
57
|
+
const httpInfo = [
|
|
58
|
+
['Total Calls', chalk.cyan(httpStats.globalStats.totalCalls)]
|
|
59
|
+
];
|
|
60
|
+
const httpMaxLabelLength = Math.max(...httpInfo.map(([label]) => label.length));
|
|
61
|
+
httpInfo.forEach(([label, value]) => {
|
|
62
|
+
const padding = ' '.repeat(httpMaxLabelLength - label.length);
|
|
63
|
+
console.log(` ${chalk.gray.bold(label)}:${padding} ${value}`);
|
|
64
|
+
});
|
|
65
|
+
|
|
66
|
+
const byHttpCode = httpStats.globalStats.byHttpResponseCode();
|
|
67
|
+
if (byHttpCode.length > 0) {
|
|
68
|
+
console.log(`\n ${chalk.gray.bold('By HTTP Response Code:')}`);
|
|
69
|
+
byHttpCode.forEach(([code, count]) => {
|
|
70
|
+
console.log(` ${code}: ${chalk.cyan(count)}`);
|
|
71
|
+
});
|
|
72
|
+
}
|
|
73
|
+
|
|
74
|
+
const byApiCode = httpStats.globalStats.byApiStatusCode();
|
|
75
|
+
if (byApiCode.length > 0) {
|
|
76
|
+
console.log(`\n ${chalk.gray.bold('By API Status Code:')}`);
|
|
77
|
+
byApiCode.forEach(([code, count]) => {
|
|
78
|
+
console.log(` ${code}: ${chalk.cyan(count)}`);
|
|
79
|
+
});
|
|
80
|
+
}
|
|
81
|
+
} else {
|
|
82
|
+
console.log(`\n ${chalk.bold.underline('HTTP Statistics')}`);
|
|
83
|
+
console.log(` ${chalk.gray.bold('Not available (stats not enabled)')}`);
|
|
84
|
+
}
|
|
85
|
+
|
|
86
|
+
console.log('');
|
|
87
|
+
}
|
|
88
|
+
|
|
89
|
+
module.exports = { showStats };
|
|
90
|
+
|