meross-cli 0.4.0 → 0.6.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.
Files changed (42) hide show
  1. package/CHANGELOG.md +19 -0
  2. package/README.md +24 -5
  3. package/cli/commands/control/execute.js +36 -6
  4. package/cli/commands/control/params/index.js +16 -12
  5. package/cli/commands/control/params/light.js +55 -25
  6. package/cli/commands/control/params/thermostat.js +24 -22
  7. package/cli/commands/control/params/timer.js +38 -43
  8. package/cli/commands/control/params/trigger.js +43 -40
  9. package/cli/commands/info.js +218 -17
  10. package/cli/commands/sniffer/sniffer-menu.js +2 -2
  11. package/cli/commands/status/device-status.js +418 -1292
  12. package/cli/commands/status/hub-status.js +14 -6
  13. package/cli/control-registry.js +211 -406
  14. package/cli/meross-cli.js +1 -1
  15. package/cli/tests/README.md +2 -0
  16. package/cli/tests/test-alarm.js +22 -2
  17. package/cli/tests/test-child-lock.js +40 -10
  18. package/cli/tests/test-config.js +22 -2
  19. package/cli/tests/test-control.js +8 -8
  20. package/cli/tests/test-diffuser.js +7 -7
  21. package/cli/tests/test-dnd.js +87 -66
  22. package/cli/tests/test-electricity.js +37 -33
  23. package/cli/tests/test-encryption.js +13 -13
  24. package/cli/tests/test-garage.js +12 -14
  25. package/cli/tests/test-helper.js +1 -1
  26. package/cli/tests/test-hub-sensors.js +3 -3
  27. package/cli/tests/test-light.js +497 -105
  28. package/cli/tests/test-presence.js +10 -55
  29. package/cli/tests/test-registry.js +7 -1
  30. package/cli/tests/test-roller-shutter.js +78 -90
  31. package/cli/tests/test-screen.js +1 -1
  32. package/cli/tests/test-sensor-history.js +6 -2
  33. package/cli/tests/test-smoke-config.js +24 -4
  34. package/cli/tests/test-spray.js +11 -11
  35. package/cli/tests/test-system.js +375 -0
  36. package/cli/tests/test-temp-unit.js +22 -2
  37. package/cli/tests/test-template.js +61 -73
  38. package/cli/tests/test-thermostat.js +126 -89
  39. package/cli/tests/test-timer.js +9 -52
  40. package/cli/tests/test-toggle.js +49 -173
  41. package/cli/tests/test-trigger.js +8 -51
  42. package/package.json +2 -2
@@ -3,6 +3,16 @@
3
3
  const chalk = require('chalk');
4
4
  const { displaySubdeviceStatus } = require('./subdevices');
5
5
 
6
+ /**
7
+ * Displays hub device status including all subdevices.
8
+ *
9
+ * Refreshes hub state to get latest subdevice data, fetches battery information
10
+ * for sensors, and displays status for each subdevice.
11
+ *
12
+ * @param {Object} device - Hub device instance
13
+ * @param {string|null} filterSubdeviceId - Optional subdevice ID to filter to a single subdevice
14
+ * @returns {Promise<boolean>} True if any readings were displayed, false otherwise
15
+ */
6
16
  async function displayHubStatus(device, filterSubdeviceId = null) {
7
17
  const subdevices = filterSubdeviceId
8
18
  ? [device.getSubdevice(filterSubdeviceId)].filter(Boolean)
@@ -17,14 +27,12 @@ async function displayHubStatus(device, filterSubdeviceId = null) {
17
27
  return false;
18
28
  }
19
29
 
20
- // Refresh hub state to get latest subdevice data
21
30
  try {
22
31
  await device.refreshState();
23
32
 
24
- // Also fetch battery data for sensors
25
33
  try {
26
- if (typeof device.getHubBattery === 'function') {
27
- const batteryResponse = await device.getHubBattery();
34
+ if (device.hub && typeof device.hub.getBattery === 'function') {
35
+ const batteryResponse = await device.hub.getBattery();
28
36
  if (batteryResponse && batteryResponse.battery && Array.isArray(batteryResponse.battery)) {
29
37
  for (const batteryData of batteryResponse.battery) {
30
38
  const subdeviceId = batteryData.id;
@@ -37,10 +45,10 @@ async function displayHubStatus(device, filterSubdeviceId = null) {
37
45
  }
38
46
  }
39
47
  } catch {
40
- // Battery fetch failed, but continue anyway
48
+ // Continue without battery data if fetch fails
41
49
  }
42
50
  } catch (error) {
43
- // Silently fail - continue with cached data
51
+ // Continue with cached data if refresh fails
44
52
  }
45
53
 
46
54
  if (!filterSubdeviceId) {