@homebridge-plugins/homebridge-sharkiq 2.0.0-beta.25 → 2.0.0-beta.27
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/BaseMatterAccessory.d.ts +4 -0
- package/dist/devices/BaseMatterAccessory.d.ts.map +1 -1
- package/dist/devices/BaseMatterAccessory.js +36 -12
- package/dist/devices/BaseMatterAccessory.js.map +1 -1
- package/docs/variables/default.html +1 -1
- package/package.json +1 -1
- package/test/translateLegacyCluster.spec.ts +57 -0
|
@@ -23,6 +23,8 @@ export interface BaseMatterAccessoryConfig {
|
|
|
23
23
|
parts?: MatterAccessory['parts'];
|
|
24
24
|
/** Optional mapping from legacy cluster names to supported cluster names. */
|
|
25
25
|
clusterNameMap?: Record<string, string>;
|
|
26
|
+
/** Enable translation behavior for legacy clusters like 'power' and 'diagnostics'. */
|
|
27
|
+
translateLegacyClusters?: boolean;
|
|
26
28
|
}
|
|
27
29
|
/**
|
|
28
30
|
* Base class for all Matter accessories
|
|
@@ -43,6 +45,8 @@ export declare abstract class BaseMatterAccessory implements MatterAccessory {
|
|
|
43
45
|
readonly parts?: MatterAccessory['parts'];
|
|
44
46
|
/** Optional mapping table for legacy cluster names */
|
|
45
47
|
readonly clusterNameMap?: Record<string, string>;
|
|
48
|
+
/** Whether to translate legacy clusters (can be toggled at runtime via context.translateLegacyClusters) */
|
|
49
|
+
protected readonly translateLegacyClusters: boolean;
|
|
46
50
|
protected readonly api: API;
|
|
47
51
|
protected readonly log: Logger;
|
|
48
52
|
constructor(api: API, log: Logger, config: BaseMatterAccessoryConfig);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"BaseMatterAccessory.d.ts","sourceRoot":"","sources":["../../src/devices/BaseMatterAccessory.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AAEH,OAAO,KAAK,EAAE,GAAG,EAAE,YAAY,EAAE,MAAM,EAAE,eAAe,EAAE,MAAM,YAA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U,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GAAG,OAAO,CAAC,IAAI,CAAC;IAsFhG;;OAEG;IACH,SAAS,CAAC,OAAO,CAAC,OAAO,EAAE,MAAM,EAAE,GAAG,IAAI,EAAE,OAAO,EAAE,GAAG,IAAI;IAI5D,SAAS,CAAC,QAAQ,CAAC,OAAO,EAAE,MAAM,EAAE,GAAG,IAAI,EAAE,OAAO,EAAE,GAAG,IAAI;IAI7D,SAAS,CAAC,QAAQ,CAAC,OAAO,EAAE,MAAM,EAAE,GAAG,IAAI,EAAE,OAAO,EAAE,GAAG,IAAI;IAI7D,SAAS,CAAC,OAAO,CAAC,OAAO,EAAE,MAAM,EAAE,GAAG,IAAI,EAAE,OAAO,EAAE,GAAG,IAAI;IAI5D;;;OAGG;IACI,WAAW,IAAI,eAAe;CAgBtC"}
|
|
@@ -27,6 +27,8 @@ export class BaseMatterAccessory {
|
|
|
27
27
|
parts;
|
|
28
28
|
/** Optional mapping table for legacy cluster names */
|
|
29
29
|
clusterNameMap;
|
|
30
|
+
/** Whether to translate legacy clusters (can be toggled at runtime via context.translateLegacyClusters) */
|
|
31
|
+
translateLegacyClusters;
|
|
30
32
|
// Protected properties available to child classes
|
|
31
33
|
api;
|
|
32
34
|
log;
|
|
@@ -46,6 +48,7 @@ export class BaseMatterAccessory {
|
|
|
46
48
|
this.handlers = config.handlers;
|
|
47
49
|
this.parts = config.parts;
|
|
48
50
|
this.clusterNameMap = config.clusterNameMap || {};
|
|
51
|
+
this.translateLegacyClusters = typeof config.translateLegacyClusters === 'boolean' ? config.translateLegacyClusters : true;
|
|
49
52
|
// Set context with all metadata
|
|
50
53
|
this.context = {
|
|
51
54
|
serialNumber: this.serialNumber,
|
|
@@ -66,8 +69,10 @@ export class BaseMatterAccessory {
|
|
|
66
69
|
// attempted to update clusters like 'power' or 'diagnostics'. The mapping
|
|
67
70
|
// is optional and can be provided per-accessory via config.
|
|
68
71
|
const mapped = (this.clusterNameMap && this.clusterNameMap[cluster]) || cluster;
|
|
69
|
-
// If the mapped cluster exists on this accessory
|
|
70
|
-
|
|
72
|
+
// If the mapped cluster exists on this accessory and this is not a
|
|
73
|
+
// legacy cluster that requires translation, forward the update.
|
|
74
|
+
const isLegacy = cluster === 'power' || cluster === 'diagnostics';
|
|
75
|
+
if (this.clusters && (mapped in this.clusters) && !isLegacy) {
|
|
71
76
|
await this.api.matter.updateAccessoryState(this.uuid, mapped, attributes);
|
|
72
77
|
this.log.debug(`[${this.displayName}] Updated ${mapped} state (from ${cluster}):`, attributes);
|
|
73
78
|
return;
|
|
@@ -77,6 +82,10 @@ export class BaseMatterAccessory {
|
|
|
77
82
|
// against supported clusters (for vacuum devices we commonly support
|
|
78
83
|
// 'rvcOperationalState'). This avoids noisy "Behavior ID ... does not
|
|
79
84
|
// exist" errors while preserving useful state updates.
|
|
85
|
+
// Determine whether translations are enabled for this accessory at runtime.
|
|
86
|
+
const runtimeTranslate = typeof this.context.translateLegacyClusters === 'boolean'
|
|
87
|
+
? this.context.translateLegacyClusters
|
|
88
|
+
: this.translateLegacyClusters;
|
|
80
89
|
if (cluster === 'power') {
|
|
81
90
|
// batteryLevel and charging are informational. If charging is present
|
|
82
91
|
// and we have rvcOperationalState, translate charging->Charging(65)
|
|
@@ -86,12 +95,21 @@ export class BaseMatterAccessory {
|
|
|
86
95
|
if (typeof batteryLevel === 'number') {
|
|
87
96
|
this.logInfo(`battery updated (via legacy 'power'): ${batteryLevel}%`);
|
|
88
97
|
}
|
|
89
|
-
if (typeof charging !== 'undefined'
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
this.
|
|
94
|
-
|
|
98
|
+
if (runtimeTranslate && typeof charging !== 'undefined') {
|
|
99
|
+
// Choose the target cluster to update. Prefer an explicit mapping
|
|
100
|
+
// if provided, otherwise fall back to rvcOperationalState when
|
|
101
|
+
// available.
|
|
102
|
+
const target = (this.clusterNameMap && this.clusterNameMap[cluster]) || 'rvcOperationalState';
|
|
103
|
+
const targetExists = this.clusters && (target in this.clusters);
|
|
104
|
+
const rvcExists = this.clusters && ('rvcOperationalState' in this.clusters);
|
|
105
|
+
if (targetExists || rvcExists) {
|
|
106
|
+
const isCharging = charging === true || charging === 1;
|
|
107
|
+
const opState = isCharging ? 65 : 66;
|
|
108
|
+
const chosen = targetExists ? target : 'rvcOperationalState';
|
|
109
|
+
await this.api.matter.updateAccessoryState(this.uuid, chosen, { operationalState: opState });
|
|
110
|
+
this.log.debug(`[${this.displayName}] Translated legacy 'power' charging=${String(charging)} -> ${chosen}=${opState}`);
|
|
111
|
+
return;
|
|
112
|
+
}
|
|
95
113
|
}
|
|
96
114
|
const available = this.clusters ? Object.keys(this.clusters).join(', ') : '(none)';
|
|
97
115
|
this.logWarn(`Attempt to update legacy cluster 'power' but no mapping or supported target found. Available clusters: ${available}`);
|
|
@@ -101,10 +119,16 @@ export class BaseMatterAccessory {
|
|
|
101
119
|
// diagnostics commonly carries an errorCode. If present and non-zero,
|
|
102
120
|
// translate to rvcOperationalState Error (3) when supported.
|
|
103
121
|
const errorCode = attributes.errorCode;
|
|
104
|
-
if (typeof errorCode === 'number' && errorCode > 0
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
122
|
+
if (runtimeTranslate && typeof errorCode === 'number' && errorCode > 0) {
|
|
123
|
+
const target = (this.clusterNameMap && this.clusterNameMap[cluster]) || 'rvcOperationalState';
|
|
124
|
+
const targetExists = this.clusters && (target in this.clusters);
|
|
125
|
+
const rvcExists = this.clusters && ('rvcOperationalState' in this.clusters);
|
|
126
|
+
if (targetExists || rvcExists) {
|
|
127
|
+
const chosen = targetExists ? target : 'rvcOperationalState';
|
|
128
|
+
await this.api.matter.updateAccessoryState(this.uuid, chosen, { operationalState: 3 });
|
|
129
|
+
this.logWarn(`[${this.displayName}] Translated legacy 'diagnostics' errorCode=${errorCode} -> ${chosen}=3 (Error)`);
|
|
130
|
+
return;
|
|
131
|
+
}
|
|
108
132
|
}
|
|
109
133
|
const available = this.clusters ? Object.keys(this.clusters).join(', ') : '(none)';
|
|
110
134
|
this.logDebug(`Attempt to update legacy cluster 'diagnostics' but no mapping or supported target found. Available clusters: ${available}`);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"BaseMatterAccessory.js","sourceRoot":"","sources":["../../src/devices/BaseMatterAccessory.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;
|
|
1
|
+
{"version":3,"file":"BaseMatterAccessory.js","sourceRoot":"","sources":["../../src/devices/BaseMatterAccessory.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AAuBH;;;GAGG;AACH,MAAM,OAAgB,mBAAmB;IACvC,sCAAsC;IACtB,IAAI,CAAQ;IACZ,WAAW,CAAQ;IACnB,UAAU,CAAc;IACxB,YAAY,CAAQ;IACpB,YAAY,CAAQ;IACpB,KAAK,CAAQ;IACb,gBAAgB,CAAQ;IACxB,gBAAgB,CAAQ;IACxB,OAAO,CAAyB;IAChC,QAAQ,CAA8B;IACtC,QAAQ,CAA8B;IACtC,KAAK,CAA2B;IAChD,sDAAsD;IACtC,cAAc,CAAyB;IACvD,2GAA2G;IACxF,uBAAuB,CAAS;IAEnD,kDAAkD;IAC/B,GAAG,CAAK;IACR,GAAG,CAAQ;IAE9B,YACE,GAAQ,EACR,GAAW,EACX,MAAiC;QAEjC,IAAI,CAAC,GAAG,GAAG,GAAG,CAAA;QACd,IAAI,CAAC,GAAG,GAAG,GAAG,CAAA;QAEd,8BAA8B;QAC9B,IAAI,CAAC,IAAI,GAAG,MAAM,CAAC,IAAI,CAAA;QACvB,IAAI,CAAC,WAAW,GAAG,MAAM,CAAC,WAAW,CAAA;QACrC,IAAI,CAAC,UAAU,GAAG,MAAM,CAAC,UAAU,CAAA;QACnC,IAAI,CAAC,YAAY,GAAG,MAAM,CAAC,YAAY,CAAA;QACvC,IAAI,CAAC,YAAY,GAAG,MAAM,CAAC,YAAY,CAAA;QACvC,IAAI,CAAC,KAAK,GAAG,MAAM,CAA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lang="en" data-base="../"><head><meta charset="utf-8"/><meta http-equiv="x-ua-compatible" content="IE=edge"/><title>default | @homebridge-plugins/homebridge-sharkiq</title><meta name="description" content="Documentation for @homebridge-plugins/homebridge-sharkiq"/><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">@homebridge-plugins/homebridge-sharkiq</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">=></span> <span class="tsd-signature-type">void</span></div><div class="tsd-comment tsd-typography"><p>This method registers the platform with Homebridge</p>
|
|
2
|
-
</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/homebridge-plugins/homebridge-sharkiq/blob/
|
|
2
|
+
</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/homebridge-plugins/homebridge-sharkiq/blob/2e2ac9deb6f025ec062c50d165dc807c6808df03/src/index.ts#L9">index.ts:9</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">@homebridge-plugins/homebridge-sharkiq</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>
|
package/package.json
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
"name": "@homebridge-plugins/homebridge-sharkiq",
|
|
3
3
|
"displayName": "SharkIQ Plugin",
|
|
4
4
|
"type": "module",
|
|
5
|
-
"version": "2.0.0-beta.
|
|
5
|
+
"version": "2.0.0-beta.27",
|
|
6
6
|
"description": "A Homebridge plugin to connect your Shark Vacuum to homebridge.",
|
|
7
7
|
"author": {
|
|
8
8
|
"name": "Bubba8291",
|
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
import { expect, it, vi } from 'vitest'
|
|
2
|
+
|
|
3
|
+
import { BaseMatterAccessory } from '../src/devices/BaseMatterAccessory.js'
|
|
4
|
+
|
|
5
|
+
// Spy for updateAccessoryState
|
|
6
|
+
const mockUpdate = vi.fn(async () => {})
|
|
7
|
+
const mockApi: any = {
|
|
8
|
+
matter: {
|
|
9
|
+
uuid: { generate: (s: string) => `uuid-${s}` },
|
|
10
|
+
deviceTypes: { RoboticVacuumCleaner: 123 },
|
|
11
|
+
updateAccessoryState: mockUpdate,
|
|
12
|
+
},
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
const mockLogger: any = { info: () => {}, warn: () => {}, error: () => {}, debug: () => {} }
|
|
16
|
+
|
|
17
|
+
class TranslateAccessory extends BaseMatterAccessory {
|
|
18
|
+
constructor(api: any, log: any) {
|
|
19
|
+
super(api, log, {
|
|
20
|
+
uuid: api.matter.uuid.generate('test-translate'),
|
|
21
|
+
displayName: 'TranslateTest',
|
|
22
|
+
deviceType: (api.matter.deviceTypes.RoboticVacuumCleaner as any) || 0,
|
|
23
|
+
serialNumber: 'SN-T-1',
|
|
24
|
+
manufacturer: 'TestCo',
|
|
25
|
+
model: 'T-1',
|
|
26
|
+
firmwareRevision: '1.0',
|
|
27
|
+
hardwareRevision: '1.0',
|
|
28
|
+
// Register rvcOperationalState so translations have a target
|
|
29
|
+
clusters: {
|
|
30
|
+
rvcOperationalState: { operationalStateList: [{ operationalStateId: 0 }, { operationalStateId: 1 }, { operationalStateId: 65 }], operationalState: 0 },
|
|
31
|
+
},
|
|
32
|
+
// Ensure translation enabled explicitly
|
|
33
|
+
translateLegacyClusters: true,
|
|
34
|
+
})
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
public async callUpdateState(cluster: string, attrs: Record<string, unknown>) {
|
|
38
|
+
await (this as any).updateState(cluster, attrs)
|
|
39
|
+
}
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
it('translates power.charging -> rvcOperationalState when target exists', async () => {
|
|
43
|
+
mockUpdate.mockClear()
|
|
44
|
+
|
|
45
|
+
const acc = new TranslateAccessory(mockApi, mockLogger)
|
|
46
|
+
|
|
47
|
+
await acc.callUpdateState('power', { batteryLevel: 42, charging: true })
|
|
48
|
+
|
|
49
|
+
// Expect updateAccessoryState called to set rvcOperationalState to 65 (Charging)
|
|
50
|
+
expect(mockUpdate).toHaveBeenCalled()
|
|
51
|
+
const calls = mockUpdate.mock.calls as any
|
|
52
|
+
const found = calls.find((c: any) => c[1] === 'rvcOperationalState')
|
|
53
|
+
expect(found).toBeDefined()
|
|
54
|
+
const args = found as any
|
|
55
|
+
const attrs = args[2] as any
|
|
56
|
+
expect(attrs.operationalState).toBe(65)
|
|
57
|
+
})
|