@switchbot/homebridge-switchbot 5.0.0-beta.1 → 5.0.0-beta.100

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 (448) hide show
  1. package/.github/ISSUE_TEMPLATE/e2e-verification.md +36 -0
  2. package/.github/workflows/ci.yml +32 -0
  3. package/.github/workflows/manual-e2e.yml +115 -0
  4. package/.github/workflows/release.yml +0 -4
  5. package/CHANGELOG.md +35 -0
  6. package/E2E-VERIFICATION.md +121 -0
  7. package/MIGRATION.md +44 -0
  8. package/README.md +56 -3
  9. package/config.schema.json +91 -14787
  10. package/dist/deviceFactory.d.ts +13 -0
  11. package/dist/deviceFactory.d.ts.map +1 -0
  12. package/dist/deviceFactory.js +81 -0
  13. package/dist/deviceFactory.js.map +1 -0
  14. package/dist/devices/deviceBase.d.ts +50 -0
  15. package/dist/devices/deviceBase.d.ts.map +1 -0
  16. package/dist/devices/deviceBase.js +119 -0
  17. package/dist/devices/deviceBase.js.map +1 -0
  18. package/dist/devices/genericDevice.d.ts +298 -0
  19. package/dist/devices/genericDevice.d.ts.map +1 -0
  20. package/dist/devices/genericDevice.js +1065 -0
  21. package/dist/devices/genericDevice.js.map +1 -0
  22. package/dist/homebridge-ui/public/index.html +636 -246
  23. package/dist/homebridge-ui/server.d.ts +3 -1
  24. package/dist/homebridge-ui/server.d.ts.map +1 -1
  25. package/dist/homebridge-ui/server.js +467 -36
  26. package/dist/homebridge-ui/server.js.map +1 -1
  27. package/dist/index.d.ts.map +1 -1
  28. package/dist/index.js +4 -7
  29. package/dist/index.js.map +1 -1
  30. package/dist/platform.d.ts +35 -0
  31. package/dist/platform.d.ts.map +1 -0
  32. package/dist/platform.js +1562 -0
  33. package/dist/platform.js.map +1 -0
  34. package/dist/settings.d.ts +10 -249
  35. package/dist/settings.d.ts.map +1 -1
  36. package/dist/settings.js +5 -30
  37. package/dist/settings.js.map +1 -1
  38. package/dist/switchbotClient.d.ts +32 -0
  39. package/dist/switchbotClient.d.ts.map +1 -0
  40. package/dist/switchbotClient.js +194 -0
  41. package/dist/switchbotClient.js.map +1 -0
  42. package/dist/utils.d.ts +39 -50
  43. package/dist/utils.d.ts.map +1 -1
  44. package/dist/utils.js +39 -688
  45. package/dist/utils.js.map +1 -1
  46. package/docs/assets/highlight.css +14 -0
  47. package/docs/assets/icons.js +1 -1
  48. package/docs/assets/icons.svg +1 -1
  49. package/docs/assets/main.js +2 -2
  50. package/docs/assets/style.css +3 -3
  51. package/docs/index.html +77 -13
  52. package/docs/variables/default.html +1 -1
  53. package/eslint.config.js +2 -8
  54. package/package.json +21 -28
  55. package/scripts/e2e/README.md +25 -0
  56. package/scripts/e2e/curtain-e2e.sh +70 -0
  57. package/scripts/e2e/fan-e2e.sh +75 -0
  58. package/scripts/e2e/light-advanced-e2e.sh +97 -0
  59. package/scripts/e2e/light-e2e.sh +75 -0
  60. package/scripts/e2e/list-accessories.sh +19 -0
  61. package/scripts/e2e/lock-e2e.sh +65 -0
  62. package/scripts/generate-matter-maps.js +60 -0
  63. package/scripts/run-e2e-local.sh +14 -0
  64. package/src/deviceFactory.ts +122 -0
  65. package/src/devices/deviceBase.ts +141 -0
  66. package/src/devices/genericDevice.ts +995 -0
  67. package/src/homebridge-ui/public/index.html +636 -246
  68. package/src/homebridge-ui/server.ts +552 -41
  69. package/src/index.ts +4 -7
  70. package/src/platform.ts +1561 -0
  71. package/src/settings.ts +12 -277
  72. package/src/switchbotClient.ts +203 -0
  73. package/src/utils.ts +45 -713
  74. package/test/accessory-restore.spec.ts +73 -0
  75. package/test/device-mapping.spec.ts +37 -0
  76. package/test/deviceFactory.spec.ts +18 -0
  77. package/test/e2e/run-e2e.spec.ts +50 -0
  78. package/test/fan-swing.spec.ts +29 -0
  79. package/test/helpers/matter-harness.ts +53 -0
  80. package/test/lock-users.spec.ts +44 -0
  81. package/test/matter-childbridge.spec.ts +55 -0
  82. package/test/matter-descriptors.spec.ts +97 -0
  83. package/test/matter-device-state.spec.ts +101 -0
  84. package/test/matter-integration.spec.ts +70 -0
  85. package/test/platform.integration.spec.ts +55 -0
  86. package/test/switchbot-client-debounce.spec.ts +131 -0
  87. package/test/switchbot-client-openapi.spec.ts +56 -0
  88. package/test/switchbotClient.spec.ts +10 -0
  89. package/test/utils.spec.ts +20 -0
  90. package/vitest.config.ts +7 -0
  91. package/coverage/base.css +0 -224
  92. package/coverage/block-navigation.js +0 -87
  93. package/coverage/clover.xml +0 -15847
  94. package/coverage/coverage-final.json +0 -42
  95. package/coverage/docs/assets/dmt/dmt-component-data.js.html +0 -85
  96. package/coverage/docs/assets/dmt/dmt-components.js.html +0 -286
  97. package/coverage/docs/assets/dmt/index.html +0 -131
  98. package/coverage/docs/assets/hierarchy.js.html +0 -85
  99. package/coverage/docs/assets/icons.js.html +0 -136
  100. package/coverage/docs/assets/index.html +0 -146
  101. package/coverage/docs/assets/main.js.html +0 -265
  102. package/coverage/favicon.png +0 -0
  103. package/coverage/index.html +0 -191
  104. package/coverage/prettify.css +0 -1
  105. package/coverage/prettify.js +0 -2
  106. package/coverage/sort-arrow-sprite.png +0 -0
  107. package/coverage/sorter.js +0 -196
  108. package/coverage/src/device/blindtilt.ts.html +0 -3238
  109. package/coverage/src/device/bot.ts.html +0 -2803
  110. package/coverage/src/device/ceilinglight.ts.html +0 -2338
  111. package/coverage/src/device/colorbulb.ts.html +0 -2824
  112. package/coverage/src/device/contact.ts.html +0 -1465
  113. package/coverage/src/device/curtain.ts.html +0 -2869
  114. package/coverage/src/device/device.ts.html +0 -2500
  115. package/coverage/src/device/fan.ts.html +0 -2242
  116. package/coverage/src/device/hub.ts.html +0 -1408
  117. package/coverage/src/device/humidifier.ts.html +0 -2116
  118. package/coverage/src/device/index.html +0 -416
  119. package/coverage/src/device/iosensor.ts.html +0 -1375
  120. package/coverage/src/device/lightstrip.ts.html +0 -2617
  121. package/coverage/src/device/lock.ts.html +0 -1963
  122. package/coverage/src/device/meter.ts.html +0 -1372
  123. package/coverage/src/device/meterplus.ts.html +0 -1384
  124. package/coverage/src/device/meterpro.ts.html +0 -1618
  125. package/coverage/src/device/motion.ts.html +0 -1264
  126. package/coverage/src/device/plug.ts.html +0 -1372
  127. package/coverage/src/device/relayswitch.ts.html +0 -2284
  128. package/coverage/src/device/robotvacuumcleaner.ts.html +0 -1810
  129. package/coverage/src/device/waterdetector.ts.html +0 -1294
  130. package/coverage/src/homebridge-ui/index.html +0 -116
  131. package/coverage/src/homebridge-ui/server.ts.html +0 -229
  132. package/coverage/src/index.html +0 -161
  133. package/coverage/src/index.ts.html +0 -124
  134. package/coverage/src/irdevice/airconditioner.ts.html +0 -1687
  135. package/coverage/src/irdevice/airpurifier.ts.html +0 -844
  136. package/coverage/src/irdevice/camera.ts.html +0 -475
  137. package/coverage/src/irdevice/fan.ts.html +0 -766
  138. package/coverage/src/irdevice/index.html +0 -251
  139. package/coverage/src/irdevice/irdevice.ts.html +0 -1117
  140. package/coverage/src/irdevice/light.ts.html +0 -826
  141. package/coverage/src/irdevice/other.ts.html +0 -2458
  142. package/coverage/src/irdevice/tv.ts.html +0 -1222
  143. package/coverage/src/irdevice/vacuumcleaner.ts.html +0 -466
  144. package/coverage/src/irdevice/waterheater.ts.html +0 -469
  145. package/coverage/src/platform.ts.html +0 -8776
  146. package/coverage/src/settings.ts.html +0 -934
  147. package/coverage/src/utils.ts.html +0 -2092
  148. package/dist/devices-hap/airpurifier.d.ts +0 -54
  149. package/dist/devices-hap/airpurifier.d.ts.map +0 -1
  150. package/dist/devices-hap/airpurifier.js +0 -527
  151. package/dist/devices-hap/airpurifier.js.map +0 -1
  152. package/dist/devices-hap/blindtilt.d.ts +0 -90
  153. package/dist/devices-hap/blindtilt.d.ts.map +0 -1
  154. package/dist/devices-hap/blindtilt.js +0 -974
  155. package/dist/devices-hap/blindtilt.js.map +0 -1
  156. package/dist/devices-hap/bot.d.ts +0 -102
  157. package/dist/devices-hap/bot.d.ts.map +0 -1
  158. package/dist/devices-hap/bot.js +0 -811
  159. package/dist/devices-hap/bot.js.map +0 -1
  160. package/dist/devices-hap/ceilinglight.d.ts +0 -85
  161. package/dist/devices-hap/ceilinglight.d.ts.map +0 -1
  162. package/dist/devices-hap/ceilinglight.js +0 -701
  163. package/dist/devices-hap/ceilinglight.js.map +0 -1
  164. package/dist/devices-hap/colorbulb.d.ts +0 -88
  165. package/dist/devices-hap/colorbulb.d.ts.map +0 -1
  166. package/dist/devices-hap/colorbulb.js +0 -881
  167. package/dist/devices-hap/colorbulb.js.map +0 -1
  168. package/dist/devices-hap/contact.d.ts +0 -44
  169. package/dist/devices-hap/contact.d.ts.map +0 -1
  170. package/dist/devices-hap/contact.js +0 -409
  171. package/dist/devices-hap/contact.js.map +0 -1
  172. package/dist/devices-hap/curtain.d.ts +0 -73
  173. package/dist/devices-hap/curtain.d.ts.map +0 -1
  174. package/dist/devices-hap/curtain.js +0 -869
  175. package/dist/devices-hap/curtain.js.map +0 -1
  176. package/dist/devices-hap/device.d.ts +0 -98
  177. package/dist/devices-hap/device.d.ts.map +0 -1
  178. package/dist/devices-hap/device.js +0 -749
  179. package/dist/devices-hap/device.js.map +0 -1
  180. package/dist/devices-hap/fan.d.ts +0 -69
  181. package/dist/devices-hap/fan.d.ts.map +0 -1
  182. package/dist/devices-hap/fan.js +0 -649
  183. package/dist/devices-hap/fan.js.map +0 -1
  184. package/dist/devices-hap/hub.d.ts +0 -37
  185. package/dist/devices-hap/hub.d.ts.map +0 -1
  186. package/dist/devices-hap/hub.js +0 -392
  187. package/dist/devices-hap/hub.js.map +0 -1
  188. package/dist/devices-hap/humidifier.d.ts +0 -68
  189. package/dist/devices-hap/humidifier.d.ts.map +0 -1
  190. package/dist/devices-hap/humidifier.js +0 -628
  191. package/dist/devices-hap/humidifier.js.map +0 -1
  192. package/dist/devices-hap/iosensor.d.ts +0 -42
  193. package/dist/devices-hap/iosensor.d.ts.map +0 -1
  194. package/dist/devices-hap/iosensor.js +0 -382
  195. package/dist/devices-hap/iosensor.js.map +0 -1
  196. package/dist/devices-hap/lightstrip.d.ts +0 -79
  197. package/dist/devices-hap/lightstrip.d.ts.map +0 -1
  198. package/dist/devices-hap/lightstrip.js +0 -797
  199. package/dist/devices-hap/lightstrip.js.map +0 -1
  200. package/dist/devices-hap/lock.d.ts +0 -53
  201. package/dist/devices-hap/lock.d.ts.map +0 -1
  202. package/dist/devices-hap/lock.js +0 -561
  203. package/dist/devices-hap/lock.js.map +0 -1
  204. package/dist/devices-hap/meter.d.ts +0 -37
  205. package/dist/devices-hap/meter.d.ts.map +0 -1
  206. package/dist/devices-hap/meter.js +0 -379
  207. package/dist/devices-hap/meter.js.map +0 -1
  208. package/dist/devices-hap/meterplus.d.ts +0 -42
  209. package/dist/devices-hap/meterplus.d.ts.map +0 -1
  210. package/dist/devices-hap/meterplus.js +0 -384
  211. package/dist/devices-hap/meterplus.js.map +0 -1
  212. package/dist/devices-hap/meterpro.d.ts +0 -43
  213. package/dist/devices-hap/meterpro.d.ts.map +0 -1
  214. package/dist/devices-hap/meterpro.js +0 -468
  215. package/dist/devices-hap/meterpro.js.map +0 -1
  216. package/dist/devices-hap/motion.d.ts +0 -42
  217. package/dist/devices-hap/motion.d.ts.map +0 -1
  218. package/dist/devices-hap/motion.js +0 -345
  219. package/dist/devices-hap/motion.js.map +0 -1
  220. package/dist/devices-hap/plug.d.ts +0 -49
  221. package/dist/devices-hap/plug.d.ts.map +0 -1
  222. package/dist/devices-hap/plug.js +0 -395
  223. package/dist/devices-hap/plug.js.map +0 -1
  224. package/dist/devices-hap/relayswitch.d.ts +0 -96
  225. package/dist/devices-hap/relayswitch.d.ts.map +0 -1
  226. package/dist/devices-hap/relayswitch.js +0 -642
  227. package/dist/devices-hap/relayswitch.js.map +0 -1
  228. package/dist/devices-hap/robotvacuumcleaner.d.ts +0 -54
  229. package/dist/devices-hap/robotvacuumcleaner.d.ts.map +0 -1
  230. package/dist/devices-hap/robotvacuumcleaner.js +0 -523
  231. package/dist/devices-hap/robotvacuumcleaner.js.map +0 -1
  232. package/dist/devices-hap/waterdetector.d.ts +0 -41
  233. package/dist/devices-hap/waterdetector.d.ts.map +0 -1
  234. package/dist/devices-hap/waterdetector.js +0 -356
  235. package/dist/devices-hap/waterdetector.js.map +0 -1
  236. package/dist/devices-matter/BaseMatterAccessory.d.ts +0 -63
  237. package/dist/devices-matter/BaseMatterAccessory.d.ts.map +0 -1
  238. package/dist/devices-matter/BaseMatterAccessory.js +0 -100
  239. package/dist/devices-matter/BaseMatterAccessory.js.map +0 -1
  240. package/dist/devices-matter/ColorLightAccessory.d.ts +0 -18
  241. package/dist/devices-matter/ColorLightAccessory.d.ts.map +0 -1
  242. package/dist/devices-matter/ColorLightAccessory.js +0 -96
  243. package/dist/devices-matter/ColorLightAccessory.js.map +0 -1
  244. package/dist/devices-matter/ColorTemperatureLightAccessory.d.ts +0 -16
  245. package/dist/devices-matter/ColorTemperatureLightAccessory.d.ts.map +0 -1
  246. package/dist/devices-matter/ColorTemperatureLightAccessory.js +0 -83
  247. package/dist/devices-matter/ColorTemperatureLightAccessory.js.map +0 -1
  248. package/dist/devices-matter/ContactSensorAccessory.d.ts +0 -10
  249. package/dist/devices-matter/ContactSensorAccessory.d.ts.map +0 -1
  250. package/dist/devices-matter/ContactSensorAccessory.js +0 -31
  251. package/dist/devices-matter/ContactSensorAccessory.js.map +0 -1
  252. package/dist/devices-matter/DimmableLightAccessory.d.ts +0 -56
  253. package/dist/devices-matter/DimmableLightAccessory.d.ts.map +0 -1
  254. package/dist/devices-matter/DimmableLightAccessory.js +0 -170
  255. package/dist/devices-matter/DimmableLightAccessory.js.map +0 -1
  256. package/dist/devices-matter/DoorLockAccessory.d.ts +0 -12
  257. package/dist/devices-matter/DoorLockAccessory.d.ts.map +0 -1
  258. package/dist/devices-matter/DoorLockAccessory.js +0 -47
  259. package/dist/devices-matter/DoorLockAccessory.js.map +0 -1
  260. package/dist/devices-matter/ExtendedColorLightAccessory.d.ts +0 -19
  261. package/dist/devices-matter/ExtendedColorLightAccessory.d.ts.map +0 -1
  262. package/dist/devices-matter/ExtendedColorLightAccessory.js +0 -108
  263. package/dist/devices-matter/ExtendedColorLightAccessory.js.map +0 -1
  264. package/dist/devices-matter/FanAccessory.d.ts +0 -14
  265. package/dist/devices-matter/FanAccessory.d.ts.map +0 -1
  266. package/dist/devices-matter/FanAccessory.js +0 -73
  267. package/dist/devices-matter/FanAccessory.js.map +0 -1
  268. package/dist/devices-matter/HumiditySensorAccessory.d.ts +0 -10
  269. package/dist/devices-matter/HumiditySensorAccessory.d.ts.map +0 -1
  270. package/dist/devices-matter/HumiditySensorAccessory.js +0 -33
  271. package/dist/devices-matter/HumiditySensorAccessory.js.map +0 -1
  272. package/dist/devices-matter/LeakSensorAccessory.d.ts +0 -10
  273. package/dist/devices-matter/LeakSensorAccessory.d.ts.map +0 -1
  274. package/dist/devices-matter/LeakSensorAccessory.js +0 -30
  275. package/dist/devices-matter/LeakSensorAccessory.js.map +0 -1
  276. package/dist/devices-matter/LightSensorAccessory.d.ts +0 -10
  277. package/dist/devices-matter/LightSensorAccessory.d.ts.map +0 -1
  278. package/dist/devices-matter/LightSensorAccessory.js +0 -33
  279. package/dist/devices-matter/LightSensorAccessory.js.map +0 -1
  280. package/dist/devices-matter/OccupancySensorAccessory.d.ts +0 -10
  281. package/dist/devices-matter/OccupancySensorAccessory.d.ts.map +0 -1
  282. package/dist/devices-matter/OccupancySensorAccessory.js +0 -43
  283. package/dist/devices-matter/OccupancySensorAccessory.js.map +0 -1
  284. package/dist/devices-matter/OnOffLightAccessory.d.ts +0 -36
  285. package/dist/devices-matter/OnOffLightAccessory.d.ts.map +0 -1
  286. package/dist/devices-matter/OnOffLightAccessory.js +0 -117
  287. package/dist/devices-matter/OnOffLightAccessory.js.map +0 -1
  288. package/dist/devices-matter/OnOffOutletAccessory.d.ts +0 -12
  289. package/dist/devices-matter/OnOffOutletAccessory.d.ts.map +0 -1
  290. package/dist/devices-matter/OnOffOutletAccessory.js +0 -43
  291. package/dist/devices-matter/OnOffOutletAccessory.js.map +0 -1
  292. package/dist/devices-matter/OnOffSwitchAccessory.d.ts +0 -12
  293. package/dist/devices-matter/OnOffSwitchAccessory.d.ts.map +0 -1
  294. package/dist/devices-matter/OnOffSwitchAccessory.js +0 -43
  295. package/dist/devices-matter/OnOffSwitchAccessory.js.map +0 -1
  296. package/dist/devices-matter/RoboticVacuumAccessory.d.ts +0 -66
  297. package/dist/devices-matter/RoboticVacuumAccessory.d.ts.map +0 -1
  298. package/dist/devices-matter/RoboticVacuumAccessory.js +0 -402
  299. package/dist/devices-matter/RoboticVacuumAccessory.js.map +0 -1
  300. package/dist/devices-matter/SmokeCOAlarmAccessory.d.ts +0 -11
  301. package/dist/devices-matter/SmokeCOAlarmAccessory.d.ts.map +0 -1
  302. package/dist/devices-matter/SmokeCOAlarmAccessory.js +0 -49
  303. package/dist/devices-matter/SmokeCOAlarmAccessory.js.map +0 -1
  304. package/dist/devices-matter/TemperatureSensorAccessory.d.ts +0 -10
  305. package/dist/devices-matter/TemperatureSensorAccessory.d.ts.map +0 -1
  306. package/dist/devices-matter/TemperatureSensorAccessory.js +0 -33
  307. package/dist/devices-matter/TemperatureSensorAccessory.js.map +0 -1
  308. package/dist/devices-matter/ThermostatAccessory.d.ts +0 -17
  309. package/dist/devices-matter/ThermostatAccessory.d.ts.map +0 -1
  310. package/dist/devices-matter/ThermostatAccessory.js +0 -87
  311. package/dist/devices-matter/ThermostatAccessory.js.map +0 -1
  312. package/dist/devices-matter/VenetianBlindAccessory.d.ts +0 -17
  313. package/dist/devices-matter/VenetianBlindAccessory.d.ts.map +0 -1
  314. package/dist/devices-matter/VenetianBlindAccessory.js +0 -100
  315. package/dist/devices-matter/VenetianBlindAccessory.js.map +0 -1
  316. package/dist/devices-matter/WindowBlindAccessory.d.ts +0 -15
  317. package/dist/devices-matter/WindowBlindAccessory.d.ts.map +0 -1
  318. package/dist/devices-matter/WindowBlindAccessory.js +0 -81
  319. package/dist/devices-matter/WindowBlindAccessory.js.map +0 -1
  320. package/dist/devices-matter/custom/PowerStripAccessory.d.ts +0 -97
  321. package/dist/devices-matter/custom/PowerStripAccessory.d.ts.map +0 -1
  322. package/dist/devices-matter/custom/PowerStripAccessory.js +0 -265
  323. package/dist/devices-matter/custom/PowerStripAccessory.js.map +0 -1
  324. package/dist/devices-matter/custom/index.d.ts +0 -8
  325. package/dist/devices-matter/custom/index.d.ts.map +0 -1
  326. package/dist/devices-matter/custom/index.js +0 -8
  327. package/dist/devices-matter/custom/index.js.map +0 -1
  328. package/dist/devices-matter/index.d.ts +0 -29
  329. package/dist/devices-matter/index.d.ts.map +0 -1
  330. package/dist/devices-matter/index.js +0 -28
  331. package/dist/devices-matter/index.js.map +0 -1
  332. package/dist/index.test.d.ts +0 -2
  333. package/dist/index.test.d.ts.map +0 -1
  334. package/dist/index.test.js +0 -14
  335. package/dist/index.test.js.map +0 -1
  336. package/dist/irdevice/airconditioner.d.ts +0 -61
  337. package/dist/irdevice/airconditioner.d.ts.map +0 -1
  338. package/dist/irdevice/airconditioner.js +0 -472
  339. package/dist/irdevice/airconditioner.js.map +0 -1
  340. package/dist/irdevice/airpurifier.d.ts +0 -50
  341. package/dist/irdevice/airpurifier.d.ts.map +0 -1
  342. package/dist/irdevice/airpurifier.js +0 -213
  343. package/dist/irdevice/airpurifier.js.map +0 -1
  344. package/dist/irdevice/camera.d.ts +0 -32
  345. package/dist/irdevice/camera.d.ts.map +0 -1
  346. package/dist/irdevice/camera.js +0 -107
  347. package/dist/irdevice/camera.js.map +0 -1
  348. package/dist/irdevice/fan.d.ts +0 -36
  349. package/dist/irdevice/fan.d.ts.map +0 -1
  350. package/dist/irdevice/fan.js +0 -200
  351. package/dist/irdevice/fan.js.map +0 -1
  352. package/dist/irdevice/irdevice.d.ts +0 -68
  353. package/dist/irdevice/irdevice.d.ts.map +0 -1
  354. package/dist/irdevice/irdevice.js +0 -298
  355. package/dist/irdevice/irdevice.js.map +0 -1
  356. package/dist/irdevice/light.d.ts +0 -36
  357. package/dist/irdevice/light.d.ts.map +0 -1
  358. package/dist/irdevice/light.js +0 -206
  359. package/dist/irdevice/light.js.map +0 -1
  360. package/dist/irdevice/other.d.ts +0 -57
  361. package/dist/irdevice/other.d.ts.map +0 -1
  362. package/dist/irdevice/other.js +0 -778
  363. package/dist/irdevice/other.js.map +0 -1
  364. package/dist/irdevice/tv.d.ts +0 -45
  365. package/dist/irdevice/tv.d.ts.map +0 -1
  366. package/dist/irdevice/tv.js +0 -327
  367. package/dist/irdevice/tv.js.map +0 -1
  368. package/dist/irdevice/vacuumcleaner.d.ts +0 -28
  369. package/dist/irdevice/vacuumcleaner.d.ts.map +0 -1
  370. package/dist/irdevice/vacuumcleaner.js +0 -104
  371. package/dist/irdevice/vacuumcleaner.js.map +0 -1
  372. package/dist/irdevice/waterheater.d.ts +0 -30
  373. package/dist/irdevice/waterheater.d.ts.map +0 -1
  374. package/dist/irdevice/waterheater.js +0 -105
  375. package/dist/irdevice/waterheater.js.map +0 -1
  376. package/dist/platform-hap.d.ts +0 -149
  377. package/dist/platform-hap.d.ts.map +0 -1
  378. package/dist/platform-hap.js +0 -2849
  379. package/dist/platform-hap.js.map +0 -1
  380. package/dist/platform-matter.d.ts +0 -75
  381. package/dist/platform-matter.d.ts.map +0 -1
  382. package/dist/platform-matter.js +0 -379
  383. package/dist/platform-matter.js.map +0 -1
  384. package/dist/verifyconfig.test.d.ts +0 -2
  385. package/dist/verifyconfig.test.d.ts.map +0 -1
  386. package/dist/verifyconfig.test.js +0 -167
  387. package/dist/verifyconfig.test.js.map +0 -1
  388. package/src/custom.d.ts +0 -7
  389. package/src/devices-hap/airpurifier.ts +0 -563
  390. package/src/devices-hap/blindtilt.ts +0 -1049
  391. package/src/devices-hap/bot.ts +0 -900
  392. package/src/devices-hap/ceilinglight.ts +0 -742
  393. package/src/devices-hap/colorbulb.ts +0 -904
  394. package/src/devices-hap/contact.ts +0 -457
  395. package/src/devices-hap/curtain.ts +0 -944
  396. package/src/devices-hap/device.ts +0 -811
  397. package/src/devices-hap/fan.ts +0 -711
  398. package/src/devices-hap/hub.ts +0 -439
  399. package/src/devices-hap/humidifier.ts +0 -669
  400. package/src/devices-hap/iosensor.ts +0 -427
  401. package/src/devices-hap/lightstrip.ts +0 -836
  402. package/src/devices-hap/lock.ts +0 -620
  403. package/src/devices-hap/meter.ts +0 -426
  404. package/src/devices-hap/meterplus.ts +0 -430
  405. package/src/devices-hap/meterpro.ts +0 -522
  406. package/src/devices-hap/motion.ts +0 -390
  407. package/src/devices-hap/plug.ts +0 -423
  408. package/src/devices-hap/relayswitch.ts +0 -727
  409. package/src/devices-hap/robotvacuumcleaner.ts +0 -568
  410. package/src/devices-hap/waterdetector.ts +0 -400
  411. package/src/devices-matter/BaseMatterAccessory.ts +0 -131
  412. package/src/devices-matter/ColorLightAccessory.ts +0 -113
  413. package/src/devices-matter/ColorTemperatureLightAccessory.ts +0 -98
  414. package/src/devices-matter/ContactSensorAccessory.ts +0 -37
  415. package/src/devices-matter/DimmableLightAccessory.ts +0 -196
  416. package/src/devices-matter/DoorLockAccessory.ts +0 -56
  417. package/src/devices-matter/ExtendedColorLightAccessory.ts +0 -127
  418. package/src/devices-matter/FanAccessory.ts +0 -87
  419. package/src/devices-matter/HumiditySensorAccessory.ts +0 -39
  420. package/src/devices-matter/LeakSensorAccessory.ts +0 -36
  421. package/src/devices-matter/LightSensorAccessory.ts +0 -39
  422. package/src/devices-matter/OccupancySensorAccessory.ts +0 -52
  423. package/src/devices-matter/OnOffLightAccessory.ts +0 -133
  424. package/src/devices-matter/OnOffOutletAccessory.ts +0 -52
  425. package/src/devices-matter/OnOffSwitchAccessory.ts +0 -52
  426. package/src/devices-matter/RoboticVacuumAccessory.ts +0 -484
  427. package/src/devices-matter/SmokeCOAlarmAccessory.ts +0 -59
  428. package/src/devices-matter/TemperatureSensorAccessory.ts +0 -39
  429. package/src/devices-matter/ThermostatAccessory.ts +0 -105
  430. package/src/devices-matter/VenetianBlindAccessory.ts +0 -118
  431. package/src/devices-matter/WindowBlindAccessory.ts +0 -94
  432. package/src/devices-matter/custom/PowerStripAccessory.ts +0 -309
  433. package/src/devices-matter/custom/index.ts +0 -8
  434. package/src/devices-matter/index.ts +0 -29
  435. package/src/index.test.ts +0 -19
  436. package/src/irdevice/airconditioner.ts +0 -533
  437. package/src/irdevice/airpurifier.ts +0 -252
  438. package/src/irdevice/camera.ts +0 -129
  439. package/src/irdevice/fan.ts +0 -226
  440. package/src/irdevice/irdevice.ts +0 -344
  441. package/src/irdevice/light.ts +0 -246
  442. package/src/irdevice/other.ts +0 -790
  443. package/src/irdevice/tv.ts +0 -378
  444. package/src/irdevice/vacuumcleaner.ts +0 -126
  445. package/src/irdevice/waterheater.ts +0 -127
  446. package/src/platform-hap.ts +0 -2986
  447. package/src/platform-matter.ts +0 -465
  448. package/src/verifyconfig.test.ts +0 -197
