@switchbot/homebridge-switchbot 5.0.0-beta.7 → 5.0.0-beta.71

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 (446) hide show
  1. package/.github/ISSUE_TEMPLATE/e2e-verification.md +36 -0
  2. package/.github/workflows/ci.yml +61 -0
  3. package/.github/workflows/manual-e2e.yml +103 -0
  4. package/CHANGELOG.md +35 -0
  5. package/E2E-VERIFICATION.md +121 -0
  6. package/MIGRATION.md +44 -0
  7. package/README.md +56 -3
  8. package/config.schema.json +99 -14823
  9. package/dist/deviceFactory.d.ts +13 -0
  10. package/dist/deviceFactory.d.ts.map +1 -0
  11. package/dist/deviceFactory.js +81 -0
  12. package/dist/deviceFactory.js.map +1 -0
  13. package/dist/devices/deviceBase.d.ts +50 -0
  14. package/dist/devices/deviceBase.d.ts.map +1 -0
  15. package/dist/devices/deviceBase.js +119 -0
  16. package/dist/devices/deviceBase.js.map +1 -0
  17. package/dist/devices/genericDevice.d.ts +283 -0
  18. package/dist/devices/genericDevice.d.ts.map +1 -0
  19. package/dist/devices/genericDevice.js +1035 -0
  20. package/dist/devices/genericDevice.js.map +1 -0
  21. package/dist/homebridge-ui/public/index.html +77 -245
  22. package/dist/homebridge-ui/server.d.ts +3 -1
  23. package/dist/homebridge-ui/server.d.ts.map +1 -1
  24. package/dist/homebridge-ui/server.js +42 -36
  25. package/dist/homebridge-ui/server.js.map +1 -1
  26. package/dist/index.d.ts.map +1 -1
  27. package/dist/index.js +5 -12
  28. package/dist/index.js.map +1 -1
  29. package/dist/platform.d.ts +27 -0
  30. package/dist/platform.d.ts.map +1 -0
  31. package/dist/platform.js +404 -0
  32. package/dist/platform.js.map +1 -0
  33. package/dist/settings.d.ts +10 -249
  34. package/dist/settings.d.ts.map +1 -1
  35. package/dist/settings.js +5 -30
  36. package/dist/settings.js.map +1 -1
  37. package/dist/switchbotClient.d.ts +32 -0
  38. package/dist/switchbotClient.d.ts.map +1 -0
  39. package/dist/switchbotClient.js +259 -0
  40. package/dist/switchbotClient.js.map +1 -0
  41. package/dist/utils.d.ts +39 -50
  42. package/dist/utils.d.ts.map +1 -1
  43. package/dist/utils.js +39 -688
  44. package/dist/utils.js.map +1 -1
  45. package/docs/assets/highlight.css +14 -0
  46. package/docs/assets/icons.js +1 -1
  47. package/docs/assets/icons.svg +1 -1
  48. package/docs/assets/main.js +2 -2
  49. package/docs/assets/style.css +3 -3
  50. package/docs/index.html +77 -13
  51. package/docs/variables/default.html +1 -1
  52. package/package.json +22 -21
  53. package/scripts/e2e/README.md +25 -0
  54. package/scripts/e2e/curtain-e2e.sh +70 -0
  55. package/scripts/e2e/fan-e2e.sh +75 -0
  56. package/scripts/e2e/light-advanced-e2e.sh +97 -0
  57. package/scripts/e2e/light-e2e.sh +75 -0
  58. package/scripts/e2e/list-accessories.sh +19 -0
  59. package/scripts/e2e/lock-e2e.sh +65 -0
  60. package/scripts/generate-matter-maps.js +60 -0
  61. package/scripts/run-e2e-local.sh +14 -0
  62. package/src/deviceFactory.ts +122 -0
  63. package/src/devices/deviceBase.ts +141 -0
  64. package/src/devices/genericDevice.ts +965 -0
  65. package/src/homebridge-ui/public/index.html +77 -245
  66. package/src/homebridge-ui/server.ts +49 -41
  67. package/src/index.ts +5 -13
  68. package/src/platform.ts +395 -0
  69. package/src/settings.ts +12 -277
  70. package/src/switchbotClient.ts +266 -0
  71. package/src/utils.ts +45 -713
  72. package/test/accessory-restore.spec.ts +73 -0
  73. package/test/device-mapping.spec.ts +37 -0
  74. package/test/deviceFactory.spec.ts +18 -0
  75. package/test/e2e/run-e2e.spec.ts +50 -0
  76. package/test/fan-swing.spec.ts +29 -0
  77. package/test/helpers/matter-harness.ts +53 -0
  78. package/test/lock-users.spec.ts +44 -0
  79. package/test/matter-childbridge.spec.ts +55 -0
  80. package/test/matter-descriptors.spec.ts +97 -0
  81. package/test/matter-device-state.spec.ts +101 -0
  82. package/test/matter-integration.spec.ts +70 -0
  83. package/test/platform.integration.spec.ts +55 -0
  84. package/test/switchbot-client-debounce.spec.ts +131 -0
  85. package/test/switchbot-client-openapi.spec.ts +56 -0
  86. package/test/switchbotClient.spec.ts +10 -0
  87. package/test/utils.spec.ts +20 -0
  88. package/vitest.config.ts +7 -0
  89. package/coverage/base.css +0 -224
  90. package/coverage/block-navigation.js +0 -87
  91. package/coverage/clover.xml +0 -15847
  92. package/coverage/coverage-final.json +0 -42
  93. package/coverage/docs/assets/dmt/dmt-component-data.js.html +0 -85
  94. package/coverage/docs/assets/dmt/dmt-components.js.html +0 -286
  95. package/coverage/docs/assets/dmt/index.html +0 -131
  96. package/coverage/docs/assets/hierarchy.js.html +0 -85
  97. package/coverage/docs/assets/icons.js.html +0 -136
  98. package/coverage/docs/assets/index.html +0 -146
  99. package/coverage/docs/assets/main.js.html +0 -265
  100. package/coverage/favicon.png +0 -0
  101. package/coverage/index.html +0 -191
  102. package/coverage/prettify.css +0 -1
  103. package/coverage/prettify.js +0 -2
  104. package/coverage/sort-arrow-sprite.png +0 -0
  105. package/coverage/sorter.js +0 -196
  106. package/coverage/src/device/blindtilt.ts.html +0 -3238
  107. package/coverage/src/device/bot.ts.html +0 -2803
  108. package/coverage/src/device/ceilinglight.ts.html +0 -2338
  109. package/coverage/src/device/colorbulb.ts.html +0 -2824
  110. package/coverage/src/device/contact.ts.html +0 -1465
  111. package/coverage/src/device/curtain.ts.html +0 -2869
  112. package/coverage/src/device/device.ts.html +0 -2500
  113. package/coverage/src/device/fan.ts.html +0 -2242
  114. package/coverage/src/device/hub.ts.html +0 -1408
  115. package/coverage/src/device/humidifier.ts.html +0 -2116
  116. package/coverage/src/device/index.html +0 -416
  117. package/coverage/src/device/iosensor.ts.html +0 -1375
  118. package/coverage/src/device/lightstrip.ts.html +0 -2617
  119. package/coverage/src/device/lock.ts.html +0 -1963
  120. package/coverage/src/device/meter.ts.html +0 -1372
  121. package/coverage/src/device/meterplus.ts.html +0 -1384
  122. package/coverage/src/device/meterpro.ts.html +0 -1618
  123. package/coverage/src/device/motion.ts.html +0 -1264
  124. package/coverage/src/device/plug.ts.html +0 -1372
  125. package/coverage/src/device/relayswitch.ts.html +0 -2284
  126. package/coverage/src/device/robotvacuumcleaner.ts.html +0 -1810
  127. package/coverage/src/device/waterdetector.ts.html +0 -1294
  128. package/coverage/src/homebridge-ui/index.html +0 -116
  129. package/coverage/src/homebridge-ui/server.ts.html +0 -229
  130. package/coverage/src/index.html +0 -161
  131. package/coverage/src/index.ts.html +0 -124
  132. package/coverage/src/irdevice/airconditioner.ts.html +0 -1687
  133. package/coverage/src/irdevice/airpurifier.ts.html +0 -844
  134. package/coverage/src/irdevice/camera.ts.html +0 -475
  135. package/coverage/src/irdevice/fan.ts.html +0 -766
  136. package/coverage/src/irdevice/index.html +0 -251
  137. package/coverage/src/irdevice/irdevice.ts.html +0 -1117
  138. package/coverage/src/irdevice/light.ts.html +0 -826
  139. package/coverage/src/irdevice/other.ts.html +0 -2458
  140. package/coverage/src/irdevice/tv.ts.html +0 -1222
  141. package/coverage/src/irdevice/vacuumcleaner.ts.html +0 -466
  142. package/coverage/src/irdevice/waterheater.ts.html +0 -469
  143. package/coverage/src/platform.ts.html +0 -8776
  144. package/coverage/src/settings.ts.html +0 -934
  145. package/coverage/src/utils.ts.html +0 -2092
  146. package/dist/devices-hap/airpurifier.d.ts +0 -54
  147. package/dist/devices-hap/airpurifier.d.ts.map +0 -1
  148. package/dist/devices-hap/airpurifier.js +0 -527
  149. package/dist/devices-hap/airpurifier.js.map +0 -1
  150. package/dist/devices-hap/blindtilt.d.ts +0 -90
  151. package/dist/devices-hap/blindtilt.d.ts.map +0 -1
  152. package/dist/devices-hap/blindtilt.js +0 -974
  153. package/dist/devices-hap/blindtilt.js.map +0 -1
  154. package/dist/devices-hap/bot.d.ts +0 -102
  155. package/dist/devices-hap/bot.d.ts.map +0 -1
  156. package/dist/devices-hap/bot.js +0 -811
  157. package/dist/devices-hap/bot.js.map +0 -1
  158. package/dist/devices-hap/ceilinglight.d.ts +0 -85
  159. package/dist/devices-hap/ceilinglight.d.ts.map +0 -1
  160. package/dist/devices-hap/ceilinglight.js +0 -701
  161. package/dist/devices-hap/ceilinglight.js.map +0 -1
  162. package/dist/devices-hap/colorbulb.d.ts +0 -88
  163. package/dist/devices-hap/colorbulb.d.ts.map +0 -1
  164. package/dist/devices-hap/colorbulb.js +0 -881
  165. package/dist/devices-hap/colorbulb.js.map +0 -1
  166. package/dist/devices-hap/contact.d.ts +0 -44
  167. package/dist/devices-hap/contact.d.ts.map +0 -1
  168. package/dist/devices-hap/contact.js +0 -409
  169. package/dist/devices-hap/contact.js.map +0 -1
  170. package/dist/devices-hap/curtain.d.ts +0 -73
  171. package/dist/devices-hap/curtain.d.ts.map +0 -1
  172. package/dist/devices-hap/curtain.js +0 -869
  173. package/dist/devices-hap/curtain.js.map +0 -1
  174. package/dist/devices-hap/device.d.ts +0 -98
  175. package/dist/devices-hap/device.d.ts.map +0 -1
  176. package/dist/devices-hap/device.js +0 -749
  177. package/dist/devices-hap/device.js.map +0 -1
  178. package/dist/devices-hap/fan.d.ts +0 -69
  179. package/dist/devices-hap/fan.d.ts.map +0 -1
  180. package/dist/devices-hap/fan.js +0 -649
  181. package/dist/devices-hap/fan.js.map +0 -1
  182. package/dist/devices-hap/hub.d.ts +0 -37
  183. package/dist/devices-hap/hub.d.ts.map +0 -1
  184. package/dist/devices-hap/hub.js +0 -392
  185. package/dist/devices-hap/hub.js.map +0 -1
  186. package/dist/devices-hap/humidifier.d.ts +0 -68
  187. package/dist/devices-hap/humidifier.d.ts.map +0 -1
  188. package/dist/devices-hap/humidifier.js +0 -628
  189. package/dist/devices-hap/humidifier.js.map +0 -1
  190. package/dist/devices-hap/iosensor.d.ts +0 -42
  191. package/dist/devices-hap/iosensor.d.ts.map +0 -1
  192. package/dist/devices-hap/iosensor.js +0 -382
  193. package/dist/devices-hap/iosensor.js.map +0 -1
  194. package/dist/devices-hap/lightstrip.d.ts +0 -79
  195. package/dist/devices-hap/lightstrip.d.ts.map +0 -1
  196. package/dist/devices-hap/lightstrip.js +0 -797
  197. package/dist/devices-hap/lightstrip.js.map +0 -1
  198. package/dist/devices-hap/lock.d.ts +0 -53
  199. package/dist/devices-hap/lock.d.ts.map +0 -1
  200. package/dist/devices-hap/lock.js +0 -561
  201. package/dist/devices-hap/lock.js.map +0 -1
  202. package/dist/devices-hap/meter.d.ts +0 -37
  203. package/dist/devices-hap/meter.d.ts.map +0 -1
  204. package/dist/devices-hap/meter.js +0 -379
  205. package/dist/devices-hap/meter.js.map +0 -1
  206. package/dist/devices-hap/meterplus.d.ts +0 -42
  207. package/dist/devices-hap/meterplus.d.ts.map +0 -1
  208. package/dist/devices-hap/meterplus.js +0 -384
  209. package/dist/devices-hap/meterplus.js.map +0 -1
  210. package/dist/devices-hap/meterpro.d.ts +0 -43
  211. package/dist/devices-hap/meterpro.d.ts.map +0 -1
  212. package/dist/devices-hap/meterpro.js +0 -468
  213. package/dist/devices-hap/meterpro.js.map +0 -1
  214. package/dist/devices-hap/motion.d.ts +0 -42
  215. package/dist/devices-hap/motion.d.ts.map +0 -1
  216. package/dist/devices-hap/motion.js +0 -345
  217. package/dist/devices-hap/motion.js.map +0 -1
  218. package/dist/devices-hap/plug.d.ts +0 -49
  219. package/dist/devices-hap/plug.d.ts.map +0 -1
  220. package/dist/devices-hap/plug.js +0 -395
  221. package/dist/devices-hap/plug.js.map +0 -1
  222. package/dist/devices-hap/relayswitch.d.ts +0 -96
  223. package/dist/devices-hap/relayswitch.d.ts.map +0 -1
  224. package/dist/devices-hap/relayswitch.js +0 -642
  225. package/dist/devices-hap/relayswitch.js.map +0 -1
  226. package/dist/devices-hap/robotvacuumcleaner.d.ts +0 -54
  227. package/dist/devices-hap/robotvacuumcleaner.d.ts.map +0 -1
  228. package/dist/devices-hap/robotvacuumcleaner.js +0 -523
  229. package/dist/devices-hap/robotvacuumcleaner.js.map +0 -1
  230. package/dist/devices-hap/waterdetector.d.ts +0 -41
  231. package/dist/devices-hap/waterdetector.d.ts.map +0 -1
  232. package/dist/devices-hap/waterdetector.js +0 -356
  233. package/dist/devices-hap/waterdetector.js.map +0 -1
  234. package/dist/devices-matter/BaseMatterAccessory.d.ts +0 -63
  235. package/dist/devices-matter/BaseMatterAccessory.d.ts.map +0 -1
  236. package/dist/devices-matter/BaseMatterAccessory.js +0 -100
  237. package/dist/devices-matter/BaseMatterAccessory.js.map +0 -1
  238. package/dist/devices-matter/ColorLightAccessory.d.ts +0 -20
  239. package/dist/devices-matter/ColorLightAccessory.d.ts.map +0 -1
  240. package/dist/devices-matter/ColorLightAccessory.js +0 -95
  241. package/dist/devices-matter/ColorLightAccessory.js.map +0 -1
  242. package/dist/devices-matter/ColorTemperatureLightAccessory.d.ts +0 -18
  243. package/dist/devices-matter/ColorTemperatureLightAccessory.d.ts.map +0 -1
  244. package/dist/devices-matter/ColorTemperatureLightAccessory.js +0 -78
  245. package/dist/devices-matter/ColorTemperatureLightAccessory.js.map +0 -1
  246. package/dist/devices-matter/ContactSensorAccessory.d.ts +0 -12
  247. package/dist/devices-matter/ContactSensorAccessory.d.ts.map +0 -1
  248. package/dist/devices-matter/ContactSensorAccessory.js +0 -34
  249. package/dist/devices-matter/ContactSensorAccessory.js.map +0 -1
  250. package/dist/devices-matter/DimmableLightAccessory.d.ts +0 -58
  251. package/dist/devices-matter/DimmableLightAccessory.d.ts.map +0 -1
  252. package/dist/devices-matter/DimmableLightAccessory.js +0 -167
  253. package/dist/devices-matter/DimmableLightAccessory.js.map +0 -1
  254. package/dist/devices-matter/DoorLockAccessory.d.ts +0 -14
  255. package/dist/devices-matter/DoorLockAccessory.d.ts.map +0 -1
  256. package/dist/devices-matter/DoorLockAccessory.js +0 -50
  257. package/dist/devices-matter/DoorLockAccessory.js.map +0 -1
  258. package/dist/devices-matter/ExtendedColorLightAccessory.d.ts +0 -21
  259. package/dist/devices-matter/ExtendedColorLightAccessory.d.ts.map +0 -1
  260. package/dist/devices-matter/ExtendedColorLightAccessory.js +0 -107
  261. package/dist/devices-matter/ExtendedColorLightAccessory.js.map +0 -1
  262. package/dist/devices-matter/FanAccessory.d.ts +0 -16
  263. package/dist/devices-matter/FanAccessory.d.ts.map +0 -1
  264. package/dist/devices-matter/FanAccessory.js +0 -81
  265. package/dist/devices-matter/FanAccessory.js.map +0 -1
  266. package/dist/devices-matter/HumiditySensorAccessory.d.ts +0 -12
  267. package/dist/devices-matter/HumiditySensorAccessory.d.ts.map +0 -1
  268. package/dist/devices-matter/HumiditySensorAccessory.js +0 -34
  269. package/dist/devices-matter/HumiditySensorAccessory.js.map +0 -1
  270. package/dist/devices-matter/LeakSensorAccessory.d.ts +0 -12
  271. package/dist/devices-matter/LeakSensorAccessory.d.ts.map +0 -1
  272. package/dist/devices-matter/LeakSensorAccessory.js +0 -33
  273. package/dist/devices-matter/LeakSensorAccessory.js.map +0 -1
  274. package/dist/devices-matter/LightSensorAccessory.d.ts +0 -12
  275. package/dist/devices-matter/LightSensorAccessory.d.ts.map +0 -1
  276. package/dist/devices-matter/LightSensorAccessory.js +0 -34
  277. package/dist/devices-matter/LightSensorAccessory.js.map +0 -1
  278. package/dist/devices-matter/OccupancySensorAccessory.d.ts +0 -12
  279. package/dist/devices-matter/OccupancySensorAccessory.d.ts.map +0 -1
  280. package/dist/devices-matter/OccupancySensorAccessory.js +0 -39
  281. package/dist/devices-matter/OccupancySensorAccessory.js.map +0 -1
  282. package/dist/devices-matter/OnOffLightAccessory.d.ts +0 -38
  283. package/dist/devices-matter/OnOffLightAccessory.d.ts.map +0 -1
  284. package/dist/devices-matter/OnOffLightAccessory.js +0 -118
  285. package/dist/devices-matter/OnOffLightAccessory.js.map +0 -1
  286. package/dist/devices-matter/OnOffOutletAccessory.d.ts +0 -12
  287. package/dist/devices-matter/OnOffOutletAccessory.d.ts.map +0 -1
  288. package/dist/devices-matter/OnOffOutletAccessory.js +0 -40
  289. package/dist/devices-matter/OnOffOutletAccessory.js.map +0 -1
  290. package/dist/devices-matter/OnOffSwitchAccessory.d.ts +0 -14
  291. package/dist/devices-matter/OnOffSwitchAccessory.d.ts.map +0 -1
  292. package/dist/devices-matter/OnOffSwitchAccessory.js +0 -42
  293. package/dist/devices-matter/OnOffSwitchAccessory.js.map +0 -1
  294. package/dist/devices-matter/RoboticVacuumAccessory.d.ts +0 -68
  295. package/dist/devices-matter/RoboticVacuumAccessory.d.ts.map +0 -1
  296. package/dist/devices-matter/RoboticVacuumAccessory.js +0 -334
  297. package/dist/devices-matter/RoboticVacuumAccessory.js.map +0 -1
  298. package/dist/devices-matter/SmokeCOAlarmAccessory.d.ts +0 -11
  299. package/dist/devices-matter/SmokeCOAlarmAccessory.d.ts.map +0 -1
  300. package/dist/devices-matter/SmokeCOAlarmAccessory.js +0 -49
  301. package/dist/devices-matter/SmokeCOAlarmAccessory.js.map +0 -1
  302. package/dist/devices-matter/TemperatureSensorAccessory.d.ts +0 -12
  303. package/dist/devices-matter/TemperatureSensorAccessory.d.ts.map +0 -1
  304. package/dist/devices-matter/TemperatureSensorAccessory.js +0 -36
  305. package/dist/devices-matter/TemperatureSensorAccessory.js.map +0 -1
  306. package/dist/devices-matter/ThermostatAccessory.d.ts +0 -19
  307. package/dist/devices-matter/ThermostatAccessory.d.ts.map +0 -1
  308. package/dist/devices-matter/ThermostatAccessory.js +0 -95
  309. package/dist/devices-matter/ThermostatAccessory.js.map +0 -1
  310. package/dist/devices-matter/VenetianBlindAccessory.d.ts +0 -19
  311. package/dist/devices-matter/VenetianBlindAccessory.d.ts.map +0 -1
  312. package/dist/devices-matter/VenetianBlindAccessory.js +0 -99
  313. package/dist/devices-matter/VenetianBlindAccessory.js.map +0 -1
  314. package/dist/devices-matter/WindowBlindAccessory.d.ts +0 -17
  315. package/dist/devices-matter/WindowBlindAccessory.d.ts.map +0 -1
  316. package/dist/devices-matter/WindowBlindAccessory.js +0 -80
  317. package/dist/devices-matter/WindowBlindAccessory.js.map +0 -1
  318. package/dist/devices-matter/custom/PowerStripAccessory.d.ts +0 -97
  319. package/dist/devices-matter/custom/PowerStripAccessory.d.ts.map +0 -1
  320. package/dist/devices-matter/custom/PowerStripAccessory.js +0 -265
  321. package/dist/devices-matter/custom/PowerStripAccessory.js.map +0 -1
  322. package/dist/devices-matter/custom/index.d.ts +0 -8
  323. package/dist/devices-matter/custom/index.d.ts.map +0 -1
  324. package/dist/devices-matter/custom/index.js +0 -8
  325. package/dist/devices-matter/custom/index.js.map +0 -1
  326. package/dist/devices-matter/index.d.ts +0 -29
  327. package/dist/devices-matter/index.d.ts.map +0 -1
  328. package/dist/devices-matter/index.js +0 -28
  329. package/dist/devices-matter/index.js.map +0 -1
  330. package/dist/index.test.d.ts +0 -2
  331. package/dist/index.test.d.ts.map +0 -1
  332. package/dist/index.test.js +0 -14
  333. package/dist/index.test.js.map +0 -1
  334. package/dist/irdevice/airconditioner.d.ts +0 -61
  335. package/dist/irdevice/airconditioner.d.ts.map +0 -1
  336. package/dist/irdevice/airconditioner.js +0 -472
  337. package/dist/irdevice/airconditioner.js.map +0 -1
  338. package/dist/irdevice/airpurifier.d.ts +0 -50
  339. package/dist/irdevice/airpurifier.d.ts.map +0 -1
  340. package/dist/irdevice/airpurifier.js +0 -213
  341. package/dist/irdevice/airpurifier.js.map +0 -1
  342. package/dist/irdevice/camera.d.ts +0 -32
  343. package/dist/irdevice/camera.d.ts.map +0 -1
  344. package/dist/irdevice/camera.js +0 -107
  345. package/dist/irdevice/camera.js.map +0 -1
  346. package/dist/irdevice/fan.d.ts +0 -36
  347. package/dist/irdevice/fan.d.ts.map +0 -1
  348. package/dist/irdevice/fan.js +0 -200
  349. package/dist/irdevice/fan.js.map +0 -1
  350. package/dist/irdevice/irdevice.d.ts +0 -68
  351. package/dist/irdevice/irdevice.d.ts.map +0 -1
  352. package/dist/irdevice/irdevice.js +0 -298
  353. package/dist/irdevice/irdevice.js.map +0 -1
  354. package/dist/irdevice/light.d.ts +0 -36
  355. package/dist/irdevice/light.d.ts.map +0 -1
  356. package/dist/irdevice/light.js +0 -206
  357. package/dist/irdevice/light.js.map +0 -1
  358. package/dist/irdevice/other.d.ts +0 -57
  359. package/dist/irdevice/other.d.ts.map +0 -1
  360. package/dist/irdevice/other.js +0 -778
  361. package/dist/irdevice/other.js.map +0 -1
  362. package/dist/irdevice/tv.d.ts +0 -45
  363. package/dist/irdevice/tv.d.ts.map +0 -1
  364. package/dist/irdevice/tv.js +0 -327
  365. package/dist/irdevice/tv.js.map +0 -1
  366. package/dist/irdevice/vacuumcleaner.d.ts +0 -28
  367. package/dist/irdevice/vacuumcleaner.d.ts.map +0 -1
  368. package/dist/irdevice/vacuumcleaner.js +0 -104
  369. package/dist/irdevice/vacuumcleaner.js.map +0 -1
  370. package/dist/irdevice/waterheater.d.ts +0 -30
  371. package/dist/irdevice/waterheater.d.ts.map +0 -1
  372. package/dist/irdevice/waterheater.js +0 -105
  373. package/dist/irdevice/waterheater.js.map +0 -1
  374. package/dist/platform-hap.d.ts +0 -149
  375. package/dist/platform-hap.d.ts.map +0 -1
  376. package/dist/platform-hap.js +0 -2861
  377. package/dist/platform-hap.js.map +0 -1
  378. package/dist/platform-matter.d.ts +0 -101
  379. package/dist/platform-matter.d.ts.map +0 -1
  380. package/dist/platform-matter.js +0 -896
  381. package/dist/platform-matter.js.map +0 -1
  382. package/dist/verifyconfig.test.d.ts +0 -2
  383. package/dist/verifyconfig.test.d.ts.map +0 -1
  384. package/dist/verifyconfig.test.js +0 -167
  385. package/dist/verifyconfig.test.js.map +0 -1
  386. package/src/custom.d.ts +0 -7
  387. package/src/devices-hap/airpurifier.ts +0 -563
  388. package/src/devices-hap/blindtilt.ts +0 -1049
  389. package/src/devices-hap/bot.ts +0 -900
  390. package/src/devices-hap/ceilinglight.ts +0 -742
  391. package/src/devices-hap/colorbulb.ts +0 -904
  392. package/src/devices-hap/contact.ts +0 -457
  393. package/src/devices-hap/curtain.ts +0 -944
  394. package/src/devices-hap/device.ts +0 -811
  395. package/src/devices-hap/fan.ts +0 -711
  396. package/src/devices-hap/hub.ts +0 -439
  397. package/src/devices-hap/humidifier.ts +0 -669
  398. package/src/devices-hap/iosensor.ts +0 -427
  399. package/src/devices-hap/lightstrip.ts +0 -836
  400. package/src/devices-hap/lock.ts +0 -620
  401. package/src/devices-hap/meter.ts +0 -426
  402. package/src/devices-hap/meterplus.ts +0 -430
  403. package/src/devices-hap/meterpro.ts +0 -522
  404. package/src/devices-hap/motion.ts +0 -390
  405. package/src/devices-hap/plug.ts +0 -423
  406. package/src/devices-hap/relayswitch.ts +0 -727
  407. package/src/devices-hap/robotvacuumcleaner.ts +0 -568
  408. package/src/devices-hap/waterdetector.ts +0 -400
  409. package/src/devices-matter/BaseMatterAccessory.ts +0 -131
  410. package/src/devices-matter/ColorLightAccessory.ts +0 -110
  411. package/src/devices-matter/ColorTemperatureLightAccessory.ts +0 -92
  412. package/src/devices-matter/ContactSensorAccessory.ts +0 -41
  413. package/src/devices-matter/DimmableLightAccessory.ts +0 -192
  414. package/src/devices-matter/DoorLockAccessory.ts +0 -60
  415. package/src/devices-matter/ExtendedColorLightAccessory.ts +0 -123
  416. package/src/devices-matter/FanAccessory.ts +0 -95
  417. package/src/devices-matter/HumiditySensorAccessory.ts +0 -41
  418. package/src/devices-matter/LeakSensorAccessory.ts +0 -40
  419. package/src/devices-matter/LightSensorAccessory.ts +0 -41
  420. package/src/devices-matter/OccupancySensorAccessory.ts +0 -48
  421. package/src/devices-matter/OnOffLightAccessory.ts +0 -133
  422. package/src/devices-matter/OnOffOutletAccessory.ts +0 -46
  423. package/src/devices-matter/OnOffSwitchAccessory.ts +0 -51
  424. package/src/devices-matter/RoboticVacuumAccessory.ts +0 -407
  425. package/src/devices-matter/SmokeCOAlarmAccessory.ts +0 -59
  426. package/src/devices-matter/TemperatureSensorAccessory.ts +0 -43
  427. package/src/devices-matter/ThermostatAccessory.ts +0 -110
  428. package/src/devices-matter/VenetianBlindAccessory.ts +0 -115
  429. package/src/devices-matter/WindowBlindAccessory.ts +0 -92
  430. package/src/devices-matter/custom/PowerStripAccessory.ts +0 -309
  431. package/src/devices-matter/custom/index.ts +0 -8
  432. package/src/devices-matter/index.ts +0 -29
  433. package/src/index.test.ts +0 -19
  434. package/src/irdevice/airconditioner.ts +0 -533
  435. package/src/irdevice/airpurifier.ts +0 -252
  436. package/src/irdevice/camera.ts +0 -129
  437. package/src/irdevice/fan.ts +0 -226
  438. package/src/irdevice/irdevice.ts +0 -344
  439. package/src/irdevice/light.ts +0 -246
  440. package/src/irdevice/other.ts +0 -790
  441. package/src/irdevice/tv.ts +0 -378
  442. package/src/irdevice/vacuumcleaner.ts +0 -126
  443. package/src/irdevice/waterheater.ts +0 -127
  444. package/src/platform-hap.ts +0 -2997
  445. package/src/platform-matter.ts +0 -1010
  446. package/src/verifyconfig.test.ts +0 -197
