@switchbot/homebridge-switchbot 5.0.0-beta.0 → 5.0.0-beta.2

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 (110) hide show
  1. package/dist/devices-matter/ColorLightAccessory.d.ts +3 -1
  2. package/dist/devices-matter/ColorLightAccessory.d.ts.map +1 -1
  3. package/dist/devices-matter/ColorLightAccessory.js +35 -36
  4. package/dist/devices-matter/ColorLightAccessory.js.map +1 -1
  5. package/dist/devices-matter/ColorTemperatureLightAccessory.d.ts +3 -1
  6. package/dist/devices-matter/ColorTemperatureLightAccessory.d.ts.map +1 -1
  7. package/dist/devices-matter/ColorTemperatureLightAccessory.js +32 -37
  8. package/dist/devices-matter/ColorTemperatureLightAccessory.js.map +1 -1
  9. package/dist/devices-matter/ContactSensorAccessory.d.ts +3 -1
  10. package/dist/devices-matter/ContactSensorAccessory.d.ts.map +1 -1
  11. package/dist/devices-matter/ContactSensorAccessory.js +16 -13
  12. package/dist/devices-matter/ContactSensorAccessory.js.map +1 -1
  13. package/dist/devices-matter/DimmableLightAccessory.d.ts +3 -1
  14. package/dist/devices-matter/DimmableLightAccessory.d.ts.map +1 -1
  15. package/dist/devices-matter/DimmableLightAccessory.js +24 -27
  16. package/dist/devices-matter/DimmableLightAccessory.js.map +1 -1
  17. package/dist/devices-matter/DoorLockAccessory.d.ts +3 -1
  18. package/dist/devices-matter/DoorLockAccessory.d.ts.map +1 -1
  19. package/dist/devices-matter/DoorLockAccessory.js +25 -22
  20. package/dist/devices-matter/DoorLockAccessory.js.map +1 -1
  21. package/dist/devices-matter/ExtendedColorLightAccessory.d.ts +3 -1
  22. package/dist/devices-matter/ExtendedColorLightAccessory.d.ts.map +1 -1
  23. package/dist/devices-matter/ExtendedColorLightAccessory.js +40 -41
  24. package/dist/devices-matter/ExtendedColorLightAccessory.js.map +1 -1
  25. package/dist/devices-matter/FanAccessory.d.ts +3 -1
  26. package/dist/devices-matter/FanAccessory.d.ts.map +1 -1
  27. package/dist/devices-matter/FanAccessory.js +31 -23
  28. package/dist/devices-matter/FanAccessory.js.map +1 -1
  29. package/dist/devices-matter/HumiditySensorAccessory.d.ts +3 -1
  30. package/dist/devices-matter/HumiditySensorAccessory.d.ts.map +1 -1
  31. package/dist/devices-matter/HumiditySensorAccessory.js +16 -15
  32. package/dist/devices-matter/HumiditySensorAccessory.js.map +1 -1
  33. package/dist/devices-matter/LeakSensorAccessory.d.ts +3 -1
  34. package/dist/devices-matter/LeakSensorAccessory.d.ts.map +1 -1
  35. package/dist/devices-matter/LeakSensorAccessory.js +16 -13
  36. package/dist/devices-matter/LeakSensorAccessory.js.map +1 -1
  37. package/dist/devices-matter/LightSensorAccessory.d.ts +3 -1
  38. package/dist/devices-matter/LightSensorAccessory.d.ts.map +1 -1
  39. package/dist/devices-matter/LightSensorAccessory.js +16 -15
  40. package/dist/devices-matter/LightSensorAccessory.js.map +1 -1
  41. package/dist/devices-matter/OccupancySensorAccessory.d.ts +3 -1
  42. package/dist/devices-matter/OccupancySensorAccessory.d.ts.map +1 -1
  43. package/dist/devices-matter/OccupancySensorAccessory.js +17 -21
  44. package/dist/devices-matter/OccupancySensorAccessory.js.map +1 -1
  45. package/dist/devices-matter/OnOffLightAccessory.d.ts +3 -1
  46. package/dist/devices-matter/OnOffLightAccessory.d.ts.map +1 -1
  47. package/dist/devices-matter/OnOffLightAccessory.js +22 -21
  48. package/dist/devices-matter/OnOffLightAccessory.js.map +1 -1
  49. package/dist/devices-matter/OnOffOutletAccessory.d.ts +3 -3
  50. package/dist/devices-matter/OnOffOutletAccessory.d.ts.map +1 -1
  51. package/dist/devices-matter/OnOffOutletAccessory.js +24 -27
  52. package/dist/devices-matter/OnOffOutletAccessory.js.map +1 -1
  53. package/dist/devices-matter/OnOffSwitchAccessory.d.ts +3 -1
  54. package/dist/devices-matter/OnOffSwitchAccessory.d.ts.map +1 -1
  55. package/dist/devices-matter/OnOffSwitchAccessory.js +18 -19
  56. package/dist/devices-matter/OnOffSwitchAccessory.js.map +1 -1
  57. package/dist/devices-matter/RoboticVacuumAccessory.d.ts +3 -1
  58. package/dist/devices-matter/RoboticVacuumAccessory.d.ts.map +1 -1
  59. package/dist/devices-matter/RoboticVacuumAccessory.js +77 -145
  60. package/dist/devices-matter/RoboticVacuumAccessory.js.map +1 -1
  61. package/dist/devices-matter/TemperatureSensorAccessory.d.ts +3 -1
  62. package/dist/devices-matter/TemperatureSensorAccessory.d.ts.map +1 -1
  63. package/dist/devices-matter/TemperatureSensorAccessory.js +18 -15
  64. package/dist/devices-matter/TemperatureSensorAccessory.js.map +1 -1
  65. package/dist/devices-matter/ThermostatAccessory.d.ts +3 -1
  66. package/dist/devices-matter/ThermostatAccessory.d.ts.map +1 -1
  67. package/dist/devices-matter/ThermostatAccessory.js +37 -29
  68. package/dist/devices-matter/ThermostatAccessory.js.map +1 -1
  69. package/dist/devices-matter/VenetianBlindAccessory.d.ts +3 -1
  70. package/dist/devices-matter/VenetianBlindAccessory.d.ts.map +1 -1
  71. package/dist/devices-matter/VenetianBlindAccessory.js +39 -40
  72. package/dist/devices-matter/VenetianBlindAccessory.js.map +1 -1
  73. package/dist/devices-matter/WindowBlindAccessory.d.ts +3 -1
  74. package/dist/devices-matter/WindowBlindAccessory.d.ts.map +1 -1
  75. package/dist/devices-matter/WindowBlindAccessory.js +36 -37
  76. package/dist/devices-matter/WindowBlindAccessory.js.map +1 -1
  77. package/dist/platform-hap.d.ts.map +1 -1
  78. package/dist/platform-hap.js +18 -1
  79. package/dist/platform-hap.js.map +1 -1
  80. package/dist/platform-matter.d.ts.map +1 -1
  81. package/dist/platform-matter.js +17 -0
  82. package/dist/platform-matter.js.map +1 -1
  83. package/dist/utils.d.ts +5 -0
  84. package/dist/utils.d.ts.map +1 -1
  85. package/dist/utils.js +43 -0
  86. package/dist/utils.js.map +1 -1
  87. package/docs/variables/default.html +1 -1
  88. package/package.json +1 -1
  89. package/src/devices-matter/ColorLightAccessory.ts +37 -40
  90. package/src/devices-matter/ColorTemperatureLightAccessory.ts +35 -41
  91. package/src/devices-matter/ContactSensorAccessory.ts +18 -14
  92. package/src/devices-matter/DimmableLightAccessory.ts +26 -30
  93. package/src/devices-matter/DoorLockAccessory.ts +28 -24
  94. package/src/devices-matter/ExtendedColorLightAccessory.ts +43 -47
  95. package/src/devices-matter/FanAccessory.ts +33 -25
  96. package/src/devices-matter/HumiditySensorAccessory.ts +18 -16
  97. package/src/devices-matter/LeakSensorAccessory.ts +18 -14
  98. package/src/devices-matter/LightSensorAccessory.ts +18 -16
  99. package/src/devices-matter/OccupancySensorAccessory.ts +18 -22
  100. package/src/devices-matter/OnOffLightAccessory.ts +23 -23
  101. package/src/devices-matter/OnOffOutletAccessory.ts +25 -31
  102. package/src/devices-matter/OnOffSwitchAccessory.ts +20 -21
  103. package/src/devices-matter/RoboticVacuumAccessory.ts +79 -156
  104. package/src/devices-matter/TemperatureSensorAccessory.ts +20 -16
  105. package/src/devices-matter/ThermostatAccessory.ts +39 -34
  106. package/src/devices-matter/VenetianBlindAccessory.ts +41 -44
  107. package/src/devices-matter/WindowBlindAccessory.ts +37 -39
  108. package/src/platform-hap.ts +16 -1
  109. package/src/platform-matter.ts +15 -0
  110. package/src/utils.ts +49 -0
