Skip to content

Commit 75f6433

Browse files
author
homebridge-bot
committed
a
1 parent 0709353 commit 75f6433

File tree

3 files changed

+63
-21
lines changed

3 files changed

+63
-21
lines changed

config.schema.json

Lines changed: 41 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -27,18 +27,6 @@
2727
"description": "Optional OpenAPI secret for certain account setups.",
2828
"format": "password"
2929
},
30-
"enableMatter": {
31-
"type": "boolean",
32-
"title": "Enable Matter Support",
33-
"default": true,
34-
"description": "Allow the plugin to register Matter accessories when Homebridge Matter is available."
35-
},
36-
"preferMatter": {
37-
"type": "boolean",
38-
"title": "Prefer Matter when available",
39-
"default": true,
40-
"description": "If enabled and Matter is available, device will be presented as Matter accessories where supported."
41-
},
4230
"devices": {
4331
"type": "array",
4432
"title": "Devices",
@@ -100,7 +88,47 @@
10088
}
10189
}
10290
}
91+
},
92+
"enableMatter": {
93+
"type": "boolean",
94+
"title": "Enable Matter Support (Override)",
95+
"description": "Manually enable Matter support. By default, Matter is auto-detected from the child bridge configuration. Only change this if you need to override the auto-detection."
96+
},
97+
"preferMatter": {
98+
"type": "boolean",
99+
"title": "Prefer Matter when available",
100+
"description": "If enabled and Matter is available, devices will be presented as Matter accessories where supported (instead of HAP)."
103101
}
104102
}
105-
}
103+
},
104+
"layout": [
105+
{
106+
"type": "fieldset",
107+
"title": "API Credentials",
108+
"expandable": false,
109+
"items": [
110+
"name",
111+
"openApiToken",
112+
"openApiSecret"
113+
]
114+
},
115+
{
116+
"type": "fieldset",
117+
"title": "Devices",
118+
"expandable": false,
119+
"items": [
120+
"devices"
121+
]
122+
},
123+
{
124+
"type": "fieldset",
125+
"title": "Advanced Settings",
126+
"expandable": true,
127+
"expanded": false,
128+
"items": [
129+
"enableMatter",
130+
"preferMatter"
131+
]
132+
}
133+
]
106134
}

