@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.
- package/dist/devices-matter/ColorLightAccessory.d.ts +3 -1
- package/dist/devices-matter/ColorLightAccessory.d.ts.map +1 -1
- package/dist/devices-matter/ColorLightAccessory.js +35 -36
- package/dist/devices-matter/ColorLightAccessory.js.map +1 -1
- package/dist/devices-matter/ColorTemperatureLightAccessory.d.ts +3 -1
- package/dist/devices-matter/ColorTemperatureLightAccessory.d.ts.map +1 -1
- package/dist/devices-matter/ColorTemperatureLightAccessory.js +32 -37
- package/dist/devices-matter/ColorTemperatureLightAccessory.js.map +1 -1
- package/dist/devices-matter/ContactSensorAccessory.d.ts +3 -1
- package/dist/devices-matter/ContactSensorAccessory.d.ts.map +1 -1
- package/dist/devices-matter/ContactSensorAccessory.js +16 -13
- package/dist/devices-matter/ContactSensorAccessory.js.map +1 -1
- package/dist/devices-matter/DimmableLightAccessory.d.ts +3 -1
- package/dist/devices-matter/DimmableLightAccessory.d.ts.map +1 -1
- package/dist/devices-matter/DimmableLightAccessory.js +24 -27
- package/dist/devices-matter/DimmableLightAccessory.js.map +1 -1
- package/dist/devices-matter/DoorLockAccessory.d.ts +3 -1
- package/dist/devices-matter/DoorLockAccessory.d.ts.map +1 -1
- package/dist/devices-matter/DoorLockAccessory.js +25 -22
- package/dist/devices-matter/DoorLockAccessory.js.map +1 -1
- package/dist/devices-matter/ExtendedColorLightAccessory.d.ts +3 -1
- package/dist/devices-matter/ExtendedColorLightAccessory.d.ts.map +1 -1
- package/dist/devices-matter/ExtendedColorLightAccessory.js +40 -41
- package/dist/devices-matter/ExtendedColorLightAccessory.js.map +1 -1
- package/dist/devices-matter/FanAccessory.d.ts +3 -1
- package/dist/devices-matter/FanAccessory.d.ts.map +1 -1
- package/dist/devices-matter/FanAccessory.js +31 -23
- package/dist/devices-matter/FanAccessory.js.map +1 -1
- package/dist/devices-matter/HumiditySensorAccessory.d.ts +3 -1
- package/dist/devices-matter/HumiditySensorAccessory.d.ts.map +1 -1
- package/dist/devices-matter/HumiditySensorAccessory.js +16 -15
- package/dist/devices-matter/HumiditySensorAccessory.js.map +1 -1
- package/dist/devices-matter/LeakSensorAccessory.d.ts +3 -1
- package/dist/devices-matter/LeakSensorAccessory.d.ts.map +1 -1
- package/dist/devices-matter/LeakSensorAccessory.js +16 -13
- package/dist/devices-matter/LeakSensorAccessory.js.map +1 -1
- package/dist/devices-matter/LightSensorAccessory.d.ts +3 -1
- package/dist/devices-matter/LightSensorAccessory.d.ts.map +1 -1
- package/dist/devices-matter/LightSensorAccessory.js +16 -15
- package/dist/devices-matter/LightSensorAccessory.js.map +1 -1
- package/dist/devices-matter/OccupancySensorAccessory.d.ts +3 -1
- package/dist/devices-matter/OccupancySensorAccessory.d.ts.map +1 -1
- package/dist/devices-matter/OccupancySensorAccessory.js +17 -21
- package/dist/devices-matter/OccupancySensorAccessory.js.map +1 -1
- package/dist/devices-matter/OnOffLightAccessory.d.ts +3 -1
- package/dist/devices-matter/OnOffLightAccessory.d.ts.map +1 -1
- package/dist/devices-matter/OnOffLightAccessory.js +22 -21
- package/dist/devices-matter/OnOffLightAccessory.js.map +1 -1
- package/dist/devices-matter/OnOffOutletAccessory.d.ts +3 -3
- package/dist/devices-matter/OnOffOutletAccessory.d.ts.map +1 -1
- package/dist/devices-matter/OnOffOutletAccessory.js +24 -27
- package/dist/devices-matter/OnOffOutletAccessory.js.map +1 -1
- package/dist/devices-matter/OnOffSwitchAccessory.d.ts +3 -1
- package/dist/devices-matter/OnOffSwitchAccessory.d.ts.map +1 -1
- package/dist/devices-matter/OnOffSwitchAccessory.js +18 -19
- package/dist/devices-matter/OnOffSwitchAccessory.js.map +1 -1
- package/dist/devices-matter/RoboticVacuumAccessory.d.ts +3 -1
- package/dist/devices-matter/RoboticVacuumAccessory.d.ts.map +1 -1
- package/dist/devices-matter/RoboticVacuumAccessory.js +77 -145
- package/dist/devices-matter/RoboticVacuumAccessory.js.map +1 -1
- package/dist/devices-matter/TemperatureSensorAccessory.d.ts +3 -1
- package/dist/devices-matter/TemperatureSensorAccessory.d.ts.map +1 -1
- package/dist/devices-matter/TemperatureSensorAccessory.js +18 -15
- package/dist/devices-matter/TemperatureSensorAccessory.js.map +1 -1
- package/dist/devices-matter/ThermostatAccessory.d.ts +3 -1
- package/dist/devices-matter/ThermostatAccessory.d.ts.map +1 -1
- package/dist/devices-matter/ThermostatAccessory.js +37 -29
- package/dist/devices-matter/ThermostatAccessory.js.map +1 -1
- package/dist/devices-matter/VenetianBlindAccessory.d.ts +3 -1
- package/dist/devices-matter/VenetianBlindAccessory.d.ts.map +1 -1
- package/dist/devices-matter/VenetianBlindAccessory.js +39 -40
- package/dist/devices-matter/VenetianBlindAccessory.js.map +1 -1
- package/dist/devices-matter/WindowBlindAccessory.d.ts +3 -1
- package/dist/devices-matter/WindowBlindAccessory.d.ts.map +1 -1
- package/dist/devices-matter/WindowBlindAccessory.js +36 -37
- package/dist/devices-matter/WindowBlindAccessory.js.map +1 -1
- package/dist/platform-hap.d.ts.map +1 -1
- package/dist/platform-hap.js +18 -1
- package/dist/platform-hap.js.map +1 -1
- package/dist/platform-matter.d.ts.map +1 -1
- package/dist/platform-matter.js +17 -0
- package/dist/platform-matter.js.map +1 -1
- package/dist/utils.d.ts +5 -0
- package/dist/utils.d.ts.map +1 -1
- package/dist/utils.js +43 -0
- package/dist/utils.js.map +1 -1
- package/docs/variables/default.html +1 -1
- package/package.json +1 -1
- package/src/devices-matter/ColorLightAccessory.ts +37 -40
- package/src/devices-matter/ColorTemperatureLightAccessory.ts +35 -41
- package/src/devices-matter/ContactSensorAccessory.ts +18 -14
- package/src/devices-matter/DimmableLightAccessory.ts +26 -30
- package/src/devices-matter/DoorLockAccessory.ts +28 -24
- package/src/devices-matter/ExtendedColorLightAccessory.ts +43 -47
- package/src/devices-matter/FanAccessory.ts +33 -25
- package/src/devices-matter/HumiditySensorAccessory.ts +18 -16
- package/src/devices-matter/LeakSensorAccessory.ts +18 -14
- package/src/devices-matter/LightSensorAccessory.ts +18 -16
- package/src/devices-matter/OccupancySensorAccessory.ts +18 -22
- package/src/devices-matter/OnOffLightAccessory.ts +23 -23
- package/src/devices-matter/OnOffOutletAccessory.ts +25 -31
- package/src/devices-matter/OnOffSwitchAccessory.ts +20 -21
- package/src/devices-matter/RoboticVacuumAccessory.ts +79 -156
- package/src/devices-matter/TemperatureSensorAccessory.ts +20 -16
- package/src/devices-matter/ThermostatAccessory.ts +39 -34
- package/src/devices-matter/VenetianBlindAccessory.ts +41 -44
- package/src/devices-matter/WindowBlindAccessory.ts +37 -39
- package/src/platform-hap.ts +16 -1
- package/src/platform-matter.ts +15 -0
- package/src/utils.ts +49 -0
package/src/platform-matter.ts
CHANGED
|
@@ -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
|
+
}
|