@@ -1,1010 +0,0 @@
1
- import type {
2
- API,
3
- DynamicPlatformPlugin,
4
- Logging,
5
- MatterAccessory,
6
- SerializedMatterAccessory,
7
- } from 'homebridge'
8
- import type { bodyChange, device } from 'node-switchbot'
9
-
10
- import type { SwitchBotPlatformConfig } from './settings.js'
11
-
12
- import { SwitchBotBLE, SwitchBotOpenAPI } from 'node-switchbot'
13
-
14
- import {
15
- ColorLightAccessory,
16
- ColorTemperatureLightAccessory,
17
- ContactSensorAccessory,
18
- DimmableLightAccessory,
19
- DoorLockAccessory,
20
- ExtendedColorLightAccessory,
21
- FanAccessory,
22
- HumiditySensorAccessory,
23
- LeakSensorAccessory,
24
- LightSensorAccessory,
25
- OccupancySensorAccessory,
26
- OnOffLightAccessory,
27
- OnOffOutletAccessory,
28
- OnOffSwitchAccessory,
29
- PowerStripAccessory,
30
- RoboticVacuumAccessory,
31
- SmokeCOAlarmAccessory,
32
- TemperatureSensorAccessory,
33
- ThermostatAccessory,
34
- VenetianBlindAccessory,
35
- WindowBlindAccessory,
36
- } from './devices-matter/index.js'
37
- import { PLATFORM_NAME, PLUGIN_NAME } from './settings.js'
38
- import { cleanDeviceConfig, formatDeviceIdAsMac, hs2rgb, rgb2hs, sleep } from './utils.js'
39
-
40
- /**
41
- * MatterPlatform
42
- * Demonstrates all available Matter device types in Homebridge
43
- *
44
- * Organized by official Matter Specification v1.4.1 categories
45
- */
46
- export class SwitchBotMatterPlatform implements DynamicPlatformPlugin {
47
- // Track restored HAP cached accessories (required for DynamicPlatformPlugin)
48
- // This is commented out here as this plugin does not have any HAP accessories
49
- // public readonly accessories: Map<string, PlatformAccessory> = new Map()
50
-
51
- // Track restored Matter cached accessories
52
- public readonly matterAccessories: Map<string, SerializedMatterAccessory> = new Map()
53
- // node-switchbot clients
54
- private switchBotAPI?: SwitchBotOpenAPI
55
- private switchBotBLE?: SwitchBotBLE
56
- // discovered devices cache
57
- private discoveredDevices: device[] = []
58
- // BLE event handlers keyed by device MAC (formatted)
59
- private bleEventHandler: { [x: string]: (context: any) => void } = {}
60
-
61
- constructor(
62
- public readonly log: Logging,
63
- public readonly config: SwitchBotPlatformConfig,
64
- public readonly api: API,
65
- ) {
66
- this.log.debug('Finished initializing platform:', this.config.name)
67
-
68
- // Normalize deviceConfig to remove UI-inserted defaults
69
- try {
70
- if ((this.config as any).options) {
71
- const cleaned = cleanDeviceConfig((this.config as any).options.deviceConfig)
72
- if (cleaned) {
73
- ;(this.config as any).options.deviceConfig = cleaned
74
- } else {
75
- delete (this.config as any).options.deviceConfig
76
- }
77
- }
78
- } catch (e) {
79
- this.log.debug('Failed to clean deviceConfig: %s', e)
80
- }
81
-
82
- // Does the user have a version of Homebridge that is compatible with matter?
83
- if (!this.api.isMatterAvailable?.()) {
84
- this.log.warn('Matter is not available in this version of Homebridge. Please update Homebridge to use this plugin.')
85
- }
86
-
87
- // Check if the user has matter enabled, this means:
88
- // - If the plugin is running on the main bridge, then the user must have enabled matter in the Homebridge settings page in the UI
89
- // - If the plugin is running on a child bridge, then the user must have enabled matter on the plugin bridge settings section in the UI
90
- // In reality, only the below check is needed, but they are both included here for completeness
91
- // Remember to use a '?.' optional chaining operator in case the user is running an older version of Homebridge that does not have these APIs
92
- if (!this.api.isMatterEnabled?.()) {
93
- this.log.warn('Matter is not enabled in Homebridge. Please enable Matter in the Homebridge settings to use this plugin.')
94
- return
95
- }
96
-
97
- // Register Matter accessories when Homebridge has finished launching
98
- this.api.on('didFinishLaunching', () => {
99
- this.log.debug('Executed didFinishLaunching callback')
100
- // Initialize SwitchBot API clients
101
- try {
102
- if (this.config.credentials?.token && this.config.credentials?.secret) {
103
- this.switchBotAPI = new SwitchBotOpenAPI(this.config.credentials.token, this.config.credentials.secret, this.config.options?.hostname)
104
- // forward basic logs
105
- if (!this.config.options?.disableLogsforOpenAPI && this.switchBotAPI?.on) {
106
- this.switchBotAPI.on('log', (l: any) => this.log.debug('[SwitchBot OpenAPI]', l.message))
107
- }
108
- } else {
109
- this.log.debug('SwitchBot OpenAPI credentials not provided; cloud devices will be skipped')
110
- }
111
- } catch (e: any) {
112
- this.log.error('Failed to initialize SwitchBot OpenAPI:', e?.message ?? e)
113
- }
114
-
115
- try {
116
- this.switchBotBLE = new SwitchBotBLE()
117
- if (!this.config.options?.disableLogsforBLE && this.switchBotBLE?.on) {
118
- this.switchBotBLE.on('log', (l: any) => this.log.debug('[SwitchBot BLE]', l.message))
119
- }
120
- } catch (e: any) {
121
- this.log.error('Failed to initialize SwitchBot BLE client:', e?.message ?? e)
122
- }
123
-
124
- // If BLE scanning is enabled, start scanning and route advertisements to registered handlers
125
- if (this.config.options?.BLE && this.switchBotBLE) {
126
- const ble = this.switchBotBLE
127
- ;(async () => {
128
- try {
129
- await ble.startScan()
130
- } catch (e: any) {
131
- this.log.error(`Failed to start BLE scanning: ${e?.message ?? e}`)
132
- }
133
-
134
- // route advertisements to our handlers
135
- ble.onadvertisement = async (ad: any) => {
136
- try {
137
- const mac = (ad.address || '').toLowerCase()
138
- const handler = this.bleEventHandler[mac]
139
- if (handler) {
140
- await handler(ad.serviceData)
141
- }
142
- } catch (e: any) {
143
- this.log.error(`Failed to handle BLE advertisement: ${e?.message ?? e}`)
144
- }
145
- }
146
- })()
147
- }
148
-
149
- // perform device discovery from SwitchBot OpenAPI (if configured)
150
- void this.discoverDevices()
151
-
152
- this.registerMatterAccessories()
153
- })
154
- }
155
-
156
- /**
157
- * Map a SwitchBot device object to a MatterAccessory using the device-specific
158
- * Matter accessory classes in `src/devices-matter`.
159
- */
160
- private async createAccessoryFromDevice(dev: device): Promise<MatterAccessory<Record<string, unknown>> | undefined> {
161
- // Basic metadata
162
- const displayName = dev.deviceName ?? dev.deviceId ?? 'SwitchBot Device'
163
- const serial = dev.deviceId ?? 'unknown'
164
- const manufacturer = 'SwitchBot'
165
- const model = dev.deviceType ?? 'SwitchBot'
166
- const firmware = (dev as any).firmware ?? (dev as any).version ?? '0.0.0'
167
-
168
- // Helper to build a default opts object consumed by the matter device classes
169
- const baseOpts = {
170
- uuid: this.api.matter.uuid.generate(serial),
171
- displayName,
172
- serialNumber: serial,
173
- manufacturer,
174
- model,
175
- firmwareRevision: String(firmware),
176
- hardwareRevision: '1.0.0',
177
- deviceId: dev.deviceId,
178
- context: { deviceId: dev.deviceId },
179
- }
180
-
181
- // Small helper to wrap common OpenAPI on/off commands
182
- // Helper to send an OpenAPI command
183
- const sendOpenAPI = async (command: string, parameter = 'default') => {
184
- const bodyChange: bodyChange = { command, parameter, commandType: 'command' }
185
- return this.retryCommand(dev, bodyChange, this.config.options?.maxRetries ?? 1, this.config.options?.delayBetweenRetries ?? 1000)
186
- }
187
-
188
- // Helper to send a BLE action if Platform BLE is enabled and switchBotBLE exists
189
- const sendBLE = async (methodName: string, ...args: any[]) => {
190
- // Provide a small retry loop for flaky BLE operations
191
- if (!this.switchBotBLE) {
192
- throw new Error('Platform BLE not available')
193
- }
194
- const id = formatDeviceIdAsMac(dev.deviceId)
195
- const maxRetries = (this.config.options as any)?.bleRetries ?? 2
196
- const retryDelay = (this.config.options as any)?.bleRetryDelay ?? 500
197
- let attempt = 0
198
- while (attempt < maxRetries) {
199
- try {
200
- const list = await this.switchBotBLE.discover({ model: (dev as any).bleModel, id })
201
- if (!Array.isArray(list) || list.length === 0) {
202
- throw new Error('BLE device not found')
203
- }
204
- const deviceInst: any = list[0]
205
- if (typeof deviceInst[methodName] !== 'function') {
206
- throw new TypeError(`BLE method ${methodName} not available on device`)
207
- }
208
- return await deviceInst[methodName](...args)
209
- } catch (e: any) {
210
- attempt++
211
- if (attempt >= maxRetries) {
212
- throw e
213
- }
214
- this.log.debug(`BLE ${methodName} attempt ${attempt} failed for ${dev.deviceId}: ${e?.message ?? e}, retrying in ${retryDelay}ms`)
215
- await sleep(retryDelay)
216
- }
217
- }
218
- throw new Error('BLE operation failed')
219
- }
220
-
221
- const makeOnOffHandlers = (uuid: string) => ({
222
- onOff: {
223
- on: async () => {
224
- try {
225
- if (this.config.options?.BLE && this.switchBotBLE) {
226
- await sendBLE('turnOn')
227
- } else {
228
- await sendOpenAPI('turnOn')
229
- }
230
- await this.api.matter.updateAccessoryState(uuid, this.api.matter.clusterNames.OnOff, { onOff: true })
231
- } catch (e: any) {
232
- this.log.error(`Failed to turn on device ${dev.deviceId}: ${e?.message ?? e}`)
233
- }
234
- },
235
- off: async () => {
236
- try {
237
- if (this.config.options?.BLE && this.switchBotBLE) {
238
- await sendBLE('turnOff')
239
- } else {
240
- await sendOpenAPI('turnOff')
241
- }
242
- await this.api.matter.updateAccessoryState(uuid, this.api.matter.clusterNames.OnOff, { onOff: false })
243
- } catch (e: any) {
244
- this.log.error(`Failed to turn off device ${dev.deviceId}: ${e?.message ?? e}`)
245
- }
246
- },
247
- },
248
- })
249
-
250
- // Mapping from SwitchBot deviceType -> constructor
251
- const mapping: { [key: string]: any } = {
252
- // Plugs / Outlets
253
- 'Plug': OnOffOutletAccessory,
254
- 'Plug Mini (US)': OnOffOutletAccessory,
255
- 'Plug Mini (JP)': OnOffOutletAccessory,
256
-
257
- // Lighting
258
- 'Color Bulb': ColorLightAccessory,
259
- 'Ceiling Light': ColorTemperatureLightAccessory,
260
- 'Ceiling Light Pro': ColorTemperatureLightAccessory,
261
- 'Strip Light': ExtendedColorLightAccessory,
262
- 'Dimmable Light': DimmableLightAccessory,
263
-
264
- // Robot Vacuums
265
- 'K10+': RoboticVacuumAccessory,
266
- 'K10+ Pro': RoboticVacuumAccessory,
267
- 'WoSweeper': RoboticVacuumAccessory,
268
- 'WoSweeperMini': RoboticVacuumAccessory,
269
- 'Robot Vacuum Cleaner S1': RoboticVacuumAccessory,
270
- 'Robot Vacuum Cleaner S1 Plus': RoboticVacuumAccessory,
271
- 'Robot Vacuum Cleaner S10': RoboticVacuumAccessory,
272
-
273
- // Locks
274
- 'Smart Lock': DoorLockAccessory,
275
- 'Smart Lock Pro': DoorLockAccessory,
276
-
277
- // Sensors
278
- 'Motion Sensor': OccupancySensorAccessory,
279
- 'Contact Sensor': ContactSensorAccessory,
280
- 'Water Detector': LeakSensorAccessory,
281
- 'Meter': TemperatureSensorAccessory,
282
- 'MeterPlus': TemperatureSensorAccessory,
283
- 'MeterPro': TemperatureSensorAccessory,
284
- 'WoIOSensor': TemperatureSensorAccessory,
285
- 'Air Purifier PM2.5': HumiditySensorAccessory,
286
-
287
- // Fans
288
- 'Battery Circulator Fan': FanAccessory,
289
-
290
- // Curtains / Blinds
291
- 'Blind Tilt': VenetianBlindAccessory,
292
- 'Curtain': WindowBlindAccessory,
293
- 'Curtain3': WindowBlindAccessory,
294
- 'WoRollerShade': WindowBlindAccessory,
295
- 'Roller Shade': WindowBlindAccessory,
296
-
297
- // Switches / Relays
298
- 'Relay Switch 1': OnOffSwitchAccessory,
299
- 'Relay Switch 1PM': OnOffSwitchAccessory,
300
-
301
- // Misc
302
- 'Hub 2': undefined,
303
- 'Hub 3': undefined,
304
- 'Bot': undefined,
305
- 'Humidifier': undefined,
306
- 'Humidifier2': undefined,
307
- 'Air Purifier Table PM2.5': undefined,
308
- 'Air Purifier VOC': undefined,
309
- 'Air Purifier Table VOC': undefined,
310
- }
311
-
312
- const Ctor = mapping[dev.deviceType ?? '']
313
- if (!Ctor) {
314
- this.log.debug(`No Matter mapping for deviceType='${dev.deviceType}', deviceId=${dev.deviceId}`)
315
- return undefined
316
- }
317
-
318
- // Build opts and handlers tailored for basic capabilities
319
- const uuid = baseOpts.uuid
320
- const handlers: Record<string, any> = {}
321
-
322
- // On/Off common
323
- handlers.onOff = makeOnOffHandlers(uuid).onOff
324
-
325
- // If this is a light, add brightness and color handlers
326
- if (['Color Bulb', 'Ceiling Light', 'Ceiling Light Pro', 'Strip Light', 'Dimmable Light'].includes(dev.deviceType ?? '')) {
327
- // levelControl
328
- handlers.levelControl = {
329
- moveToLevelWithOnOff: async (request: any) => {
330
- try {
331
- const level = request.level as number
332
- const percent = Math.round((level / 254) * 100)
333
- if (this.config.options?.BLE && this.switchBotBLE) {
334
- await sendBLE('setBrightness', percent)
335
- } else {
336
- await sendOpenAPI('setBrightness', `${percent}`)
337
- }
338
- await this.api.matter.updateAccessoryState(uuid, this.api.matter.clusterNames.LevelControl, { currentLevel: level })
339
- } catch (e: any) {
340
- this.log.error(`Failed to set brightness for ${dev.deviceId}: ${e?.message ?? e}`)
341
- }
342
- },
343
- }
344
-
345
- // colorControl
346
- handlers.colorControl = {
347
- moveToHueAndSaturationLogic: async (request: any) => {
348
- try {
349
- const hue = request.hue as number
350
- const saturation = request.saturation as number
351
- const [r, g, b] = hs2rgb(Math.round((hue / 254) * 360), Math.round((saturation / 254) * 100))
352
- if (this.config.options?.BLE && this.switchBotBLE) {
353
- await sendBLE('setRGB', Number(request.level ?? 100), r, g, b)
354
- } else {
355
- await sendOpenAPI('setColor', `${r}:${g}:${b}`)
356
- }
357
- await this.api.matter.updateAccessoryState(uuid, this.api.matter.clusterNames.ColorControl, { currentHue: hue, currentSaturation: saturation })
358
- } catch (e: any) {
359
- this.log.error(`Failed to set hue/sat for ${dev.deviceId}: ${e?.message ?? e}`)
360
- }
361
- },
362
- moveToColorLogic: async (request: any) => {
363
- try {
364
- // MoveToColor gives colorX/colorY values; convert to approximate RGB by mapping to 0-255 scale
365
- const colorX = request.colorX as number
366
- const colorY = request.colorY as number
367
- // Naive conversion: map X/Y into RGB via hue approximation (not colorimetrically accurate)
368
- const hueApprox = Math.round((colorX / 65535) * 360)
369
- const satApprox = Math.round((colorY / 65535) * 100)
370
- const [r, g, b] = hs2rgb(hueApprox, satApprox)
371
- if (this.config.options?.BLE && this.switchBotBLE) {
372
- await sendBLE('setRGB', Number(request.level ?? 100), r, g, b)
373
- } else {
374
- await sendOpenAPI('setColor', `${r}:${g}:${b}`)
375
- }
376
- await this.api.matter.updateAccessoryState(uuid, this.api.matter.clusterNames.ColorControl, { currentX: colorX, currentY: colorY })
377
- } catch (e: any) {
378
- this.log.error(`Failed to set XY color for ${dev.deviceId}: ${e?.message ?? e}`)
379
- }
380
- },
381
- }
382
-
383
- // color temperature — map to kelvin and send setColorTemperature
384
- handlers.colorTemperature = {
385
- moveToColorTemperature: async (request: any) => {
386
- try {
387
- const kelvin = Math.round(1000000 / Number(request.colorTemperature))
388
- if (this.config.options?.BLE && this.switchBotBLE) {
389
- await sendBLE('setColorTemperature', kelvin)
390
- } else {
391
- await sendOpenAPI('setColorTemperature', `${kelvin}`)
392
- }
393
- await this.api.matter.updateAccessoryState(uuid, this.api.matter.clusterNames.ColorControl, { currentX: request.colorX ?? 0, currentY: request.colorY ?? 0 })
394
- } catch (e: any) {
395
- this.log.error(`Failed to set color temperature for ${dev.deviceId}: ${e?.message ?? e}`)
396
- }
397
- },
398
- }
399
- }
400
-
401
- const opts = Object.assign({}, baseOpts, { handlers })
402
-
403
- // Instantiate the device class and return its serialized accessory
404
- const instance = new Ctor(this.api, this.log, opts)
405
-
406
- // Register BLE->Matter push handler for this device's MAC (if BLE scanning is active)
407
- try {
408
- const mac = formatDeviceIdAsMac(dev.deviceId).toLowerCase()
409
- // Handler receives advertisement/serviceData when BLE scan events arrive
410
- this.bleEventHandler[mac] = async (serviceData?: any) => {
411
- const uuidLocal = baseOpts.uuid
412
-
413
- // First try model-specific / normalized parsing of BLE advertisement
414
- try {
415
- const parsed = this.parseAdvertisementForDevice(dev, serviceData)
416
- if (parsed) {
417
- // Power
418
- if (parsed.power !== undefined) {
419
- await this.api.matter.updateAccessoryState(uuidLocal, this.api.matter.clusterNames.OnOff, { onOff: Boolean(parsed.power) })
420
- }
421
-
422
- // Brightness
423
- if (parsed.brightness !== undefined) {
424
- const level = Math.round((Number(parsed.brightness) / 100) * 254)
425
- await this.api.matter.updateAccessoryState(uuidLocal, this.api.matter.clusterNames.LevelControl, { currentLevel: level })
426
- }
427
-
428
- // Color
429
- if (parsed.color !== undefined) {
430
- const { r, g, b } = parsed.color
431
- const [h, s] = rgb2hs(r, g, b)
432
- await this.api.matter.updateAccessoryState(uuidLocal, this.api.matter.clusterNames.ColorControl, { currentHue: Math.round((h / 360) * 254), currentSaturation: Math.round((s / 100) * 254) })
433
- }
434
-
435
- // If we parsed something from serviceData prefer it and return early
436
- if (serviceData) {
437
- return
438
- }
439
- }
440
- } catch (e: any) {
441
- this.log.debug(`BLE advertisement parsing failed for ${dev.deviceId}: ${e?.message ?? e}`)
442
- }
443
-
444
- // Fallback to OpenAPI getDeviceStatus when serviceData is not present or parsing failed
445
- if (!this.switchBotAPI) {
446
- return
447
- }
448
- try {
449
- const { response, statusCode } = await this.switchBotAPI.getDeviceStatus(dev.deviceId, this.config.credentials?.token, this.config.credentials?.secret)
450
- if (!(statusCode === 100 || statusCode === 200)) {
451
- return
452
- }
453
- const respAny: any = response
454
- const body = respAny?.body ?? respAny
455
- const status = body?.status ?? body
456
-
457
- // On/Off
458
- if (status?.power !== undefined) {
459
- const on = (String(status.power).toLowerCase() === 'on' || Number(status.power) === 1)
460
- await this.api.matter.updateAccessoryState(uuidLocal, this.api.matter.clusterNames.OnOff, { onOff: on })
461
- }
462
-
463
- // Brightness
464
- if (status?.brightness !== undefined) {
465
- const level = Math.round((Number(status.brightness) / 100) * 254)
466
- await this.api.matter.updateAccessoryState(uuidLocal, this.api.matter.clusterNames.LevelControl, { currentLevel: level })
467
- }
468
-
469
- // Color
470
- if (status?.color !== undefined) {
471
- const color = String(status.color)
472
- let r = 0
473
- let g = 0
474
- let b = 0
475
- if (color.includes(':')) {
476
- const parts = color.split(':').map(Number)
477
- ;[r, g, b] = parts
478
- } else if (color.startsWith('#')) {
479
- const hex = color.replace('#', '')
480
- r = Number.parseInt(hex.substring(0, 2), 16)
481
- g = Number.parseInt(hex.substring(2, 4), 16)
482
- b = Number.parseInt(hex.substring(4, 6), 16)
483
- }
484
- const [h, s] = rgb2hs(r, g, b)
485
- await this.api.matter.updateAccessoryState(uuidLocal, this.api.matter.clusterNames.ColorControl, { currentHue: Math.round((h / 360) * 254), currentSaturation: Math.round((s / 100) * 254) })
486
- }
487
- } catch (e: any) {
488
- this.log.debug(`BLE push handler failed for ${dev.deviceId}: ${e?.message ?? e}`)
489
- }
490
- }
491
- } catch (e: any) {
492
- this.log.debug(`Failed to register BLE handler for ${dev.deviceId}: ${e?.message ?? e}`)
493
- }
494
-
495
- return instance.toAccessory()
496
- }
497
-
498
- /**
499
- * Discover devices via SwitchBot OpenAPI and cache them for later use
500
- */
501
- private async discoverDevices(): Promise<void> {
502
- if (!this.switchBotAPI) {
503
- this.log.debug('SwitchBot OpenAPI not configured; skipping discovery')
504
- return
505
- }
506
-
507
- try {
508
- const { response, statusCode } = await this.switchBotAPI.getDevices()
509
- this.log.debug(`SwitchBot getDevices response status: ${statusCode}`)
510
- if (statusCode === 100 || statusCode === 200) {
511
- const deviceList = Array.isArray(response?.body?.deviceList) ? response.body.deviceList : []
512
- this.discoveredDevices = deviceList
513
- this.log.info(`Discovered ${deviceList.length} SwitchBot device(s) from OpenAPI`)
514
- for (const d of deviceList) {
515
- this.log.debug(` - ${d.deviceName} (${d.deviceType}) id=${d.deviceId}`)
516
- }
517
- } else {
518
- this.log.warn(`SwitchBot getDevices returned status ${statusCode}`)
519
- }
520
- } catch (e: any) {
521
- this.log.error('Failed to discover SwitchBot devices:', e?.message ?? e)
522
- }
523
- }
524
-
525
- /**
526
- * Retry wrapper for control commands using SwitchBot OpenAPI
527
- */
528
- async retryCommand(deviceObj: device, bodyChange: bodyChange, maxRetries = 1, delayBetweenRetries = 1000): Promise<{ response: any, statusCode: number }> {
529
- let retryCount = 0
530
- while (retryCount < maxRetries) {
531
- try {
532
- if (!this.switchBotAPI) {
533
- throw new Error('SwitchBot OpenAPI not initialized')
534
- }
535
- const { response, statusCode } = await this.switchBotAPI.controlDevice(
536
- deviceObj.deviceId,
537
- bodyChange.command,
538
- bodyChange.parameter,
539
- bodyChange.commandType as import('node-switchbot').commandType | undefined,
540
- this.config.credentials?.token,
541
- this.config.credentials?.secret,
542
- )
543
- return { response, statusCode }
544
- } catch (e: any) {
545
- this.log.debug(`retryCommand error: ${e?.message ?? e}`)
546
- }
547
- retryCount++
548
-
549
- await sleep(delayBetweenRetries)
550
- }
551
- return { response: {}, statusCode: 500 }
552
- }
553
-
554
- /**
555
- * Parse BLE advertisement/serviceData into normalized fields for a given device.
556
- * Returns null when serviceData is falsy or parsing fails.
557
- */
558
- private parseAdvertisementForDevice(dev: device, serviceData?: any) {
559
- if (!serviceData) {
560
- return null
561
- }
562
- try {
563
- const sd = serviceData
564
- const result: any = {}
565
-
566
- // Power/on state - supports multiple field names used by different models
567
- const power = sd.power ?? sd.on ?? sd.p
568
- if (power !== undefined) {
569
- result.power = (String(power).toLowerCase() === 'on' || Number(power) === 1)
570
- }
571
-
572
- // Brightness (0-100)
573
- const brightness = sd.brightness ?? sd.b
574
- if (brightness !== undefined) {
575
- result.brightness = Number(brightness)
576
- }
577
-
578
- // Color - could be 'r:g:b', '#rrggbb' or 'rrggbb'
579
- const color = sd.color ?? sd.rgb ?? sd.c
580
- if (color !== undefined) {
581
- let r = 0
582
- let g = 0
583
- let b = 0
584
- const c = String(color)
585
- if (c.includes(':')) {
586
- const parts = c.split(':').map(Number)
587
- ;[r, g, b] = parts
588
- } else if (c.startsWith('#')) {
589
- const hex = c.replace('#', '')
590
- r = Number.parseInt(hex.substring(0, 2), 16)
591
- g = Number.parseInt(hex.substring(2, 4), 16)
592
- b = Number.parseInt(hex.substring(4, 6), 16)
593
- } else if (/^[0-9a-f]{6}$/i.test(c)) {
594
- r = Number.parseInt(c.substring(0, 2), 16)
595
- g = Number.parseInt(c.substring(2, 4), 16)
596
- b = Number.parseInt(c.substring(4, 6), 16)
597
- }
598
- result.color = { r, g, b }
599
- }
600
-
601
- // Battery (some devices use battery or batt)
602
- const battery = sd.battery ?? sd.batt
603
- if (battery !== undefined) {
604
- result.battery = Number(battery)
605
- }
606
-
607
- return result
608
- } catch (e: any) {
609
- this.log.debug(`parseAdvertisementForDevice failed for ${dev.deviceId}: ${e?.message ?? e}`)
610
- return null
611
- }
612
- }
613
-
614
- /**
615
- * Required for DynamicPlatformPlugin
616
- * Called when homebridge restores cached accessories from disk at startup
617
- */
618
- configureAccessory(/* accessory: PlatformAccessory */) {
619
- // Note this is not used for Matter accessories - use configureMatterAccessory instead
620
- // This plugin does not have any hap accessories, so here we can comment this out
621
- // this.accessories.set(accessory.UUID, accessory)
622
- }
623
-
624
- /**
625
- * Called when homebridge restores cached Matter accessories from disk at startup.
626
- *
627
- * This is where you can access the `accessory.context` object to retrieve
628
- * any custom data you stored when the accessory was originally registered.
629
- */
630
- configureMatterAccessory(accessory: SerializedMatterAccessory) {
631
- this.log.debug('Loading cached Matter accessory:', accessory.displayName)
632
- this.matterAccessories.set(accessory.uuid, accessory)
633
- }
634
-
635
- /**
636
- * Register all Matter accessories
637
- */
638
- private async registerMatterAccessories() {
639
- this.log.info('═'.repeat(80))
640
- this.log.info('Homebridge Matter Plugin')
641
- this.log.info('═'.repeat(80))
642
-
643
- // Remove accessories that are disabled in config
644
- await this.removeDisabledAccessories()
645
-
646
- // If we discovered real SwitchBot devices via OpenAPI, map and register them
647
- if (this.discoveredDevices && this.discoveredDevices.length > 0) {
648
- this.log.info(`Registering ${this.discoveredDevices.length} discovered SwitchBot device(s) as Matter accessories`)
649
- const accessories: Array<MatterAccessory<Record<string, unknown>>> = []
650
- for (const dev of this.discoveredDevices) {
651
- try {
652
- const acc = await this.createAccessoryFromDevice(dev)
653
- if (acc) {
654
- accessories.push(acc)
655
- }
656
- } catch (e: any) {
657
- this.log.error(`Failed to create Matter accessory for ${dev.deviceId}: ${e?.message ?? e}`)
658
- }
659
- }
660
- if (accessories.length > 0) {
661
- this.log.info(`✓ Registered ${accessories.length} discovered device(s)`)
662
- for (const acc of accessories) {
663
- this.log.info(` - ${acc.displayName}`)
664
- }
665
- await this.api.matter.registerPlatformAccessories(PLUGIN_NAME, PLATFORM_NAME, accessories)
666
- return
667
- }
668
- this.log.info('No discovered devices were mapped to Matter accessories; falling back to example sections')
669
- }
670
-
671
- // Register example/demo devices by Matter specification sections
672
- await this.registerSection4Lighting()
673
- await this.registerSection5SmartPlugs()
674
- await this.registerSection6Switches()
675
- await this.registerSection7Sensors()
676
- await this.registerSection8Closure()
677
- await this.registerSection9HVAC()
678
- await this.registerSection12Robotic()
679
- await this.registerCustomDevices()
680
-
681
- this.log.info('═'.repeat(80))
682
- this.log.info('Finished registering Matter accessories')
683
- this.log.info('═'.repeat(80))
684
- }
685
-
686
- /**
687
- * Remove accessories that are disabled in config
688
- */
689
- private async removeDisabledAccessories() {
690
- const configMap = [
691
- { enabled: this.config.enableOnOffLight, uuid: this.api.matter.uuid.generate('matter-onoff-light'), name: 'On/Off Light' },
692
- { enabled: this.config.enableDimmableLight, uuid: this.api.matter.uuid.generate('matter-dimmable-light'), name: 'Dimmable Light' },
693
- { enabled: this.config.enableColourTemperatureLight, uuid: this.api.matter.uuid.generate('matter-colour-temp-light'), name: 'Colour Temperature Light' },
694
- { enabled: this.config.enableColourLight, uuid: this.api.matter.uuid.generate('matter-colour-light'), name: 'Colour Light (HS)' },
695
- { enabled: this.config.enableExtendedColourLight, uuid: this.api.matter.uuid.generate('matter-extended-colour-light'), name: 'Extended Colour Light' },
696
- { enabled: this.config.enableOnOffOutlet, uuid: this.api.matter.uuid.generate('matter-onoff-outlet'), name: 'On/Off Outlet' },
697
- { enabled: this.config.enableOnOffSwitch, uuid: this.api.matter.uuid.generate('matter-onoff-switch'), name: 'On/Off Switch' },
698
- { enabled: this.config.enableTemperatureSensor, uuid: this.api.matter.uuid.generate('matter-temperature-sensor'), name: 'Temperature Sensor' },
699
- { enabled: this.config.enableHumiditySensor, uuid: this.api.matter.uuid.generate('matter-humidity-sensor'), name: 'Humidity Sensor' },
700
- { enabled: this.config.enableLightSensor, uuid: this.api.matter.uuid.generate('matter-light-sensor'), name: 'Light Sensor' },
701
- { enabled: this.config.enableOccupancySensor, uuid: this.api.matter.uuid.generate('matter-occupancy-sensor'), name: 'Occupancy Sensor' },
702
- { enabled: this.config.enableContactSensor, uuid: this.api.matter.uuid.generate('matter-contact-sensor'), name: 'Contact Sensor' },
703
- { enabled: this.config.enableLeakSensor, uuid: this.api.matter.uuid.generate('matter-leak-sensor'), name: 'Leak Sensor' },
704
- { enabled: this.config.enableSmokeSensor, uuid: this.api.matter.uuid.generate('matter-smoke-sensor'), name: 'Smoke Sensor' },
705
- { enabled: this.config.enableDoorLock, uuid: this.api.matter.uuid.generate('matter-door-lock'), name: 'Door Lock' },
706
- { enabled: this.config.enableWindowBlind, uuid: this.api.matter.uuid.generate('matter-window-blind'), name: 'Window Blind' },
707
- { enabled: this.config.enableVenetianBlind, uuid: this.api.matter.uuid.generate('matter-venetian-blind'), name: 'Venetian Blind' },
708
- { enabled: this.config.enableThermostat, uuid: this.api.matter.uuid.generate('matter-thermostat'), name: 'Thermostat' },
709
- { enabled: this.config.enableFan, uuid: this.api.matter.uuid.generate('matter-fan'), name: 'Fan' },
710
- { enabled: this.config.enableRobotVacuum, uuid: this.api.matter.uuid.generate('matter-robot-vacuum'), name: 'Robot Vacuum' },
711
- { enabled: this.config.enablePowerStrip, uuid: this.api.matter.uuid.generate('matter-power-strip'), name: 'Power Strip' },
712
- ]
713
-
714
- for (const { enabled, uuid, name } of configMap) {
715
- if (enabled === false) {
716
- const existingAccessory = this.matterAccessories.get(uuid)
717
- if (existingAccessory) {
718
- this.log.info(`Removing accessory '${name}' (disabled in config)`)
719
- await this.api.matter.unregisterPlatformAccessories(PLUGIN_NAME, PLATFORM_NAME, [existingAccessory as unknown as MatterAccessory])
720
- this.matterAccessories.delete(uuid)
721
- }
722
- }
723
- }
724
- }
725
-
726
- /**
727
- * Section 4: Lighting Devices (Matter Spec § 4)
728
- */
729
- private async registerSection4Lighting() {
730
- this.log.info('═'.repeat(80))
731
- this.log.info('Section 4: Lighting Devices (Matter Spec § 4)')
732
- this.log.info('═'.repeat(80))
733
-
734
- const accessories: Array<MatterAccessory<Record<string, unknown>>> = []
735
-
736
- // On/Off Light
737
- if (this.config.enableOnOffLight !== false) {
738
- const device = new OnOffLightAccessory(this.api, this.log)
739
- accessories.push(device.toAccessory())
740
- }
741
-
742
- // Dimmable Light
743
- if (this.config.enableDimmableLight !== false) {
744
- const device = new DimmableLightAccessory(this.api, this.log)
745
- accessories.push(device.toAccessory())
746
- }
747
-
748
- // Color Temperature Light
749
- if (this.config.enableColourTemperatureLight !== false) {
750
- const device = new ColorTemperatureLightAccessory(this.api, this.log)
751
- accessories.push(device.toAccessory())
752
- }
753
-
754
- // Color Light (HS only)
755
- if (this.config.enableColourLight !== false) {
756
- const device = new ColorLightAccessory(this.api, this.log)
757
- accessories.push(device.toAccessory())
758
- }
759
-
760
- // Extended Color Light (HS+CCT)
761
- if (this.config.enableExtendedColourLight !== false) {
762
- const device = new ExtendedColorLightAccessory(this.api, this.log)
763
- accessories.push(device.toAccessory())
764
- }
765
-
766
- if (accessories.length > 0) {
767
- this.log.info(`✓ Registered ${accessories.length} lighting device(s)`)
768
- for (const acc of accessories) {
769
- this.log.info(` - ${acc.displayName}`)
770
- }
771
- await this.api.matter.registerPlatformAccessories(PLUGIN_NAME, PLATFORM_NAME, accessories)
772
- }
773
- }
774
-
775
- /**
776
- * Section 5: Smart Plugs/Actuators (Matter Spec § 5)
777
- */
778
- private async registerSection5SmartPlugs() {
779
- this.log.info('═'.repeat(80))
780
- this.log.info('Section 5: Smart Plugs/Actuators (Matter Spec § 5)')
781
- this.log.info('═'.repeat(80))
782
-
783
- const accessories: Array<MatterAccessory<Record<string, unknown>>> = []
784
-
785
- // On/Off Outlet
786
- if (this.config.enableOnOffOutlet !== false) {
787
- const device = new OnOffOutletAccessory(this.api, this.log)
788
- accessories.push(device.toAccessory())
789
- }
790
-
791
- if (accessories.length > 0) {
792
- this.log.info(`✓ Registered ${accessories.length} smart plug/actuator device(s)`)
793
- for (const acc of accessories) {
794
- this.log.info(` - ${acc.displayName}`)
795
- }
796
- await this.api.matter.registerPlatformAccessories(PLUGIN_NAME, PLATFORM_NAME, accessories)
797
- }
798
- }
799
-
800
- /**
801
- * Section 6: Switches & Controllers (Matter Spec § 6)
802
- */
803
- private async registerSection6Switches() {
804
- this.log.info('═'.repeat(80))
805
- this.log.info('Section 6: Switches & Controllers (Matter Spec § 6)')
806
- this.log.info('═'.repeat(80))
807
-
808
- const accessories: Array<MatterAccessory<Record<string, unknown>>> = []
809
-
810
- // On/Off Switch
811
- if (this.config.enableOnOffSwitch !== false) {
812
- const device = new OnOffSwitchAccessory(this.api, this.log)
813
- accessories.push(device.toAccessory())
814
- }
815
-
816
- if (accessories.length > 0) {
817
- this.log.info(`✓ Registered ${accessories.length} switch/controller device(s)`)
818
- for (const acc of accessories) {
819
- this.log.info(` - ${acc.displayName}`)
820
- }
821
- await this.api.matter.registerPlatformAccessories(PLUGIN_NAME, PLATFORM_NAME, accessories)
822
- }
823
- }
824
-
825
- /**
826
- * Section 7: Sensors (Matter Spec § 7)
827
- */
828
- private async registerSection7Sensors() {
829
- this.log.info('═'.repeat(80))
830
- this.log.info('Section 7: Sensors (Matter Spec § 7)')
831
- this.log.info('═'.repeat(80))
832
-
833
- const accessories: Array<MatterAccessory<Record<string, unknown>>> = []
834
-
835
- // Contact Sensor
836
- if (this.config.enableContactSensor !== false) {
837
- const device = new ContactSensorAccessory(this.api, this.log)
838
- accessories.push(device.toAccessory())
839
- }
840
-
841
- // Light Sensor
842
- if (this.config.enableLightSensor !== false) {
843
- const device = new LightSensorAccessory(this.api, this.log)
844
- accessories.push(device.toAccessory())
845
- }
846
-
847
- // Occupancy Sensor
848
- if (this.config.enableOccupancySensor !== false) {
849
- const device = new OccupancySensorAccessory(this.api, this.log)
850
- accessories.push(device.toAccessory())
851
- }
852
-
853
- // Temperature Sensor
854
- if (this.config.enableTemperatureSensor !== false) {
855
- const device = new TemperatureSensorAccessory(this.api, this.log)
856
- accessories.push(device.toAccessory())
857
- }
858
-
859
- // Humidity Sensor
860
- if (this.config.enableHumiditySensor !== false) {
861
- const device = new HumiditySensorAccessory(this.api, this.log)
862
- accessories.push(device.toAccessory())
863
- }
864
-
865
- // Smoke/CO Alarm
866
- if (this.config.enableSmokeSensor !== false) {
867
- const device = new SmokeCOAlarmAccessory(this.api, this.log)
868
- accessories.push(device.toAccessory())
869
- }
870
-
871
- // Leak Sensor
872
- if (this.config.enableLeakSensor !== false) {
873
- const device = new LeakSensorAccessory(this.api, this.log)
874
- accessories.push(device.toAccessory())
875
- }
876
-
877
- if (accessories.length > 0) {
878
- this.log.info(`✓ Registered ${accessories.length} sensor device(s)`)
879
- for (const acc of accessories) {
880
- this.log.info(` - ${acc.displayName}`)
881
- }
882
- await this.api.matter.registerPlatformAccessories(PLUGIN_NAME, PLATFORM_NAME, accessories)
883
- }
884
- }
885
-
886
- /**
887
- * Section 8: Closure Devices (Matter Spec § 8)
888
- */
889
- private async registerSection8Closure() {
890
- this.log.info('═'.repeat(80))
891
- this.log.info('Section 8: Closure Devices (Matter Spec § 8)')
892
- this.log.info('═'.repeat(80))
893
-
894
- const accessories: Array<MatterAccessory<Record<string, unknown>>> = []
895
-
896
- // Door Lock
897
- if (this.config.enableDoorLock !== false) {
898
- const device = new DoorLockAccessory(this.api, this.log)
899
- accessories.push(device.toAccessory())
900
- }
901
-
902
- // Window Blind
903
- if (this.config.enableWindowBlind !== false) {
904
- const device = new WindowBlindAccessory(this.api, this.log)
905
- accessories.push(device.toAccessory())
906
- }
907
-
908
- // Venetian Blind
909
- if (this.config.enableVenetianBlind !== false) {
910
- const device = new VenetianBlindAccessory(this.api, this.log)
911
- accessories.push(device.toAccessory())
912
- }
913
-
914
- if (accessories.length > 0) {
915
- this.log.info(`✓ Registered ${accessories.length} closure device(s)`)
916
- for (const acc of accessories) {
917
- this.log.info(` - ${acc.displayName}`)
918
- }
919
- await this.api.matter.registerPlatformAccessories(PLUGIN_NAME, PLATFORM_NAME, accessories)
920
- }
921
- }
922
-
923
- /**
924
- * Section 9: HVAC (Matter Spec § 9)
925
- */
926
- private async registerSection9HVAC() {
927
- this.log.info('═'.repeat(80))
928
- this.log.info('Section 9: HVAC (Matter Spec § 9)')
929
- this.log.info('═'.repeat(80))
930
-
931
- const accessories: Array<MatterAccessory<Record<string, unknown>>> = []
932
-
933
- // Thermostat
934
- if (this.config.enableThermostat !== false) {
935
- const device = new ThermostatAccessory(this.api, this.log)
936
- accessories.push(device.toAccessory())
937
- }
938
-
939
- // Fan
940
- if (this.config.enableFan !== false) {
941
- const device = new FanAccessory(this.api, this.log)
942
- accessories.push(device.toAccessory())
943
- }
944
-
945
- if (accessories.length > 0) {
946
- this.log.info(`✓ Registered ${accessories.length} HVAC device(s)`)
947
- for (const acc of accessories) {
948
- this.log.info(` - ${acc.displayName}`)
949
- }
950
- await this.api.matter.registerPlatformAccessories(PLUGIN_NAME, PLATFORM_NAME, accessories)
951
- }
952
- }
953
-
954
- /**
955
- * Section 12: Robotic Devices (Matter Spec § 12)
956
- * ⚠️ IMPORTANT: RVC devices use a DIFFERENT PROCESS (same code) than other devices!
957
- * When this runs, you'll see separate commissioning codes in the logs for the robot vacuum.
958
- * Use those codes to pair the vacuum as a separate bridge in your Home app.
959
- */
960
- private async registerSection12Robotic() {
961
- this.log.info('═'.repeat(80))
962
- this.log.info('Section 12: Robotic Devices (Matter Spec § 12)')
963
- this.log.info('═'.repeat(80))
964
-
965
- const accessories: Array<MatterAccessory<Record<string, unknown>>> = []
966
-
967
- // Robot Vacuum
968
- if (this.config.enableRobotVacuum !== false) {
969
- const device = new RoboticVacuumAccessory(this.api, this.log)
970
- accessories.push(device.toAccessory())
971
- }
972
-
973
- if (accessories.length > 0) {
974
- this.log.info(`✓ Registered ${accessories.length} robot vacuum device(s)`)
975
- for (const acc of accessories) {
976
- this.log.info(` - ${acc.displayName} (standalone for Apple Home compatibility)`)
977
- }
978
- await this.api.matter.registerPlatformAccessories(PLUGIN_NAME, PLATFORM_NAME, accessories)
979
- }
980
- }
981
-
982
- /**
983
- * Custom Devices
984
- *
985
- * This section demonstrates custom device implementations that go beyond
986
- * the standard Matter device types. These examples show advanced patterns
987
- * like managing multiple logical components within a single device.
988
- */
989
- private async registerCustomDevices() {
990
- this.log.info('═'.repeat(80))
991
- this.log.info('Custom Devices')
992
- this.log.info('═'.repeat(80))
993
-
994
- const accessories: Array<MatterAccessory<Record<string, unknown>>> = []
995
-
996
- // Power Strip (4 Outlets)
997
- if (this.config.enablePowerStrip !== false) {
998
- const device = new PowerStripAccessory(this.api, this.log)
999
- accessories.push(device.toAccessory())
1000
- }
1001
-
1002
- if (accessories.length > 0) {
1003
- this.log.info(`✓ Registered ${accessories.length} custom device(s)`)
1004
- for (const acc of accessories) {
1005
- this.log.info(` - ${acc.displayName}`)
1006
- }
1007
- await this.api.matter.registerPlatformAccessories(PLUGIN_NAME, PLATFORM_NAME, accessories)
1008
- }
1009
- }
1010
- }