docs/variables/default.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
<!DOCTYPE html><html class="default" lang="en" data-base="../"><head><meta charset="utf-8"/><meta http-equiv="x-ua-compatible" content="IE=edge"/><title>default | @switchbot/homebridge-switchbot</title><meta name="description" content="Documentation for @switchbot/homebridge-switchbot"/><meta name="viewport" content="width=device-width, initial-scale=1"/><link rel="stylesheet" href="../assets/style.css"/><link rel="stylesheet" href="../assets/highlight.css"/><script defer src="../assets/main.js"></script><script async src="../assets/icons.js" id="tsd-icons-script"></script><script async src="../assets/search.js" id="tsd-search-script"></script><script async src="../assets/navigation.js" id="tsd-nav-script"></script></head><body><script>document.documentElement.dataset.theme = localStorage.getItem("tsd-theme") || "os";document.body.style.display="none";setTimeout(() => window.app?app.showPage():document.body.style.removeProperty("display"),500)</script><header class="tsd-page-toolbar"><div class="tsd-toolbar-contents container"><a href="../index.html" class="title">@switchbot/homebridge-switchbot</a><div id="tsd-toolbar-links"></div><button id="tsd-search-trigger" class="tsd-widget" aria-label="Search"><svg width="16" height="16" viewBox="0 0 16 16" fill="none" aria-hidden="true"><use href="../assets/icons.svg#icon-search"></use></svg></button><dialog id="tsd-search" aria-label="Search"><input role="combobox" id="tsd-search-input" aria-controls="tsd-search-results" aria-autocomplete="list" aria-expanded="true" autocapitalize="off" autocomplete="off" placeholder="Search the docs" maxLength="100"/><ul role="listbox" id="tsd-search-results"></ul><div id="tsd-search-status" aria-live="polite" aria-atomic="true"><div>Preparing search index...</div></div></dialog><a href="#" class="tsd-widget menu" id="tsd-toolbar-menu-trigger" data-toggle="menu" aria-label="Menu"><svg width="16" height="16" viewBox="0 0 16 16" fill="none" aria-hidden="true"><use href="../assets/icons.svg#icon-menu"></use></svg></a></div></header><div class="container container-main"><div class="col-content"><div class="tsd-page-title"><ul class="tsd-breadcrumb" aria-label="Breadcrumb"><li><a href="" aria-current="page">default</a></li></ul><h1>Variable default</h1></div><div class="tsd-signature"><span class="tsd-kind-variable">default</span><span class="tsd-signature-symbol">:</span> <span class="tsd-signature-symbol">(</span><span class="tsd-kind-parameter">api</span><span class="tsd-signature-symbol">:</span> <span class="tsd-signature-type">API</span><span class="tsd-signature-symbol">)</span> <span class="tsd-signature-symbol">=&gt;</span> <span class="tsd-signature-type">void</span></div><div class="tsd-type-declaration"><h4>Type Declaration</h4><ul class="tsd-parameters"><li class="tsd-parameter-signature"><ul class="tsd-signatures"><li class="tsd-signature" id="__type"><span class="tsd-signature-symbol">(</span><span class="tsd-kind-parameter">api</span><span class="tsd-signature-symbol">:</span> <span class="tsd-signature-type">API</span><span class="tsd-signature-symbol">)</span><span class="tsd-signature-symbol">:</span> <span class="tsd-signature-type">void</span></li><li class="tsd-description"><div class="tsd-parameters"><h4 class="tsd-parameters-title">Parameters</h4><ul class="tsd-parameter-list"><li><span><span class="tsd-kind-parameter">api</span>: <span class="tsd-signature-type">API</span></span></li></ul></div><h4 class="tsd-returns-title">Returns <span class="tsd-signature-type">void</span></h4></li></ul></li></ul></div><aside class="tsd-sources"><ul><li>Defined in <a href="https://github.com/OpenWonderLabs/homebridge-switchbot/blob/0c3bba22e06039260e02162e71169960ccffbc82/src/index.ts#L12">index.ts:12</a></li></ul></aside></div><div class="col-sidebar"><div class="page-menu"><div class="tsd-navigation settings"><details class="tsd-accordion"><summary class="tsd-accordion-summary"><svg width="20" height="20" viewBox="0 0 24 24" fill="none" aria-hidden="true"><use href="../assets/icons.svg#icon-chevronDown"></use></svg><h3>Settings</h3></summary><div class="tsd-accordion-details"><div class="tsd-filter-visibility"><span class="settings-label">Member Visibility</span><ul id="tsd-filter-options"><li class="tsd-filter-item"><label class="tsd-filter-input"><input type="checkbox" id="tsd-filter-inherited" name="inherited" checked/><svg width="32" height="32" viewBox="0 0 32 32" aria-hidden="true"><rect class="tsd-checkbox-background" width="30" height="30" x="1" y="1" rx="6" fill="none"></rect><path class="tsd-checkbox-checkmark" d="M8.35422 16.8214L13.2143 21.75L24.6458 10.25" stroke="none" stroke-width="3.5" stroke-linejoin="round" fill="none"></path></svg><span>Inherited</span></label></li></ul></div><div class="tsd-theme-toggle"><label class="settings-label" for="tsd-theme">Theme</label><select id="tsd-theme"><option value="os">OS</option><option value="light">Light</option><option value="dark">Dark</option></select></div></div></details></div></div><div class="site-menu"><nav class="tsd-navigation"><a href="../modules.html">@switchbot/homebridge-switchbot</a><ul class="tsd-small-nested-navigation" id="tsd-nav-container"><li>Loading...</li></ul></nav></div></div></div><footer></footer><div class="overlay"></div></body></html>
1+
<!DOCTYPE html><html class="default" lang="en" data-base="../"><head><meta charset="utf-8"/><meta http-equiv="x-ua-compatible" content="IE=edge"/><title>default | @switchbot/homebridge-switchbot</title><meta name="description" content="Documentation for @switchbot/homebridge-switchbot"/><meta name="viewport" content="width=device-width, initial-scale=1"/><link rel="stylesheet" href="../assets/style.css"/><link rel="stylesheet" href="../assets/highlight.css"/><script defer src="../assets/main.js"></script><script async src="../assets/icons.js" id="tsd-icons-script"></script><script async src="../assets/search.js" id="tsd-search-script"></script><script async src="../assets/navigation.js" id="tsd-nav-script"></script></head><body><script>document.documentElement.dataset.theme = localStorage.getItem("tsd-theme") || "os";document.body.style.display="none";setTimeout(() => window.app?app.showPage():document.body.style.removeProperty("display"),500)</script><header class="tsd-page-toolbar"><div class="tsd-toolbar-contents container"><a href="../index.html" class="title">@switchbot/homebridge-switchbot</a><div id="tsd-toolbar-links"></div><button id="tsd-search-trigger" class="tsd-widget" aria-label="Search"><svg width="16" height="16" viewBox="0 0 16 16" fill="none" aria-hidden="true"><use href="../assets/icons.svg#icon-search"></use></svg></button><dialog id="tsd-search" aria-label="Search"><input role="combobox" id="tsd-search-input" aria-controls="tsd-search-results" aria-autocomplete="list" aria-expanded="true" autocapitalize="off" autocomplete="off" placeholder="Search the docs" maxLength="100"/><ul role="listbox" id="tsd-search-results"></ul><div id="tsd-search-status" aria-live="polite" aria-atomic="true"><div>Preparing search index...</div></div></dialog><a href="#" class="tsd-widget menu" id="tsd-toolbar-menu-trigger" data-toggle="menu" aria-label="Menu"><svg width="16" height="16" viewBox="0 0 16 16" fill="none" aria-hidden="true"><use href="../assets/icons.svg#icon-menu"></use></svg></a></div></header><div class="container container-main"><div class="col-content"><div class="tsd-page-title"><ul class="tsd-breadcrumb" aria-label="Breadcrumb"><li><a href="" aria-current="page">default</a></li></ul><h1>Variable default</h1></div><div class="tsd-signature"><span class="tsd-kind-variable">default</span><span class="tsd-signature-symbol">:</span> <span class="tsd-signature-symbol">(</span><span class="tsd-kind-parameter">api</span><span class="tsd-signature-symbol">:</span> <span class="tsd-signature-type">API</span><span class="tsd-signature-symbol">)</span> <span class="tsd-signature-symbol">=&gt;</span> <span class="tsd-signature-type">void</span></div><div class="tsd-type-declaration"><h4>Type Declaration</h4><ul class="tsd-parameters"><li class="tsd-parameter-signature"><ul class="tsd-signatures"><li class="tsd-signature" id="__type"><span class="tsd-signature-symbol">(</span><span class="tsd-kind-parameter">api</span><span class="tsd-signature-symbol">:</span> <span class="tsd-signature-type">API</span><span class="tsd-signature-symbol">)</span><span class="tsd-signature-symbol">:</span> <span class="tsd-signature-type">void</span></li><li class="tsd-description"><div class="tsd-parameters"><h4 class="tsd-parameters-title">Parameters</h4><ul class="tsd-parameter-list"><li><span><span class="tsd-kind-parameter">api</span>: <span class="tsd-signature-type">API</span></span></li></ul></div><h4 class="tsd-returns-title">Returns <span class="tsd-signature-type">void</span></h4></li></ul></li></ul></div><aside class="tsd-sources"><ul><li>Defined in <a href="https://github.com/OpenWonderLabs/homebridge-switchbot/blob/0709353aaaf5749adeb9c5218ee69003f2f539e0/src/index.ts#L12">index.ts:12</a></li></ul></aside></div><div class="col-sidebar"><div class="page-menu"><div class="tsd-navigation settings"><details class="tsd-accordion"><summary class="tsd-accordion-summary"><svg width="20" height="20" viewBox="0 0 24 24" fill="none" aria-hidden="true"><use href="../assets/icons.svg#icon-chevronDown"></use></svg><h3>Settings</h3></summary><div class="tsd-accordion-details"><div class="tsd-filter-visibility"><span class="settings-label">Member Visibility</span><ul id="tsd-filter-options"><li class="tsd-filter-item"><label class="tsd-filter-input"><input type="checkbox" id="tsd-filter-inherited" name="inherited" checked/><svg width="32" height="32" viewBox="0 0 32 32" aria-hidden="true"><rect class="tsd-checkbox-background" width="30" height="30" x="1" y="1" rx="6" fill="none"></rect><path class="tsd-checkbox-checkmark" d="M8.35422 16.8214L13.2143 21.75L24.6458 10.25" stroke="none" stroke-width="3.5" stroke-linejoin="round" fill="none"></path></svg><span>Inherited</span></label></li></ul></div><div class="tsd-theme-toggle"><label class="settings-label" for="tsd-theme">Theme</label><select id="tsd-theme"><option value="os">OS</option><option value="light">Light</option><option value="dark">Dark</option></select></div></div></details></div></div><div class="site-menu"><nav class="tsd-navigation"><a href="../modules.html">@switchbot/homebridge-switchbot</a><ul class="tsd-small-nested-navigation" id="tsd-nav-container"><li>Loading...</li></ul></nav></div></div></div><footer></footer><div class="overlay"></div></body></html>