@@ -1,465 +0,0 @@
1
- import type {
2
- API,
3
- DynamicPlatformPlugin,
4
- Logging,
5
- MatterAccessory,
6
- SerializedMatterAccessory,
7
- } from 'homebridge'
8
-
9
- import type { SwitchBotPlatformConfig } from './settings.js'
10
-
11
- import {
12
- ColorLightAccessory,
13
- ColorTemperatureLightAccessory,
14
- ContactSensorAccessory,
15
- DimmableLightAccessory,
16
- DoorLockAccessory,
17
- ExtendedColorLightAccessory,
18
- FanAccessory,
19
- HumiditySensorAccessory,
20
- LeakSensorAccessory,
21
- LightSensorAccessory,
22
- OccupancySensorAccessory,
23
- OnOffLightAccessory,
24
- OnOffOutletAccessory,
25
- OnOffSwitchAccessory,
26
- PowerStripAccessory,
27
- RoboticVacuumAccessory,
28
- SmokeCOAlarmAccessory,
29
- TemperatureSensorAccessory,
30
- ThermostatAccessory,
31
- VenetianBlindAccessory,
32
- WindowBlindAccessory,
33
- } from './devices-matter/index.js'
34
- import { PLATFORM_NAME, PLUGIN_NAME } from './settings.js'
35
- import { cleanDeviceConfig } from './utils.js'
36
-
37
- /**
38
- * MatterPlatform
39
- * Demonstrates all available Matter device types in Homebridge
40
- *
41
- * Organized by official Matter Specification v1.4.1 categories
42
- */
43
- export class SwitchBotMatterPlatform implements DynamicPlatformPlugin {
44
- // Track restored HAP cached accessories (required for DynamicPlatformPlugin)
45
- // This is commented out here as this plugin does not have any HAP accessories
46
- // public readonly accessories: Map<string, PlatformAccessory> = new Map()
47
-
48
- // Track restored Matter cached accessories
49
- public readonly matterAccessories: Map<string, SerializedMatterAccessory> = new Map()
50
-
51
- constructor(
52
- public readonly log: Logging,
53
- public readonly config: SwitchBotPlatformConfig,
54
- public readonly api: API,
55
- ) {
56
- this.log.debug('Finished initializing platform:', this.config.name)
57
-
58
- // Normalize deviceConfig to remove UI-inserted defaults
59
- try {
60
- if ((this.config as any).options) {
61
- const cleaned = cleanDeviceConfig((this.config as any).options.deviceConfig)
62
- if (cleaned) {
63
- ;(this.config as any).options.deviceConfig = cleaned
64
- } else {
65
- delete (this.config as any).options.deviceConfig
66
- }
67
- }
68
- } catch (e) {
69
- this.log.debug('Failed to clean deviceConfig: %s', e)
70
- }
71
-
72
- // Does the user have a version of Homebridge that is compatible with matter?
73
- if (!this.api.isMatterAvailable?.()) {
74
- this.log.warn('Matter is not available in this version of Homebridge. Please update Homebridge to use this plugin.')
75
- }
76
-
77
- // Check if the user has matter enabled, this means:
78
- // - If the plugin is running on the main bridge, then the user must have enabled matter in the Homebridge settings page in the UI
79
- // - 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
80
- // In reality, only the below check is needed, but they are both included here for completeness
81
- // Remember to use a '?.' optional chaining operator in case the user is running an older version of Homebridge that does not have these APIs
82
- if (!this.api.isMatterEnabled?.()) {
83
- this.log.warn('Matter is not enabled in Homebridge. Please enable Matter in the Homebridge settings to use this plugin.')
84
- return
85
- }
86
-
87
- // Register Matter accessories when Homebridge has finished launching
88
- this.api.on('didFinishLaunching', () => {
89
- this.log.debug('Executed didFinishLaunching callback')
90
- this.registerMatterAccessories()
91
- })
92
- }
93
-
94
- /**
95
- * Required for DynamicPlatformPlugin
96
- * Called when homebridge restores cached accessories from disk at startup
97
- */
98
- configureAccessory(/* accessory: PlatformAccessory */) {
99
- // Note this is not used for Matter accessories - use configureMatterAccessory instead
100
- // This plugin does not have any hap accessories, so here we can comment this out
101
- // this.accessories.set(accessory.UUID, accessory)
102
- }
103
-
104
- /**
105
- * Called when homebridge restores cached Matter accessories from disk at startup.
106
- *
107
- * This is where you can access the `accessory.context` object to retrieve
108
- * any custom data you stored when the accessory was originally registered.
109
- */
110
- configureMatterAccessory(accessory: SerializedMatterAccessory) {
111
- this.log.debug('Loading cached Matter accessory:', accessory.displayName)
112
- this.matterAccessories.set(accessory.uuid, accessory)
113
- }
114
-
115
- /**
116
- * Register all Matter accessories
117
- */
118
- private async registerMatterAccessories() {
119
- this.log.info('═'.repeat(80))
120
- this.log.info('Homebridge Matter Plugin')
121
- this.log.info('═'.repeat(80))
122
-
123
- // Remove accessories that are disabled in config
124
- await this.removeDisabledAccessories()
125
-
126
- // Register devices by Matter specification sections
127
- await this.registerSection4Lighting()
128
- await this.registerSection5SmartPlugs()
129
- await this.registerSection6Switches()
130
- await this.registerSection7Sensors()
131
- await this.registerSection8Closure()
132
- await this.registerSection9HVAC()
133
- await this.registerSection12Robotic()
134
- await this.registerCustomDevices()
135
-
136
- this.log.info('═'.repeat(80))
137
- this.log.info('Finished registering Matter accessories')
138
- this.log.info('═'.repeat(80))
139
- }
140
-
141
- /**
142
- * Remove accessories that are disabled in config
143
- */
144
- private async removeDisabledAccessories() {
145
- const configMap = [
146
- { enabled: this.config.enableOnOffLight, uuid: this.api.matter.uuid.generate('matter-onoff-light'), name: 'On/Off Light' },
147
- { enabled: this.config.enableDimmableLight, uuid: this.api.matter.uuid.generate('matter-dimmable-light'), name: 'Dimmable Light' },
148
- { enabled: this.config.enableColourTemperatureLight, uuid: this.api.matter.uuid.generate('matter-colour-temp-light'), name: 'Colour Temperature Light' },
149
- { enabled: this.config.enableColourLight, uuid: this.api.matter.uuid.generate('matter-colour-light'), name: 'Colour Light (HS)' },
150
- { enabled: this.config.enableExtendedColourLight, uuid: this.api.matter.uuid.generate('matter-extended-colour-light'), name: 'Extended Colour Light' },
151
- { enabled: this.config.enableOnOffOutlet, uuid: this.api.matter.uuid.generate('matter-onoff-outlet'), name: 'On/Off Outlet' },
152
- { enabled: this.config.enableOnOffSwitch, uuid: this.api.matter.uuid.generate('matter-onoff-switch'), name: 'On/Off Switch' },
153
- { enabled: this.config.enableTemperatureSensor, uuid: this.api.matter.uuid.generate('matter-temperature-sensor'), name: 'Temperature Sensor' },
154
- { enabled: this.config.enableHumiditySensor, uuid: this.api.matter.uuid.generate('matter-humidity-sensor'), name: 'Humidity Sensor' },
155
- { enabled: this.config.enableLightSensor, uuid: this.api.matter.uuid.generate('matter-light-sensor'), name: 'Light Sensor' },
156
- { enabled: this.config.enableOccupancySensor, uuid: this.api.matter.uuid.generate('matter-occupancy-sensor'), name: 'Occupancy Sensor' },
157
- { enabled: this.config.enableContactSensor, uuid: this.api.matter.uuid.generate('matter-contact-sensor'), name: 'Contact Sensor' },
158
- { enabled: this.config.enableLeakSensor, uuid: this.api.matter.uuid.generate('matter-leak-sensor'), name: 'Leak Sensor' },
159
- { enabled: this.config.enableSmokeSensor, uuid: this.api.matter.uuid.generate('matter-smoke-sensor'), name: 'Smoke Sensor' },
160
- { enabled: this.config.enableDoorLock, uuid: this.api.matter.uuid.generate('matter-door-lock'), name: 'Door Lock' },
161
- { enabled: this.config.enableWindowBlind, uuid: this.api.matter.uuid.generate('matter-window-blind'), name: 'Window Blind' },
162
- { enabled: this.config.enableVenetianBlind, uuid: this.api.matter.uuid.generate('matter-venetian-blind'), name: 'Venetian Blind' },
163
- { enabled: this.config.enableThermostat, uuid: this.api.matter.uuid.generate('matter-thermostat'), name: 'Thermostat' },
164
- { enabled: this.config.enableFan, uuid: this.api.matter.uuid.generate('matter-fan'), name: 'Fan' },
165
- { enabled: this.config.enableRobotVacuum, uuid: this.api.matter.uuid.generate('matter-robot-vacuum'), name: 'Robot Vacuum' },
166
- { enabled: this.config.enablePowerStrip, uuid: this.api.matter.uuid.generate('matter-power-strip'), name: 'Power Strip' },
167
- ]
168
-
169
- for (const { enabled, uuid, name } of configMap) {
170
- if (enabled === false) {
171
- const existingAccessory = this.matterAccessories.get(uuid)
172
- if (existingAccessory) {
173
- this.log.info(`Removing accessory '${name}' (disabled in config)`)
174
- await this.api.matter.unregisterPlatformAccessories(PLUGIN_NAME, PLATFORM_NAME, [existingAccessory as unknown as MatterAccessory])
175
- this.matterAccessories.delete(uuid)
176
- }
177
- }
178
- }
179
- }
180
-
181
- /**
182
- * Section 4: Lighting Devices (Matter Spec § 4)
183
- */
184
- private async registerSection4Lighting() {
185
- this.log.info('═'.repeat(80))
186
- this.log.info('Section 4: Lighting Devices (Matter Spec § 4)')
187
- this.log.info('═'.repeat(80))
188
-
189
- const accessories: Array<MatterAccessory<Record<string, unknown>>> = []
190
-
191
- // On/Off Light
192
- if (this.config.enableOnOffLight !== false) {
193
- const device = new OnOffLightAccessory(this.api, this.log)
194
- accessories.push(device.toAccessory())
195
- }
196
-
197
- // Dimmable Light
198
- if (this.config.enableDimmableLight !== false) {
199
- const device = new DimmableLightAccessory(this.api, this.log)
200
- accessories.push(device.toAccessory())
201
- }
202
-
203
- // Color Temperature Light
204
- if (this.config.enableColourTemperatureLight !== false) {
205
- const device = new ColorTemperatureLightAccessory(this.api, this.log)
206
- accessories.push(device.toAccessory())
207
- }
208
-
209
- // Color Light (HS only)
210
- if (this.config.enableColourLight !== false) {
211
- const device = new ColorLightAccessory(this.api, this.log)
212
- accessories.push(device.toAccessory())
213
- }
214
-
215
- // Extended Color Light (HS+CCT)
216
- if (this.config.enableExtendedColourLight !== false) {
217
- const device = new ExtendedColorLightAccessory(this.api, this.log)
218
- accessories.push(device.toAccessory())
219
- }
220
-
221
- if (accessories.length > 0) {
222
- this.log.info(`✓ Registered ${accessories.length} lighting device(s)`)
223
- for (const acc of accessories) {
224
- this.log.info(` - ${acc.displayName}`)
225
- }
226
- await this.api.matter.registerPlatformAccessories(PLUGIN_NAME, PLATFORM_NAME, accessories)
227
- }
228
- }
229
-
230
- /**
231
- * Section 5: Smart Plugs/Actuators (Matter Spec § 5)
232
- */
233
- private async registerSection5SmartPlugs() {
234
- this.log.info('═'.repeat(80))
235
- this.log.info('Section 5: Smart Plugs/Actuators (Matter Spec § 5)')
236
- this.log.info('═'.repeat(80))
237
-
238
- const accessories: Array<MatterAccessory<Record<string, unknown>>> = []
239
-
240
- // On/Off Outlet
241
- if (this.config.enableOnOffOutlet !== false) {
242
- const device = new OnOffOutletAccessory(this.api, this.log)
243
- accessories.push(device.toAccessory())
244
- }
245
-
246
- if (accessories.length > 0) {
247
- this.log.info(`✓ Registered ${accessories.length} smart plug/actuator device(s)`)
248
- for (const acc of accessories) {
249
- this.log.info(` - ${acc.displayName}`)
250
- }
251
- await this.api.matter.registerPlatformAccessories(PLUGIN_NAME, PLATFORM_NAME, accessories)
252
- }
253
- }
254
-
255
- /**
256
- * Section 6: Switches & Controllers (Matter Spec § 6)
257
- */
258
- private async registerSection6Switches() {
259
- this.log.info('═'.repeat(80))
260
- this.log.info('Section 6: Switches & Controllers (Matter Spec § 6)')
261
- this.log.info('═'.repeat(80))
262
-
263
- const accessories: Array<MatterAccessory<Record<string, unknown>>> = []
264
-
265
- // On/Off Switch
266
- if (this.config.enableOnOffSwitch !== false) {
267
- const device = new OnOffSwitchAccessory(this.api, this.log)
268
- accessories.push(device.toAccessory())
269
- }
270
-
271
- if (accessories.length > 0) {
272
- this.log.info(`✓ Registered ${accessories.length} switch/controller device(s)`)
273
- for (const acc of accessories) {
274
- this.log.info(` - ${acc.displayName}`)
275
- }
276
- await this.api.matter.registerPlatformAccessories(PLUGIN_NAME, PLATFORM_NAME, accessories)
277
- }
278
- }
279
-
280
- /**
281
- * Section 7: Sensors (Matter Spec § 7)
282
- */
283
- private async registerSection7Sensors() {
284
- this.log.info('═'.repeat(80))
285
- this.log.info('Section 7: Sensors (Matter Spec § 7)')
286
- this.log.info('═'.repeat(80))
287
-
288
- const accessories: Array<MatterAccessory<Record<string, unknown>>> = []
289
-
290
- // Contact Sensor
291
- if (this.config.enableContactSensor !== false) {
292
- const device = new ContactSensorAccessory(this.api, this.log)
293
- accessories.push(device.toAccessory())
294
- }
295
-
296
- // Light Sensor
297
- if (this.config.enableLightSensor !== false) {
298
- const device = new LightSensorAccessory(this.api, this.log)
299
- accessories.push(device.toAccessory())
300
- }
301
-
302
- // Occupancy Sensor
303
- if (this.config.enableOccupancySensor !== false) {
304
- const device = new OccupancySensorAccessory(this.api, this.log)
305
- accessories.push(device.toAccessory())
306
- }
307
-
308
- // Temperature Sensor
309
- if (this.config.enableTemperatureSensor !== false) {
310
- const device = new TemperatureSensorAccessory(this.api, this.log)
311
- accessories.push(device.toAccessory())
312
- }
313
-
314
- // Humidity Sensor
315
- if (this.config.enableHumiditySensor !== false) {
316
- const device = new HumiditySensorAccessory(this.api, this.log)
317
- accessories.push(device.toAccessory())
318
- }
319
-
320
- // Smoke/CO Alarm
321
- if (this.config.enableSmokeSensor !== false) {
322
- const device = new SmokeCOAlarmAccessory(this.api, this.log)
323
- accessories.push(device.toAccessory())
324
- }
325
-
326
- // Leak Sensor
327
- if (this.config.enableLeakSensor !== false) {
328
- const device = new LeakSensorAccessory(this.api, this.log)
329
- accessories.push(device.toAccessory())
330
- }
331
-
332
- if (accessories.length > 0) {
333
- this.log.info(`✓ Registered ${accessories.length} sensor device(s)`)
334
- for (const acc of accessories) {
335
- this.log.info(` - ${acc.displayName}`)
336
- }
337
- await this.api.matter.registerPlatformAccessories(PLUGIN_NAME, PLATFORM_NAME, accessories)
338
- }
339
- }
340
-
341
- /**
342
- * Section 8: Closure Devices (Matter Spec § 8)
343
- */
344
- private async registerSection8Closure() {
345
- this.log.info('═'.repeat(80))
346
- this.log.info('Section 8: Closure Devices (Matter Spec § 8)')
347
- this.log.info('═'.repeat(80))
348
-
349
- const accessories: Array<MatterAccessory<Record<string, unknown>>> = []
350
-
351
- // Door Lock
352
- if (this.config.enableDoorLock !== false) {
353
- const device = new DoorLockAccessory(this.api, this.log)
354
- accessories.push(device.toAccessory())
355
- }
356
-
357
- // Window Blind
358
- if (this.config.enableWindowBlind !== false) {
359
- const device = new WindowBlindAccessory(this.api, this.log)
360
- accessories.push(device.toAccessory())
361
- }
362
-
363
- // Venetian Blind
364
- if (this.config.enableVenetianBlind !== false) {
365
- const device = new VenetianBlindAccessory(this.api, this.log)
366
- accessories.push(device.toAccessory())
367
- }
368
-
369
- if (accessories.length > 0) {
370
- this.log.info(`✓ Registered ${accessories.length} closure device(s)`)
371
- for (const acc of accessories) {
372
- this.log.info(` - ${acc.displayName}`)
373
- }
374
- await this.api.matter.registerPlatformAccessories(PLUGIN_NAME, PLATFORM_NAME, accessories)
375
- }
376
- }
377
-
378
- /**
379
- * Section 9: HVAC (Matter Spec § 9)
380
- */
381
- private async registerSection9HVAC() {
382
- this.log.info('═'.repeat(80))
383
- this.log.info('Section 9: HVAC (Matter Spec § 9)')
384
- this.log.info('═'.repeat(80))
385
-
386
- const accessories: Array<MatterAccessory<Record<string, unknown>>> = []
387
-
388
- // Thermostat
389
- if (this.config.enableThermostat !== false) {
390
- const device = new ThermostatAccessory(this.api, this.log)
391
- accessories.push(device.toAccessory())
392
- }
393
-
394
- // Fan
395
- if (this.config.enableFan !== false) {
396
- const device = new FanAccessory(this.api, this.log)
397
- accessories.push(device.toAccessory())
398
- }
399
-
400
- if (accessories.length > 0) {
401
- this.log.info(`✓ Registered ${accessories.length} HVAC device(s)`)
402
- for (const acc of accessories) {
403
- this.log.info(` - ${acc.displayName}`)
404
- }
405
- await this.api.matter.registerPlatformAccessories(PLUGIN_NAME, PLATFORM_NAME, accessories)
406
- }
407
- }
408
-
409
- /**
410
- * Section 12: Robotic Devices (Matter Spec § 12)
411
- * ⚠️ IMPORTANT: RVC devices use a DIFFERENT PROCESS (same code) than other devices!
412
- * When this runs, you'll see separate commissioning codes in the logs for the robot vacuum.
413
- * Use those codes to pair the vacuum as a separate bridge in your Home app.
414
- */
415
- private async registerSection12Robotic() {
416
- this.log.info('═'.repeat(80))
417
- this.log.info('Section 12: Robotic Devices (Matter Spec § 12)')
418
- this.log.info('═'.repeat(80))
419
-
420
- const accessories: Array<MatterAccessory<Record<string, unknown>>> = []
421
-
422
- // Robot Vacuum
423
- if (this.config.enableRobotVacuum !== false) {
424
- const device = new RoboticVacuumAccessory(this.api, this.log)
425
- accessories.push(device.toAccessory())
426
- }
427
-
428
- if (accessories.length > 0) {
429
- this.log.info(`✓ Registered ${accessories.length} robot vacuum device(s)`)
430
- for (const acc of accessories) {
431
- this.log.info(` - ${acc.displayName} (standalone for Apple Home compatibility)`)
432
- }
433
- await this.api.matter.registerPlatformAccessories(PLUGIN_NAME, PLATFORM_NAME, accessories)
434
- }
435
- }
436
-
437
- /**
438
- * Custom Devices
439
- *
440
- * This section demonstrates custom device implementations that go beyond
441
- * the standard Matter device types. These examples show advanced patterns
442
- * like managing multiple logical components within a single device.
443
- */
444
- private async registerCustomDevices() {
445
- this.log.info('═'.repeat(80))
446
- this.log.info('Custom Devices')
447
- this.log.info('═'.repeat(80))
448
-
449
- const accessories: Array<MatterAccessory<Record<string, unknown>>> = []
450
-
451
- // Power Strip (4 Outlets)
452
- if (this.config.enablePowerStrip !== false) {
453
- const device = new PowerStripAccessory(this.api, this.log)
454
- accessories.push(device.toAccessory())
455
- }
456
-
457
- if (accessories.length > 0) {
458
- this.log.info(`✓ Registered ${accessories.length} custom device(s)`)
459
- for (const acc of accessories) {
460
- this.log.info(` - ${acc.displayName}`)
461
- }
462
- await this.api.matter.registerPlatformAccessories(PLUGIN_NAME, PLATFORM_NAME, accessories)
463
- }
464
- }
465
- }
@@ -1,197 +0,0 @@
1
- import { describe, expect, it, vi } from 'vitest'
2
- import type { SwitchBotPlatformConfig } from './settings.js'
3
-
4
- // Create a minimal mock of the SwitchBotPlatform to test verifyConfig
5
- class MockSwitchBotPlatform {
6
- config: SwitchBotPlatformConfig
7
- errorLogCalls: string[] = []
8
- debugLogCalls: string[] = []
9
-
10
- constructor(config: SwitchBotPlatformConfig) {
11
- this.config = config
12
- }
13
-
14
- errorLog(message: string) {
15
- this.errorLogCalls.push(message)
16
- }
17
-
18
- debugLog(message: string) {
19
- this.debugLogCalls.push(message)
20
- }
21
-
22
- debugWarnLog(message: string) {
23
- this.debugLogCalls.push(`WARN: ${message}`)
24
- }
25
-
26
- debugErrorLog(message: string) {
27
- this.debugLogCalls.push(`ERROR: ${message}`)
28
- }
29
-
30
- // Copy the exact verifyConfig method from the actual platform
31
- async verifyConfig() {
32
- this.debugLog('Verifying Config')
33
- this.config = this.config || {}
34
- this.config.options = this.config.options || {}
35
-
36
- if (this.config.options) {
37
- // Device Config
38
- if (this.config.options.devices) {
39
- for (const deviceConfig of this.config.options.devices) {
40
- if (!deviceConfig.hide_device) {
41
- if (!deviceConfig.deviceId) {
42
- this.errorLog('The devices config section is missing the *Device ID* in the config. Please check your config.')
43
- }
44
- if (!deviceConfig.configDeviceType && (deviceConfig as any).connectionType) {
45
- this.errorLog('The devices config section is missing the *Device Type* in the config. Please check your config.')
46
- }
47
- }
48
- }
49
- }
50
-
51
- // IR Device Config
52
- if (this.config.options.irdevices) {
53
- for (const irDeviceConfig of this.config.options.irdevices) {
54
- if (!irDeviceConfig.hide_device) {
55
- if (!irDeviceConfig.deviceId) {
56
- this.errorLog('The devices config section is missing the *Device ID* in the config. Please check your config.')
57
- }
58
- if (!irDeviceConfig.deviceId && !irDeviceConfig.configRemoteType) {
59
- this.errorLog('The devices config section is missing the *Device Type* in the config. Please check your config.')
60
- }
61
- }
62
- }
63
- }
64
- }
65
-
66
- if (!this.config.credentials && !this.config.options) {
67
- this.debugWarnLog('Missing Credentials')
68
- } else if (this.config.credentials && !this.config.credentials.notice) {
69
- if (!this.config.credentials?.token) {
70
- this.debugErrorLog('Missing token')
71
- this.debugWarnLog('Cloud Enabled SwitchBot Devices & IR Devices will not work')
72
- }
73
- if (this.config.credentials?.token) {
74
- if (!this.config.credentials?.secret) {
75
- this.debugErrorLog('Missing secret')
76
- this.debugWarnLog('Cloud Enabled SwitchBot Devices & IR Devices will not work')
77
- }
78
- }
79
- }
80
- }
81
- }
82
-
83
- describe('verifyConfig fix for reboot loop', () => {
84
- it('should log error instead of throwing when device config is missing deviceId', async () => {
85
- const config: SwitchBotPlatformConfig = {
86
- platform: 'SwitchBot',
87
- name: 'SwitchBot',
88
- credentials: {
89
- token: 'test-token',
90
- secret: 'test-secret',
91
- },
92
- options: {
93
- devices: [
94
- {
95
- logging: 'standard',
96
- } as any, // Missing deviceId
97
- ],
98
- },
99
- }
100
-
101
- const platform = new MockSwitchBotPlatform(config)
102
-
103
- // This should NOT throw an error anymore - it should log instead
104
- await expect(platform.verifyConfig()).resolves.not.toThrow()
105
-
106
- // Verify that the error was logged instead of thrown
107
- expect(platform.errorLogCalls).toContain(
108
- 'The devices config section is missing the *Device ID* in the config. Please check your config.'
109
- )
110
- })
111
-
112
- it('should log error instead of throwing when device config is missing configDeviceType with connectionType', async () => {
113
- const config: SwitchBotPlatformConfig = {
114
- platform: 'SwitchBot',
115
- name: 'SwitchBot',
116
- credentials: {
117
- token: 'test-token',
118
- secret: 'test-secret',
119
- },
120
- options: {
121
- devices: [
122
- {
123
- deviceId: 'test-device-id',
124
- connectionType: 'BLE',
125
- // Missing configDeviceType
126
- } as any,
127
- ],
128
- },
129
- }
130
-
131
- const platform = new MockSwitchBotPlatform(config)
132
-
133
- // This should NOT throw an error anymore - it should log instead
134
- await expect(platform.verifyConfig()).resolves.not.toThrow()
135
-
136
- // Verify that the error was logged instead of thrown
137
- expect(platform.errorLogCalls).toContain(
138
- 'The devices config section is missing the *Device Type* in the config. Please check your config.'
139
- )
140
- })
141
-
142
- it('should not log error when device config has hide_device set to true', async () => {
143
- const config: SwitchBotPlatformConfig = {
144
- platform: 'SwitchBot',
145
- name: 'SwitchBot',
146
- credentials: {
147
- token: 'test-token',
148
- secret: 'test-secret',
149
- },
150
- options: {
151
- devices: [
152
- {
153
- hide_device: true,
154
- // Missing deviceId but hidden
155
- } as any,
156
- ],
157
- },
158
- }
159
-
160
- const platform = new MockSwitchBotPlatform(config)
161
-
162
- // Should not throw or log errors because device is hidden
163
- await expect(platform.verifyConfig()).resolves.not.toThrow()
164
- expect(platform.errorLogCalls).toHaveLength(0)
165
- })
166
-
167
- it('should handle valid device config without errors', async () => {
168
- const config: SwitchBotPlatformConfig = {
169
- platform: 'SwitchBot',
170
- name: 'SwitchBot',
171
- credentials: {
172
- token: 'test-token',
173
- secret: 'test-secret',
174
- },
175
- options: {
176
- devices: [
177
- {
178
- deviceId: 'test-device-id',
179
- configDeviceType: 'Bot',
180
- logging: 'standard',
181
- } as any,
182
- ],
183
- },
184
- }
185
-
186
- const platform = new MockSwitchBotPlatform(config)
187
-
188
- // Should not throw or log device config errors with valid config
189
- await expect(platform.verifyConfig()).resolves.not.toThrow()
190
-
191
- // Should not have device config errors
192
- expect(platform.errorLogCalls.filter(msg =>
193
- msg.includes('missing the *Device ID*') ||
194
- msg.includes('missing the *Device Type*')
195
- )).toHaveLength(0)
196
- })
197
- })