@homebridge-plugins/homebridge-sharkiq 1.4.1-beta.9 → 1.4.1

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 (55) hide show
  1. package/CHANGELOG.md +148 -6
  2. package/README.md +1 -1
  3. package/config.schema.json +38 -1
  4. package/dist/SharkIQMatterPlatform.d.ts +80 -0
  5. package/dist/SharkIQMatterPlatform.d.ts.map +1 -0
  6. package/dist/SharkIQMatterPlatform.js +266 -0
  7. package/dist/SharkIQMatterPlatform.js.map +1 -0
  8. package/dist/config.d.ts +1 -1
  9. package/dist/config.d.ts.map +1 -1
  10. package/dist/config.js +5 -4
  11. package/dist/config.js.map +1 -1
  12. package/dist/index.d.ts.map +1 -1
  13. package/dist/index.js +6 -1
  14. package/dist/index.js.map +1 -1
  15. package/dist/login.d.ts +2 -1
  16. package/dist/login.d.ts.map +1 -1
  17. package/dist/login.js +16 -12
  18. package/dist/login.js.map +1 -1
  19. package/dist/platform.d.ts.map +1 -1
  20. package/dist/platform.js +27 -4
  21. package/dist/platform.js.map +1 -1
  22. package/dist/settings.d.ts +15 -0
  23. package/dist/settings.d.ts.map +1 -1
  24. package/dist/settings.js +5 -0
  25. package/dist/settings.js.map +1 -1
  26. package/dist/sharkiq-js/ayla_api.d.ts.map +1 -1
  27. package/dist/sharkiq-js/ayla_api.js +12 -2
  28. package/dist/sharkiq-js/ayla_api.js.map +1 -1
  29. package/dist/sharkiq-js/const.d.ts +9 -0
  30. package/dist/sharkiq-js/const.d.ts.map +1 -1
  31. package/dist/sharkiq-js/const.js +11 -2
  32. package/dist/sharkiq-js/const.js.map +1 -1
  33. package/dist/utils.d.ts +19 -1
  34. package/dist/utils.d.ts.map +1 -1
  35. package/dist/utils.js +33 -1
  36. package/dist/utils.js.map +1 -1
  37. package/docs/assets/icons.js +1 -1
  38. package/docs/assets/icons.svg +1 -1
  39. package/docs/assets/main.js +5 -5
  40. package/docs/assets/navigation.js +1 -0
  41. package/docs/assets/search.js +1 -0
  42. package/docs/assets/style.css +248 -226
  43. package/docs/hierarchy.html +1 -0
  44. package/docs/index.html +25 -16
  45. package/docs/modules.html +1 -2
  46. package/docs/variables/default.html +1 -0
  47. package/eslint.config.js +6 -8
  48. package/package.json +21 -26
  49. package/typedoc.json +0 -4
  50. package/docs/assets/dmt/dmt-component-data.js +0 -1
  51. package/docs/assets/dmt/dmt-components.css +0 -20
  52. package/docs/assets/dmt/dmt-components.js +0 -67
  53. package/docs/assets/dmt/dmt-search.cmp +0 -0
  54. package/docs/assets/dmt/dmt-theme.css +0 -1
  55. package/docs/functions/default.html +0 -2
package/CHANGELOG.md CHANGED
@@ -2,11 +2,6 @@
2
2
 