@@ -32,6 +32,7 @@ import {
32
32
  WindowBlindAccessory,
33
33
  } from './devices-matter/index.js'
34
34
  import { PLATFORM_NAME, PLUGIN_NAME } from './settings.js'
35
+ import { cleanDeviceConfig } from './utils.js'
35
36
 
36
37
  /**
37
38
  * MatterPlatform
@@ -54,6 +55,20 @@ export class SwitchBotMatterPlatform implements DynamicPlatformPlugin {
54
55
  ) {
55
56
  this.log.debug('Finished initializing platform:', this.config.name)
56
57
 
58
+ // Normalize deviceConfig to remove UI-inserted defaults
59
+ try {
60
+ if ((this.config as any).options) {
61
+ const cleaned = cleanDeviceConfig((this.config as any).options.deviceConfig)
62
+ if (cleaned) {
63
+ ;(this.config as any).options.deviceConfig = cleaned
64
+ } else {
65
+ delete (this.config as any).options.deviceConfig
66
+ }
67
+ }
68
+ } catch (e) {
69
+ this.log.debug('Failed to clean deviceConfig: %s', e)
70
+ }
71
+
57
72
  // Does the user have a version of Homebridge that is compatible with matter?
58
73
  if (!this.api.isMatterAvailable?.()) {
59
74
  this.log.warn('Matter is not available in this version of Homebridge. Please update Homebridge to use this plugin.')
package/src/utils.ts CHANGED
@@ -667,3 +667,52 @@ export function m2hs(m) {
667
667
  const toReturn = table[input]
668
668
  return [Math.round(toReturn[1]), Math.round(toReturn[0])]
669
669
  }
670
+
671
+ /**
672
+ * Remove deviceConfig entries that contain only default/empty values.
673
+ * Returns undefined if nothing meaningful remains.
674
+ */
675
+ export function cleanDeviceConfig(deviceConfig?: Record<string, Record<string, any>>): Record<string, Record<string, any>> | undefined {
676
+ if (!deviceConfig || typeof deviceConfig !== 'object') {
677
+ return undefined
678
+ }
679
+
680
+ const cleaned: Record<string, Record<string, any>> = {}
681
+
682
+ for (const [deviceName, cfg] of Object.entries(deviceConfig)) {
683
+ if (!cfg || typeof cfg !== 'object') {
684
+ continue
685
+ }
686
+
687
+ const hasMeaningful = Object.values(cfg).some((v) => {
688
+ if (v === null || v === undefined) {
689
+ return false
690
+ }
691
+ if (typeof v === 'boolean') {
692
+ return v === true
693
+ }
694
+ if (typeof v === 'string') {
695
+ return v.trim().length > 0
696
+ }
697
+ if (typeof v === 'number') {
698
+ return Number.isFinite(v)
699
+ }
700
+ if (Array.isArray(v)) {
701
+ return v.length > 0
702
+ }
703
+ if (typeof v === 'object') {
704
+ return Object.keys(v).length > 0
705
+ }
706
+ return true
707
+ })
708
+
709
+ if (hasMeaningful) {
710
+ cleaned[deviceName] = cfg
711
+ }
712
+ }
713
+
714
+ if (Object.keys(cleaned).length > 0) {
715
+ return cleaned
716
+ }
717
+ return undefined
718
+ }