@switchbot/homebridge-switchbot 5.0.0 → 5.1.0-beta.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/.github/npm-version-script-esm.js +97 -0
- package/CHANGELOG.md +21 -8
- package/MIGRATION.md +5 -0
- package/README.md +25 -0
- package/config.schema.json +11 -0
- package/dist/SwitchBotHAPPlatform.d.ts.map +1 -1
- package/dist/SwitchBotHAPPlatform.js +33 -4
- package/dist/SwitchBotHAPPlatform.js.map +1 -1
- package/dist/SwitchBotMatterPlatform.d.ts +1 -0
- package/dist/SwitchBotMatterPlatform.d.ts.map +1 -1
- package/dist/SwitchBotMatterPlatform.js +38 -5
- package/dist/SwitchBotMatterPlatform.js.map +1 -1
- package/dist/homebridge-ui/public/js/api.d.ts +6 -0
- package/dist/homebridge-ui/public/js/api.d.ts.map +1 -1
- package/dist/homebridge-ui/public/js/api.js +18 -0
- package/dist/homebridge-ui/public/js/api.js.map +1 -1
- package/dist/homebridge-ui/public/js/api.ts +31 -1
- package/dist/homebridge-ui/public/js/app.js +78 -2
- package/dist/homebridge-ui/public/js/app.js.map +2 -2
- package/dist/homebridge-ui/public/js/devices.d.ts.map +1 -1
- package/dist/homebridge-ui/public/js/devices.js +6 -0
- package/dist/homebridge-ui/public/js/devices.js.map +1 -1
- package/dist/homebridge-ui/public/js/devices.ts +6 -0
- package/dist/homebridge-ui/public/js/modals.d.ts +1 -0
- package/dist/homebridge-ui/public/js/modals.d.ts.map +1 -1
- package/dist/homebridge-ui/public/js/modals.js +53 -0
- package/dist/homebridge-ui/public/js/modals.js.map +1 -1
- package/dist/homebridge-ui/public/js/modals.ts +58 -0
- package/dist/homebridge-ui/public/js/render.d.ts.map +1 -1
- package/dist/homebridge-ui/public/js/render.js +2 -1
- package/dist/homebridge-ui/public/js/render.js.map +1 -1
- package/dist/homebridge-ui/public/js/render.ts +2 -1
- package/dist/homebridge-ui/settings.js.map +1 -1
- package/dist/settings.d.ts +11 -0
- package/dist/settings.d.ts.map +1 -1
- package/dist/settings.js.map +1 -1
- package/dist/utils.d.ts +5 -0
- package/dist/utils.d.ts.map +1 -1
- package/dist/utils.js +27 -0
- package/dist/utils.js.map +1 -1
- package/docs/assets/highlight.css +15 -15
- package/docs/index.html +22 -5
- package/docs/variables/default.html +1 -1
- package/package.json +1 -1
- package/src/SwitchBotHAPPlatform.ts +31 -6
- package/src/SwitchBotMatterPlatform.ts +35 -7
- package/src/homebridge-ui/public/js/api.ts +31 -1
- package/src/homebridge-ui/public/js/devices.ts +6 -0
- package/src/homebridge-ui/public/js/modals.ts +58 -0
- package/src/homebridge-ui/public/js/render.ts +2 -1
- package/src/settings.ts +12 -0
- package/src/utils.ts +31 -0
- package/test/utils/utils.spec.ts +15 -0
package/src/utils.ts
CHANGED
|
@@ -1137,6 +1137,37 @@ export function normalizeConfig(raw?: PlatformConfig): SwitchBotPluginConfig {
|
|
|
1137
1137
|
return { ...(raw as any) } as SwitchBotPluginConfig
|
|
1138
1138
|
}
|
|
1139
1139
|
|
|
1140
|
+
/**
|
|
1141
|
+
* Resolve the per-device external publish protocol from raw config.
|
|
1142
|
+
* Accepts canonical values (`none`, `hap`, `matter`) and common aliases.
|
|
1143
|
+
*/
|
|
1144
|
+
export function resolveExternalPublishProtocol(rawDevice: any): 'none' | 'hap' | 'matter' {
|
|
1145
|
+
const raw = String(
|
|
1146
|
+
rawDevice?.externalPublishProtocol
|
|
1147
|
+
?? rawDevice?.externalDeviceProtocol
|
|
1148
|
+
?? rawDevice?.publishExternal
|
|
1149
|
+
?? rawDevice?.external
|
|
1150
|
+
?? 'none',
|
|
1151
|
+
).trim().toLowerCase()
|
|
1152
|
+
|
|
1153
|
+
if (raw === 'true') {
|
|
1154
|
+
return 'hap'
|
|
1155
|
+
}
|
|
1156
|
+
if (raw === 'false') {
|
|
1157
|
+
return 'none'
|
|
1158
|
+
}
|
|
1159
|
+
if (raw === 'homekit') {
|
|
1160
|
+
return 'hap'
|
|
1161
|
+
}
|
|
1162
|
+
if (raw === 'none' || raw === 'off' || raw === 'disabled') {
|
|
1163
|
+
return 'none'
|
|
1164
|
+
}
|
|
1165
|
+
if (raw === 'hap' || raw === 'matter') {
|
|
1166
|
+
return raw
|
|
1167
|
+
}
|
|
1168
|
+
return 'none'
|
|
1169
|
+
}
|
|
1170
|
+
|
|
1140
1171
|
// Create a Proxy constructor that instantiates the right platform implementation at runtime.
|
|
1141
1172
|
/**
|
|
1142
1173
|
* Creates a proxy class that instantiates the correct platform implementation (HAP or Matter) at runtime.
|
package/test/utils/utils.spec.ts
CHANGED
|
@@ -5,6 +5,7 @@ import {
|
|
|
5
5
|
MATTER_ATTRIBUTE_IDS,
|
|
6
6
|
MATTER_CLUSTER_IDS,
|
|
7
7
|
normalizeConfig,
|
|
8
|
+
resolveExternalPublishProtocol,
|
|
8
9
|
} from '../../src/utils'
|
|
9
10
|
|
|
10
11
|
describe('utils', () => {
|
|
@@ -50,4 +51,18 @@ describe('utils', () => {
|
|
|
50
51
|
expect(HAP).toHaveBeenCalled()
|
|
51
52
|
expect(Matter).not.toHaveBeenCalled()
|
|
52
53
|
})
|
|
54
|
+
|
|
55
|
+
it('resolveExternalPublishProtocol normalizes known values and aliases', () => {
|
|
56
|
+
expect(resolveExternalPublishProtocol({ externalPublishProtocol: 'hap' })).toBe('hap')
|
|
57
|
+
expect(resolveExternalPublishProtocol({ externalPublishProtocol: 'matter' })).toBe('matter')
|
|
58
|
+
expect(resolveExternalPublishProtocol({ externalPublishProtocol: 'none' })).toBe('none')
|
|
59
|
+
expect(resolveExternalPublishProtocol({ externalPublishProtocol: 'homekit' })).toBe('hap')
|
|
60
|
+
expect(resolveExternalPublishProtocol({ publishExternal: true })).toBe('hap')
|
|
61
|
+
expect(resolveExternalPublishProtocol({ publishExternal: false })).toBe('none')
|
|
62
|
+
})
|
|
63
|
+
|
|
64
|
+
it('resolveExternalPublishProtocol defaults to none for unknown values', () => {
|
|
65
|
+
expect(resolveExternalPublishProtocol({ externalPublishProtocol: 'invalid' })).toBe('none')
|
|
66
|
+
expect(resolveExternalPublishProtocol({})).toBe('none')
|
|
67
|
+
})
|
|
53
68
|
})
|