3
3
  All notable changes to this project will be documented in this file. This project uses [Semantic Versioning](https://semver.org/)
4
4
 
5
- ## [1.4.1] (TBD)
6
-
7
- ### What's Changed
8
- - Fix ARM64 OAuth code handling for users with both email/password and OAuth code [#54](https://github.com/homebridge-plugins/homebridge-sharkiq/issues/54)
9
-
10
5
  ## [1.4.0](https://github.com/homebridge-plugins/homebridge-sharkiq/releases/tag/v1.4.0) (2025-07-17)
11
6
 
12
7
  ### What's Changes
@@ -14,4 +9,151 @@ All notable changes to this project will be documented in this file. This projec
14
9
  - Fix JSON parsing errors in SharkIQ API responses [#44](https://github.com/homebridge-plugins/homebridge-sharkiq/pull/44) [@mmenanno](https://github.com/mmenanno)
15
10
  - Housekeeping and updated dependencies.
16
11
 
17
- **Full Changelog**: https://github.com/homebridge-plugins/homebridge-sharkiq/compare/v1.3.2...v1.4.0
12
+ **Full Changelog**: https://github.com/homebridge-plugins/homebridge-sharkiq/compare/v1.3.2...v1.4.0
13
+
14
+ # ## [1.3.2](https://github.com/homebridge-plugins/homebridge-sharkiq/releases/tag/v1.3.2) (2024-10-29)
15
+
16
+ ### What's Changed
17
+ - Show warning messages if manual login is required
18
+
19
+ **Full Changelog**: https://github.com/homebridge-plugins/homebridge-sharkiq/compare/v1.3.1...v1.3.2
20
+
21
+ # ## [1.3.1](https://github.com/homebridge-plugins/homebridge-sharkiq/releases/tag/v1.3.1) (2024-09-29)
22
+
23
+ ### What's Changed
24
+ - Development by [@Bubba8291](https://github.com/Bubba8291) in [#21](https://github.com/homebridge-plugins/homebridge-sharkiq/pull/21)
25
+ - Email and password login working again [#18](https://github.com/homebridge-plugins/homebridge-sharkiq/issues/18)
26
+ - Manual login still works as well
27
+ - Homebridge 2.0 support [#22](https://github.com/homebridge-plugins/homebridge-sharkiq/issues/22)
28
+
29
+ **Full Changelog**: https://github.com/homebridge-plugins/homebridge-sharkiq/compare/v1.2.3...v1.3.1
30
+
31
+ # ## [1.2.3](https://github.com/homebridge-plugins/homebridge-sharkiq/releases/tag/v1.2.3) (2024-08-28)
32
+
33
+ ### What's Changed
34
+ - Fixed the small chance of get fan speed generating errors
35
+ - Stores the date of the expiration rather than the amount of seconds until the auth token expiration ([#18](https://github.com/homebridge-plugins/homebridge-sharkiq/issues/18))
36
+
37
+ **Full Changelog**: https://github.com/homebridge-plugins/homebridge-sharkiq/compare/v1.2.2...v1.2.3
38
+
39
+ # ## [1.2.2](https://github.com/homebridge-plugins/homebridge-sharkiq/releases/tag/v1.2.2) (2024-08-24)
40
+
41
+ ### What's Changed
42
+ - Log location of auth file to user if errors relating to refresh continue
43
+
44
+ **Full Changelog**: https://github.com/homebridge-plugins/homebridge-sharkiq/compare/v1.2.1...v1.2.2
45
+
46
+ # ## [1.2.1](https://github.com/homebridge-plugins/homebridge-sharkiq/releases/tag/v1.2.1) (2024-08-24)
47
+
48
+ ### What's Changed
49
+ - Added specific debug error messages from API
50
+
51
+ **Full Changelog**: https://github.com/homebridge-plugins/homebridge-sharkiq/compare/v1.2.0...v1.2.1
52
+
53
+ # ## [1.2.0](https://github.com/homebridge-plugins/homebridge-sharkiq/releases/tag/v1.2.0) (2024-08-19)
54
+
55
+ ### What's Changed
56
+ - Switched to new Shark login method [#17](https://github.com/homebridge-plugins/homebridge-sharkiq/issues/17)
57
+
58
+ **Full Changelog**: https://github.com/homebridge-plugins/homebridge-sharkiq/compare/v1.1.3...v1.2.0
59
+
60
+ # ## [1.1.3](https://github.com/homebridge-plugins/homebridge-sharkiq/releases/tag/v1.1.3) (2024-08-10)
61
+
62
+ ### What's Changed
63
+ - Make API errors more descriptive
64
+
65
+ **Full Changelog**: https://github.com/homebridge-plugins/homebridge-sharkiq/compare/v1.1.2...v1.1.3
66
+
67
+ # ## [1.1.2](https://github.com/homebridge-plugins/homebridge-sharkiq/releases/tag/v1.1.2) (2023-10-27)
68
+
69
+ ### What's Changed
70
+ - Vacuums are now obtained from their device serial numbers (DSN)
71
+
72
+ **Full Changelog**: https://github.com/homebridge-plugins/homebridge-sharkiq/compare/v1.1.1...v1.1.2
73
+
74
+ # ## [1.1.1](https://github.com/homebridge-plugins/homebridge-sharkiq/releases/tag/v1.1.1) (2023-10-25)
75
+
76
+ ### What's Changed
77
+ - Added support for the SharkClean European server
78
+
79
+ **Full Changelog**: https://github.com/homebridge-plugins/homebridge-sharkiq/compare/v1.1.0...v1.1.1
80
+
81
+ # ## [1.1.0](https://github.com/homebridge-plugins/homebridge-sharkiq/releases/tag/v1.1.0) (2023-10-09)
82
+
83
+ ### What's Changed
84
+ - Fixed an issue where the plugin would slow down Homebridge [#8](https://github.com/homebridge-plugins/homebridge-sharkiq/issues/8)
85
+ - Changed the http client to `node-fetch`
86
+ - Fixed an issue where the vacuum states would not consistently update in Homebridge if controlled from the SharkClean mobile app
87
+ - Heavily optimized the plugin code
88
+ - Added a config option to change the interval on how often the docked status updates
89
+ - Changed the minimum Homebridge version to `1.6.1` [#9](https://github.com/homebridge-plugins/homebridge-sharkiq/pull/9)
90
+ - Updated the plugin to work on both Node versions 18 and 20 [#9](https://github.com/homebridge-plugins/homebridge-sharkiq/pull/9)
91
+
92
+ **Full Changelog**: https://github.com/homebridge-plugins/homebridge-sharkiq/compare/v1.0.9...v1.1.0
93
+
94
+ # ## [1.0.9](https://github.com/homebridge-plugins/homebridge-sharkiq/releases/tag/v1.0.9) (2023-09-01)
95
+
96
+ ### What's Changed
97
+ - Optimized code for parsing config
98
+
99
+ **Full Changelog**: https://github.com/homebridge-plugins/homebridge-sharkiq/compare/v1.0.8...v1.0.9
100
+
101
+ # ## [1.0.8](https://github.com/homebridge-plugins/homebridge-sharkiq/releases/tag/v1.0.8) (2023-09-01)
102
+
103
+ ### What's Changed
104
+ - Updated README to include badge
105
+ - Added donation link
106
+
107
+ **Full Changelog**: https://github.com/homebridge-plugins/homebridge-sharkiq/compare/v1.0.7...v1.0.8
108
+
109
+ # ## [1.0.7](https://github.com/homebridge-plugins/homebridge-sharkiq/releases/tag/v1.0.7) (2023-09-01)
110
+
111
+ ### What's Changed
112
+ - Updated `README`
113
+
114
+ **Full Changelog**: https://github.com/homebridge-plugins/homebridge-sharkiq/compare/v1.0.6...v1.0.7
115
+
116
+ # ## [1.0.6](https://github.com/homebridge-plugins/homebridge-sharkiq/releases/tag/v1.0.6) (2023-09-01)
117
+
118
+ ### What's Changed
119
+ - Updated the README to make the json config easier to understand
120
+ - Updated the `config.schema.json` to fix a bug in the Homebridge config UI
121
+ - Updated `package.json` and removed a dev dependency that is no longer needed
122
+
123
+ **Full Changelog**: https://github.com/homebridge-plugins/homebridge-sharkiq/compare/v1.0.5...v1.0.6
124
+
125
+ # ## [1.0.5](https://github.com/homebridge-plugins/homebridge-sharkiq/releases/tag/v1.0.5) (2023-08-31)
126
+
127
+ ### What's Changed
128
+ - Minor fixes and improvements to config and documentation
129
+
130
+ **Full Changelog**: https://github.com/homebridge-plugins/homebridge-sharkiq/compare/v1.0.4...v1.0.5
131
+
132
+ # ## [1.0.4](https://github.com/homebridge-plugins/homebridge-sharkiq/releases/tag/v1.0.4) (2023-08-30)
133
+
134
+ ### What's Changed
135
+ - Added invert docked status option
136
+ - Bug fixes for auth token
137
+
138
+ **Full Changelog**: https://github.com/homebridge-plugins/homebridge-sharkiq/compare/v1.0.3...v1.0.4
139
+
140
+ # ## [1.0.3](https://github.com/homebridge-plugins/homebridge-sharkiq/releases/tag/v1.0.3) (2023-08-29)
141
+
142
+ ### What's Changed
143
+ - Various bug fixes and documentation updates
144
+
145
+ **Full Changelog**: https://github.com/homebridge-plugins/homebridge-sharkiq/compare/v1.0.2...v1.0.3
146
+
147
+ # ## [1.0.2](https://github.com/homebridge-plugins/homebridge-sharkiq/releases/tag/v1.0.2) (2023-08-28)
148
+
149
+ ### What's Changed
150
+ - Minor updates to config and formatting
151
+
152
+ **Full Changelog**: https://github.com/homebridge-plugins/homebridge-sharkiq/compare/v1.0.1...v1.0.2
153
+
154
+ # ## [1.0.1](https://github.com/homebridge-plugins/homebridge-sharkiq/releases/tag/v1.0.1) (2023-08-27)
155
+
156
+ ### What's Changed
157
+ - Initial public release
158
+
159
+ **Full Changelog**: https://github.com/homebridge-plugins/homebridge-sharkiq/compare/df61287...v1.0.1
package/README.md CHANGED
@@ -59,7 +59,7 @@ If you would like to manually obtain your Shark Clean credentials without using
59
59
 
60
60
  The Vacuums array is a list of your vacuum's device serial numbers (DSN). If you only have one vacuum, just include the one's DSN. The DSN(s) can be found in the SharkClean mobile app.
61
61
 
62
- If you are in Europe, set the `europe` config value to `true`. SharkClean has separate servers for the U.S. and Europe. The default value is `false`, which connects to the U.S. server.
62
+ If you are in Europe or the UK, set the `europe` config value to `true`. SharkClean has separate servers for the U.S. and Europe. The default value is `false`, which connects to the U.S. server.
63
63
 
64
64
  The default interval between updating the docked status is 30 seconds (30000 ms). To change the docked status interval, add `dockedUpdateInterval` to your config. Value is in milliseconds. If the interval is too low, you have the risk of your account being rate limited.
65
65
 
@@ -38,6 +38,7 @@
38
38
  },
39
39
  "europe": {
40
40
  "title": "SharkClean European Server",
41
+ "description": "Set to true if you are located in Europe or the UK. SharkClean uses different servers for US and European regions.",
41
42
  "type": "boolean",
42
43
  "required": false,
43
44
  "default": false
@@ -53,6 +54,27 @@
53
54
  "type": "integer",
54
55
  "required": false,
55
56
  "default": 30000
57
+ },
58
+ "externalAccessory": {
59
+ "title": "Publish as External Accessory",
60
+ "description": "When enabled, each vacuum is published as a standalone external accessory with its own HomeKit pairing code, instead of being bridged through Homebridge. Applies to both HAP and Matter registration modes.",
61
+ "type": "boolean",
62
+ "required": false,
63
+ "default": false
64
+ },
65
+ "preferMatter": {
66
+ "title": "Prefer Matter",
67
+ "description": "When enabled, the plugin will use the Homebridge Matter API (requires Homebridge v2.0+ with Matter enabled). Falls back to HAP if Matter is unavailable.",
68
+ "type": "boolean",
69
+ "required": false,
70
+ "default": true
71
+ },
72
+ "enableMatter": {
73
+ "title": "Enable Matter",
74
+ "description": "Allow the plugin to use Homebridge Matter support when available. Set to false to always use HAP accessories.",
75
+ "type": "boolean",
76
+ "required": false,
77
+ "default": true
56
78
  }
57
79
  }
58
80
  },
@@ -107,7 +129,22 @@
107
129
  },
108
130
  "europe",
109
131
  "invertDockedStatus",
110
- "dockedUpdateInterval"
132
+ "dockedUpdateInterval",
133
+ "externalAccessory"
134
+ ]
135
+ },
136
+ {
137
+ "type": "fieldset",
138
+ "title": "Matter Settings",
139
+ "expandable": true,
140
+ "expanded": false,
141
+ "items": [
142
+ {
143
+ "type": "help",
144
+ "helpvalue": "<h5>Homebridge Matter Support</h5><em class='primary-text'>These options require Homebridge v2.0 or later with Matter enabled. If Matter is unavailable the plugin will automatically fall back to standard HomeKit (HAP) accessories.</em>"
145
+ },
146
+ "preferMatter",
147
+ "enableMatter"
111
148
  ]
112
149
  }
113
150
  ]
@@ -0,0 +1,80 @@
1
+ import type { API, Logger, PlatformAccessory, PlatformConfig } from 'homebridge';
2
+ import { SharkIQPlatform } from './platform.js';
3
+ /**
4
+ * SharkIQMatterPlatform
5
+ *
6
+ * Extends the base HAP platform to add Homebridge v2.0 Matter support.
7
+ * When the Homebridge Matter API is available and enabled, robot vacuums are
8
+ * registered as native Matter `RoboticVacuumCleaner` endpoints via
9
+ * `api.matter.registerPlatformAccessories()`. State is kept up-to-date by
10
+ * periodic polling that calls `api.matter.updateAccessoryState()` directly —
11
+ * no HAP platform accessories are created in the Matter code path, avoiding
12
+ * duplicate accessories.
13
+ *
14
+ * If the Matter API is unavailable (e.g. running on Homebridge v1.x or Matter
15
+ * is disabled by the user) the platform falls back transparently to the
16
+ * standard HAP registration path inherited from {@link SharkIQPlatform}.
17
+ */
18
+ export declare class SharkIQMatterPlatform extends SharkIQPlatform {
19
+ readonly matterAccessories: Map<string, any>;
20
+ constructor(log: Logger, config: PlatformConfig, api: API);
21
+ /**
22
+ * Called by Homebridge when a cached HAP accessory is restored from disk.
23
+ *
24
+ * Delegates to the parent so that `this.accessories` is populated for the
25
+ * HAP fallback path. When Matter mode is active, these cached HAP accessories
26
+ * are unregistered in `_cleanupCachedHapAccessories()` before Matter
27
+ * accessories are registered, preventing duplicates.
28
+ */
29
+ configureAccessory(accessory: PlatformAccessory): void;
30
+ /**
31
+ * Called by Homebridge when a cached Matter accessory is restored from disk.
32
+ * Required for Matter-enabled platforms (mirrors `configureAccessory` for HAP).
33
+ */
34
+ configureMatterAccessory(accessory: any): void;
35
+ /**
36
+ * Override the HAP `discoverDevices` method.
37
+ *
38
+ * When the Matter API is fully initialised, cached HAP accessories are
39
+ * cleaned up and vacuums are registered as Matter `RoboticVacuumCleaner`
40
+ * accessories. Falls back to the standard HAP path when Matter is not available.
41
+ */
42
+ discoverDevices(): void;
43
+ /**
44
+ * Unregister all cached HAP accessories before registering Matter accessories.
45
+ *
46
+ * Prevents duplicate accessories when a user upgrades to Homebridge v2 or
47
+ * switches from the HAP registration path to the Matter registration path.
48
+ */
49
+ private _cleanupCachedHapAccessories;
50
+ /**
51
+ * Register all discovered vacuum devices using the Homebridge Matter API.
52
+ *
53
+ * For each vacuum:
54
+ * - Reuses a previously cached `MatterAccessory` when the UUID matches, or
55
+ * creates a new plain-object descriptor satisfying the `MatterAccessory`
56
+ * interface.
57
+ * - Starts a periodic polling loop that fetches live state from the Shark
58
+ * cloud and pushes updates directly via `api.matter.updateAccessoryState`.
59
+ * - Removes any cached Matter accessories whose vacuums are no longer present.
60
+ *
61
+ * No HAP platform accessories are created in this path to avoid duplicate
62
+ * device entries.
63
+ */
64
+ private _registerMatterDevices;
65
+ /**
66
+ * Build Matter command handlers for an RVC accessory.
67
+ *
68
+ * Handlers respond to Matter `changeToMode` commands (user starting or
69
+ * stopping the vacuum from a Matter controller or Apple Home) by calling
70
+ * the appropriate SharkIQ API methods.
71
+ */
72
+ private _buildMatterHandlers;
73
+ /**
74
+ * Start a periodic polling loop that fetches live vacuum state from the Shark
75
+ * cloud and pushes updates into Matter cluster attributes via
76
+ * `api.matter.updateAccessoryState`.
77
+ */
78
+ private _startVacuumPolling;
79
+ }
80
+ //# sourceMappingURL=SharkIQMatterPlatform.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"SharkIQMatterPlatform.d.ts","sourceRoot":"","sources":["../src/SharkIQMatterPlatform.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,GAAG,EAAE,MAAM,EAAE,iBAAiB,EAAE,cAAc,EAAE,MAAM,YAAY,CAAA;AAMhF,OAAO,EAAE,eAAe,EAAE,MAAM,eAAe,CAAA;AAI/C;;;;;;;;;;;;;;GAcG;AACH,qBAAa,qBAAsB,SAAQ,eAAe;IAExD,SAAgB,iBAAiB,EAAE,GAAG,CAAC,MAAM,EAAE,GAAG,CAAC,CAAY;gBAG7D,GAAG,EAAE,MAAM,EACX,MAAM,EAAE,cAAc,EACtB,GAAG,EAAE,GAAG;IAaV;;;;;;;OAOG;IACH,kBAAkB,CAAC,SAAS,EAAE,iBAAiB,GAAG,IAAI;IAItD;;;OAGG;IACH,wBAAwB,CAAC,SAAS,EAAE,GAAG,GAAG,IAAI;IAK9C;;;;;;OAMG;IACH,eAAe,IAAI,IAAI;IAiBvB;;;;;OAKG;IACH,OAAO,CAAC,4BAA4B;IAUpC;;;;;;;;;;;;;OAaG;IACH,OAAO,CAAC,sBAAsB;IAoG9B;;;;;;OAMG;IACH,OAAO,CAAC,oBAAoB;IAkB5B;;;;OAIG;IACH,OAAO,CAAC,mBAAmB;CA0C5B"}
@@ -0,0 +1,266 @@
1
+ import { TIMEOUTS } from './constants.js';
2
+ import { createPromiseRejectionHandler } from './errorHandling.js';
3
+ import { SharkIQPlatform } from './platform.js';
4
+ import { PLATFORM_NAME, PLUGIN_NAME } from './settings.js';
5
+ import { OperatingModes, Properties } from './sharkiq-js/sharkiq.js';
6
+ /**
7
+ * SharkIQMatterPlatform
8
+ *
9
+ * Extends the base HAP platform to add Homebridge v2.0 Matter support.
10
+ * When the Homebridge Matter API is available and enabled, robot vacuums are
11
+ * registered as native Matter `RoboticVacuumCleaner` endpoints via
12
+ * `api.matter.registerPlatformAccessories()`. State is kept up-to-date by
13
+ * periodic polling that calls `api.matter.updateAccessoryState()` directly —
14
+ * no HAP platform accessories are created in the Matter code path, avoiding
15
+ * duplicate accessories.
16
+ *
17
+ * If the Matter API is unavailable (e.g. running on Homebridge v1.x or Matter
18
+ * is disabled by the user) the platform falls back transparently to the
19
+ * standard HAP registration path inherited from {@link SharkIQPlatform}.
20
+ */
21
+ export class SharkIQMatterPlatform extends SharkIQPlatform {
22
+ // Track restored Matter cached accessories
23
+ matterAccessories = new Map();
24
+ constructor(log, config, api) {
25
+ super(log, config, api);
26
+ if (!api.isMatterAvailable?.()) {
27
+ this.log.warn('Matter is not available in this version of Homebridge. SharkIQ will use HAP accessories.');
28
+ }
29
+ else if (!api.isMatterEnabled?.()) {
30
+ this.log.warn('Matter is not enabled in Homebridge. SharkIQ will use HAP accessories.');
31
+ }
32
+ else {
33
+ this.log.info('Homebridge Matter support detected. SharkIQ will register vacuums as Matter accessories.');
34
+ }
35
+ }
36
+ /**
37
+ * Called by Homebridge when a cached HAP accessory is restored from disk.
38
+ *
39
+ * Delegates to the parent so that `this.accessories` is populated for the
40
+ * HAP fallback path. When Matter mode is active, these cached HAP accessories
41
+ * are unregistered in `_cleanupCachedHapAccessories()` before Matter
42
+ * accessories are registered, preventing duplicates.
43
+ */
44
+ configureAccessory(accessory) {
45
+ super.configureAccessory(accessory);
46
+ }
47
+ /**
48
+ * Called by Homebridge when a cached Matter accessory is restored from disk.
49
+ * Required for Matter-enabled platforms (mirrors `configureAccessory` for HAP).
50
+ */
51
+ configureMatterAccessory(accessory) {
52
+ this.log.info('Loading cached Matter accessory:', accessory.displayName);
53
+ this.matterAccessories.set(accessory.UUID, accessory);
54
+ }
55
+ /**
56
+ * Override the HAP `discoverDevices` method.
57
+ *
58
+ * When the Matter API is fully initialised, cached HAP accessories are
59
+ * cleaned up and vacuums are registered as Matter `RoboticVacuumCleaner`
60
+ * accessories. Falls back to the standard HAP path when Matter is not available.
61
+ */
62
+ discoverDevices() {
63
+ const matterApi = this.api.matter;
64
+ const matterAvailable = !!this.api.isMatterAvailable?.()
65
+ && !!this.api.isMatterEnabled?.()
66
+ && !!matterApi
67
+ && typeof matterApi.registerPlatformAccessories === 'function';
68
+ if (!matterAvailable) {
69
+ this.log.info('Matter API not available; falling back to HAP for SharkIQ device registration.');
70
+ super.discoverDevices();
71
+ return;
72
+ }
73
+ this._cleanupCachedHapAccessories();
74
+ this._registerMatterDevices(matterApi);
75
+ }
76
+ /**
77
+ * Unregister all cached HAP accessories before registering Matter accessories.
78
+ *
79
+ * Prevents duplicate accessories when a user upgrades to Homebridge v2 or
80
+ * switches from the HAP registration path to the Matter registration path.
81
+ */
82
+ _cleanupCachedHapAccessories() {
83
+ if (this.accessories.length === 0) {
84
+ return;
85
+ }
86
+ this.log.info(`Removing ${this.accessories.length} cached HAP accessor${this.accessories.length === 1 ? 'y' : 'ies'} before Matter registration.`);
87
+ this.api.unregisterPlatformAccessories(PLUGIN_NAME, PLATFORM_NAME, [...this.accessories]);
88
+ this.accessories.splice(0, this.accessories.length);
89
+ }
90
+ /**
91
+ * Register all discovered vacuum devices using the Homebridge Matter API.
92
+ *
93
+ * For each vacuum:
94
+ * - Reuses a previously cached `MatterAccessory` when the UUID matches, or
95
+ * creates a new plain-object descriptor satisfying the `MatterAccessory`
96
+ * interface.
97
+ * - Starts a periodic polling loop that fetches live state from the Shark
98
+ * cloud and pushes updates directly via `api.matter.updateAccessoryState`.
99
+ * - Removes any cached Matter accessories whose vacuums are no longer present.
100
+ *
101
+ * No HAP platform accessories are created in this path to avoid duplicate
102
+ * device entries.
103
+ */
104
+ _registerMatterDevices(matterApi) {
105
+ const accessoriesToRegister = [];
106
+ const activeMatterAccessories = [];
107
+ const cachedActiveMatterAccessories = [];
108
+ const unusedMatterAccessories = new Map(this.matterAccessories);
109
+ this.vacuumDevices.forEach((vacuumDevice) => {
110
+ const uuid = this.api.hap.uuid.generate(vacuumDevice._dsn.toString());
111
+ // Remove from the "unused" tracking map now that we've seen it
112
+ unusedMatterAccessories.delete(uuid);
113
+ let matterAccessory = this.matterAccessories.get(uuid);
114
+ if (!matterAccessory) {
115
+ // Build a new MatterAccessory descriptor for this vacuum
116
+ matterAccessory = {
117
+ UUID: uuid,
118
+ displayName: vacuumDevice._name.toString(),
119
+ deviceType: matterApi.deviceTypes?.RoboticVacuumCleaner,
120
+ serialNumber: vacuumDevice._dsn,
121
+ manufacturer: 'Shark',
122
+ model: vacuumDevice._vac_model_number || 'Unknown',
123
+ firmwareRevision: '1.0.0',
124
+ hardwareRevision: '1.0.0',
125
+ context: { dsn: vacuumDevice._dsn },
126
+ clusters: {
127
+ rvcRunMode: {
128
+ supportedModes: [
129
+ { label: 'Idle', mode: 0, modeTags: [{ value: 16384 }] },
130
+ { label: 'Cleaning', mode: 1, modeTags: [{ value: 16385 }] },
131
+ ],
132
+ currentMode: 0,
133
+ },
134
+ rvcOperationalState: {
135
+ operationalStateList: [
136
+ { operationalStateId: 0, operationalStateLabel: 'Stopped' },
137
+ { operationalStateId: 1, operationalStateLabel: 'Running' },
138
+ { operationalStateId: 2, operationalStateLabel: 'Paused' },
139
+ { operationalStateId: 64, operationalStateLabel: 'Seeking Charger' },
140
+ { operationalStateId: 65, operationalStateLabel: 'Charging' },
141
+ { operationalStateId: 66, operationalStateLabel: 'Docked' },
142
+ ],
143
+ operationalState: 66,
144
+ },
145
+ },
146
+ handlers: this._buildMatterHandlers(matterApi, uuid, vacuumDevice),
147
+ };
148
+ accessoriesToRegister.push(matterAccessory);
149
+ this.matterAccessories.set(uuid, matterAccessory);
150
+ this.log.info(`Preparing new Matter accessory for vacuum: ${vacuumDevice._name.toString()} (${vacuumDevice._dsn})`);
151
+ }
152
+ else {
153
+ cachedActiveMatterAccessories.push(matterAccessory);
154
+ this.log.info(`Restoring cached Matter accessory for vacuum: ${vacuumDevice._name.toString()} (${vacuumDevice._dsn})`);
155
+ }
156
+ activeMatterAccessories.push(matterAccessory);
157
+ // Start a polling loop to push live vacuum state into Matter cluster attributes
158
+ this._startVacuumPolling(matterApi, uuid, vacuumDevice);
159
+ });
160
+ // Register new Matter accessories with Homebridge
161
+ try {
162
+ const externalAccessory = this.config.externalAccessory || false;
163
+ if (externalAccessory && typeof matterApi.publishExternalAccessories === 'function') {
164
+ if (cachedActiveMatterAccessories.length > 0
165
+ && typeof matterApi.unregisterPlatformAccessories === 'function') {
166
+ this.log.info(`Unregistering ${cachedActiveMatterAccessories.length} bridged Matter accessory(ies) before external publishing.`);
167
+ matterApi.unregisterPlatformAccessories(PLUGIN_NAME, PLATFORM_NAME, cachedActiveMatterAccessories);
168
+ }
169
+ matterApi.publishExternalAccessories(PLUGIN_NAME, activeMatterAccessories);
170
+ this.log.info(`Published ${activeMatterAccessories.length} Matter accessory(ies) as external device(s).`);
171
+ }
172
+ else if (accessoriesToRegister.length > 0) {
173
+ matterApi.registerPlatformAccessories(PLUGIN_NAME, PLATFORM_NAME, accessoriesToRegister);
174
+ this.log.info(`Registered ${accessoriesToRegister.length} Matter accessory(ies) with Homebridge.`);
175
+ }
176
+ }
177
+ catch (error) {
178
+ this.log.warn('Failed to register Matter accessories; falling back to HAP.', error);
179
+ super.discoverDevices();
180
+ return;
181
+ }
182
+ // Remove any Matter accessories whose vacuums are no longer in the config
183
+ const toUnregister = [...unusedMatterAccessories.values()];
184
+ toUnregister.forEach((unusedAccessory) => {
185
+ this.log.info(`Removing unused Matter accessory: ${unusedAccessory.displayName}`);
186
+ this.matterAccessories.delete(unusedAccessory.UUID);
187
+ });
188
+ if (toUnregister.length > 0) {
189
+ try {
190
+ matterApi.unregisterPlatformAccessories(PLUGIN_NAME, PLATFORM_NAME, toUnregister);
191
+ }
192
+ catch (error) {
193
+ this.log.debug('Error unregistering stale Matter accessories:', error);
194
+ }
195
+ }
196
+ }
197
+ /**
198
+ * Build Matter command handlers for an RVC accessory.
199
+ *
200
+ * Handlers respond to Matter `changeToMode` commands (user starting or
201
+ * stopping the vacuum from a Matter controller or Apple Home) by calling
202
+ * the appropriate SharkIQ API methods.
203
+ */
204
+ _buildMatterHandlers(_matterApi, _uuid, vacuumDevice) {
205
+ return {
206
+ rvcRunMode: {
207
+ changeToMode: async ({ newMode }) => {
208
+ if (newMode === 1) {
209
+ // Start cleaning
210
+ await vacuumDevice.clean_rooms([])
211
+ .catch(createPromiseRejectionHandler(this.log, 'Matter start cleaning'));
212
+ }
213
+ else {
214
+ // Return to dock / stop
215
+ await vacuumDevice.cancel_clean()
216
+ .catch(createPromiseRejectionHandler(this.log, 'Matter cancel cleaning'));
217
+ }
218
+ },
219
+ },
220
+ };
221
+ }
222
+ /**
223
+ * Start a periodic polling loop that fetches live vacuum state from the Shark
224
+ * cloud and pushes updates into Matter cluster attributes via
225
+ * `api.matter.updateAccessoryState`.
226
+ */
227
+ _startVacuumPolling(matterApi, uuid, vacuumDevice) {
228
+ const dockedUpdateInterval = this.config.dockedUpdateInterval || TIMEOUTS.DEFAULT_DOCKED_UPDATE_INTERVAL;
229
+ const invertDockedStatus = this.config.invertDockedStatus || false;
230
+ const updateMatterState = async () => {
231
+ try {
232
+ await vacuumDevice.update([Properties.DOCKED_STATUS, Properties.OPERATING_MODE]);
233
+ const mode = vacuumDevice.operating_mode();
234
+ const dockedStatus = vacuumDevice.docked_status();
235
+ const isActive = mode === OperatingModes.START || mode === OperatingModes.STOP;
236
+ const isPaused = mode === OperatingModes.STOP;
237
+ const isDocked = invertDockedStatus ? dockedStatus !== 1 : dockedStatus === 1;
238
+ let operationalState = 66; // Docked
239
+ if (!isDocked) {
240
+ if (!isActive) {
241
+ operationalState = 0; // Stopped
242
+ }
243
+ else if (isPaused) {
244
+ operationalState = 2; // Paused
245
+ }
246
+ else {
247
+ operationalState = 1; // Running
248
+ }
249
+ }
250
+ const runMode = isActive ? 1 : 0; // 1 = Cleaning, 0 = Idle
251
+ if (typeof matterApi.updateAccessoryState === 'function') {
252
+ await matterApi.updateAccessoryState(uuid, 'rvcRunMode', { currentMode: runMode });
253
+ await matterApi.updateAccessoryState(uuid, 'rvcOperationalState', { operationalState });
254
+ }
255
+ this.log.debug(`[Matter] Vacuum ${vacuumDevice._dsn}: runMode=${runMode}, operationalState=${operationalState}`);
256
+ }
257
+ catch (error) {
258
+ this.log.debug('Failed to update Matter vacuum state:', error);
259
+ }
260
+ };
261
+ // Initial fetch, then periodic
262
+ void updateMatterState();
263
+ setInterval(() => void updateMatterState(), dockedUpdateInterval);
264
+ }
265
+ }
266
+ //# sourceMappingURL=SharkIQMatterPlatform.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"SharkIQMatterPlatform.js","sourceRoot":"","sources":["../src/SharkIQMatterPlatform.ts"],"names":[],"mappings":"AAIA,OAAO,EAAE,QAAQ,EAAE,MAAM,gBAAgB,CAAA;AACzC,OAAO,EAAE,6BAA6B,EAAE,MAAM,oBAAoB,CAAA;AAClE,OAAO,EAAE,eAAe,EAAE,MAAM,eAAe,CAAA;AAC/C,OAAO,EAAE,aAAa,EAAE,WAAW,EAAE,MAAM,eAAe,CAAA;AAC1D,OAAO,EAAE,cAAc,EAAE,UAAU,EAAE,MAAM,yBAAyB,CAAA;AAEpE;;;;;;;;;;;;;;GAcG;AACH,MAAM,OAAO,qBAAsB,SAAQ,eAAe;IACxD,2CAA2C;IAC3B,iBAAiB,GAAqB,IAAI,GAAG,EAAE,CAAA;IAE/D,YACE,GAAW,E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AC,KAAK,iBAAiB,EAAE,EAAE,oBAAoB,CAAC,CAAA;IACnE,CAAC;CACF"}
package/dist/config.d.ts CHANGED
@@ -3,5 +3,5 @@ export declare function getAuthData(authFilePath: string): Promise<AuthData>;
3
3
  export declare function setAuthData(authFilePath: string, data: AuthData): Promise<void>;
4
4
  export declare function getOAuthData(oAuthFilePath: string): Promise<OAuthData>;
5
5
  export declare function removeFile(filePath: string): Promise<void>;
6
- export declare function generateURL(oauth_file_path: string): Promise<string>;
6
+ export declare function generateURL(oauth_file_path: string, europe?: boolean): Promise<string>;
7
7
  //# sourceMappingURL=config.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"config.d.ts","sourceRoot":"","sources":["../src/config.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,QAAQ,EAAE,SAAS,EAAE,MAAM,QAAQ,CAAA;AAOjD,wBAAsB,WAAW,CAAC,YAAY,EAAE,MAAM,GAAG,OAAO,CAAC,QAAQ,CAAC,CAQzE;AAED,wBAAsB,WAAW,CAAC,YAAY,EAAE,MAAM,EAAE,IAAI,EAAE,QAAQ,GAAG,OAAO,CAAC,IAAI,CAAC,CAMrF;AAED,wBAAsB,YAAY,CAAC,aAAa,EAAE,MAAM,GAAG,OAAO,CAAC,SAAS,CAAC,CAQ5E;AAUD,wBAAsB,UAAU,CAAC,QAAQ,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC,CAMhE;AAED,wBAAsB,WAAW,CAAC,eAAe,EAAE,MAAM,GAAG,OAAO,CAAC,MAAM,CAAC,CA6B1E"}
1
+ {"version":3,"file":"config.d.ts","sourceRoot":"","sources":["../src/config.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,QAAQ,EAAE,SAAS,EAAE,MAAM,QAAQ,CAAA;AAOjD,wBAAsB,WAAW,CAAC,YAAY,EAAE,MAAM,GAAG,OAAO,CAAC,QAAQ,CAAC,CAQzE;AAED,wBAAsB,WAAW,CAAC,YAAY,EAAE,MAAM,EAAE,IAAI,EAAE,QAAQ,GAAG,OAAO,CAAC,IAAI,CAAC,CAMrF;AAED,wBAAsB,YAAY,CAAC,aAAa,EAAE,MAAM,GAAG,OAAO,CAAC,SAAS,CAAC,CAQ5E;AAUD,wBAAsB,UAAU,CAAC,QAAQ,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC,CAMhE;AAED,wBAAsB,WAAW,CAAC,eAAe,EAAE,MAAM,EAAE,MAAM,UAAQ,GAAG,OAAO,CAAC,MAAM,CAAC,CA8B1F"}
package/dist/config.js CHANGED
@@ -45,7 +45,7 @@ export async function removeFile(filePath) {
45
45
  return Promise.reject(new Error(`Error removing file: ${error}`));
46
46
  }
47
47
  }
48
- export async function generateURL(oauth_file_path) {
48
+ export async function generateURL(oauth_file_path, europe = false) {
49
49
  const state = generateRandomString(43);
50
50
  const code_verify = generateRandomString(43);
51
51
  const code_challenge = crypto.createHash('sha256').update(code_verify).digest('base64').replace(/\+/g, '-').replace(/\//g, '_').replace(/=+$/, '');
@@ -56,10 +56,11 @@ export async function generateURL(oauth_file_path) {
56
56
  };
57
57
  try {
58
58
  await setOAuthData(oauth_file_path, oAuthData);
59
- const url = `${global_vars.OAUTH.AUTH_URL}?response_type=code`
60
- + `&client_id=${encodeURIComponent(global_vars.OAUTH.CLIENT_ID)}&state=${encodeURIComponent(oAuthData.state)}&scope=${encodeURIComponent(global_vars.OAUTH.SCOPES)}&redirect_uri=${encodeURIComponent(global_vars.OAUTH.REDIRECT_URI)}&code_challenge=${encodeURIComponent(oAuthData.code_challenge)}&code_challenge_method=S256`
59
+ const oauthConfig = europe ? global_vars.EU_OAUTH : global_vars.OAUTH;
60
+ const url = `${oauthConfig.AUTH_URL}?response_type=code`
61
+ + `&client_id=${encodeURIComponent(oauthConfig.CLIENT_ID)}&state=${encodeURIComponent(oAuthData.state)}&scope=${encodeURIComponent(oauthConfig.SCOPES)}&redirect_uri=${encodeURIComponent(oauthConfig.REDIRECT_URI)}&code_challenge=${encodeURIComponent(oAuthData.code_challenge)}&code_challenge_method=S256`
61
62
  + `&ui_locales=en`
62
- + `&auth0Client=${global_vars.OAUTH.AUTH0_CLIENT}`;
63
+ + `&auth0Client=${oauthConfig.AUTH0_CLIENT}`;
63
64
  return url;
64
65
  }
65
66
  catch (error) {