src/platform.ts

Lines changed: 21 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -114,7 +114,10 @@ export class SwitchBotHAPPlatform {
114114
type = 'vacuum'
115115
}
116116
const matterSupported = !!DEVICE_MATTER_SUPPORTED[(type || '').toLowerCase()]
117-
const useMatter = !!this.config.enableMatter && matterSupported && !!this.config.preferMatter
117+
// Auto-detect Matter from Homebridge API, allow manual override via config
118+
const matterAvailable = !!(this.api?.isMatterAvailable?.() && this.api?.isMatterEnabled?.())
119+
const matterEnabled = matterAvailable || !!this.config.enableMatter
120+
const useMatter = !!(matterEnabled && matterSupported && (!!this.config.preferMatter || matterAvailable))
118121

119122
try {
120123
const created = await createDevice({ id: d.id, type, name: d.name }, this.config, useMatter)
@@ -346,15 +349,18 @@ export class SwitchBotMatterPlatform {
346349
type = 'vacuum'
347350
}
348351
const matterSupported = !!DEVICE_MATTER_SUPPORTED[(type || '').toLowerCase()]
349-
const useMatter = !!this.config.enableMatter && matterSupported
352+
// Auto-detect Matter from Homebridge API, allow manual override via config
353+
const matterAvailable = this.api?.isMatterAvailable?.() && this.api?.isMatterEnabled?.()
354+
const matterEnabled = matterAvailable || !!this.config.enableMatter
355+
const useMatter = matterEnabled && matterSupported
350356
try {
351357
const created = await createDevice({ id: d.id, type, name: d.name }, this.config, useMatter)
352358
this.devices.push(created)
353359
if (useMatter) {
354-
this.log.info(`Prepared Matter accessory for ${d.id} (${type})`)
360+
this.log.info(`Prepared Matter accessory for ${d.id} (${type})${matterAvailable ? ' (auto-detected)' : ' (manually enabled)'})`)
355361
} else {
356-
if (!this.config.enableMatter) {
357-
this.log.info(`Skipping Matter for ${d.id} (${type}) - Matter not enabled in plugin config`)
362+
if (!matterEnabled) {
363+
this.log.info(`Skipping Matter for ${d.id} (${type}) - Matter not available on this bridge`)
358364
} else if (!matterSupported) {
359365
this.log.info(`Skipping Matter for ${d.id} (${type}) - device type not supported`)
360366
} else {
@@ -424,10 +430,18 @@ export class SwitchBotMatterPlatform {
424430
const devices = (this.config as any)?.devices ?? []
425431
const accessoriesToRegister: any[] = []
426432

433+
// Auto-detect Matter from Homebridge API
434+
const matterAvailable = this.api?.isMatterAvailable?.() && this.api?.isMatterEnabled?.()
435+
const matterEnabled = matterAvailable || !!this.config.enableMatter
436+
427437
for (const d of devices) {
428-
const type: string = d.type || d.deviceType || 'unknown'
438+
let type: string = d.type || d.deviceType || 'unknown'
439+
// Normalize wosweeper variants to vacuum
440+
if (['wosweeper', 'wosweepermini', 'wosweeperminipro'].includes((type || '').toLowerCase())) {
441+
type = 'vacuum'
442+
}
429443
const matterSupported = !!DEVICE_MATTER_SUPPORTED[(type || '').toLowerCase()]
430-
const useMatter = !!this.config.enableMatter && matterSupported
444+
const useMatter = matterEnabled && matterSupported
431445
if (!useMatter) {
432446
continue
433447
}

0 commit comments

Comments
 (0)