@switchbot/homebridge-switchbot 5.0.0-beta.15 → 5.0.0-beta.150

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 (610) hide show
  1. package/.changeset/config.json +14 -0
  2. package/.github/ISSUE_TEMPLATE/e2e-verification.md +36 -0
  3. package/.github/copilot-instructions.md +39 -0
  4. package/.github/workflows/ci.yml +32 -0
  5. package/.github/workflows/manual-e2e.yml +115 -0
  6. package/.github/workflows/release.yml +0 -4
  7. package/.husky/pre-push +15 -0
  8. package/CHANGELOG.md +35 -0
  9. package/E2E-VERIFICATION.md +121 -0
  10. package/MIGRATION.md +54 -0
  11. package/README.md +136 -4
  12. package/TODO.md +263 -0
  13. package/config.schema.json +284 -14787
  14. package/dist/SwitchBotHAPPlatform.d.ts +133 -0
  15. package/dist/SwitchBotHAPPlatform.d.ts.map +1 -0
  16. package/dist/SwitchBotHAPPlatform.js +555 -0
  17. package/dist/SwitchBotHAPPlatform.js.map +1 -0
  18. package/dist/SwitchBotMatterPlatform.d.ts +141 -0
  19. package/dist/SwitchBotMatterPlatform.d.ts.map +1 -0
  20. package/dist/SwitchBotMatterPlatform.js +536 -0
  21. package/dist/SwitchBotMatterPlatform.js.map +1 -0
  22. package/dist/device-types.d.ts +31 -0
  23. package/dist/device-types.d.ts.map +1 -0
  24. package/dist/device-types.js +246 -0
  25. package/dist/device-types.js.map +1 -0
  26. package/dist/deviceCommandMapper.d.ts +10 -0
  27. package/dist/deviceCommandMapper.d.ts.map +1 -0
  28. package/dist/deviceCommandMapper.js +319 -0
  29. package/dist/deviceCommandMapper.js.map +1 -0
  30. package/dist/deviceFactory.d.ts +14 -0
  31. package/dist/deviceFactory.d.ts.map +1 -0
  32. package/dist/deviceFactory.js +159 -0
  33. package/dist/deviceFactory.js.map +1 -0
  34. package/dist/devices/deviceBase.d.ts +50 -0
  35. package/dist/devices/deviceBase.d.ts.map +1 -0
  36. package/dist/devices/deviceBase.js +119 -0
  37. package/dist/devices/deviceBase.js.map +1 -0
  38. package/dist/devices/genericDevice.d.ts +320 -0
  39. package/dist/devices/genericDevice.d.ts.map +1 -0
  40. package/dist/devices/genericDevice.js +1363 -0
  41. package/dist/devices/genericDevice.js.map +1 -0
  42. package/dist/errors.d.ts +38 -0
  43. package/dist/errors.d.ts.map +1 -0
  44. package/dist/errors.js +32 -0
  45. package/dist/errors.js.map +1 -0
  46. package/dist/homebridge-ui/endpoints/config.d.ts +3 -0
  47. package/dist/homebridge-ui/endpoints/config.d.ts.map +1 -0
  48. package/dist/homebridge-ui/endpoints/config.js +90 -0
  49. package/dist/homebridge-ui/endpoints/config.js.map +1 -0
  50. package/dist/homebridge-ui/endpoints/devices.d.ts +6 -0
  51. package/dist/homebridge-ui/endpoints/devices.d.ts.map +1 -0
  52. package/dist/homebridge-ui/endpoints/devices.js +81 -0
  53. package/dist/homebridge-ui/endpoints/devices.js.map +1 -0
  54. package/dist/homebridge-ui/endpoints/discovery.d.ts +7 -0
  55. package/dist/homebridge-ui/endpoints/discovery.d.ts.map +1 -0
  56. package/dist/homebridge-ui/endpoints/discovery.js +212 -0
  57. package/dist/homebridge-ui/endpoints/discovery.js.map +1 -0
  58. package/dist/homebridge-ui/public/css/styles.css +472 -0
  59. package/dist/homebridge-ui/public/index.html +210 -244
  60. package/dist/homebridge-ui/public/js/advanced-settings.d.ts +3 -0
  61. package/dist/homebridge-ui/public/js/advanced-settings.d.ts.map +1 -0
  62. package/dist/homebridge-ui/public/js/advanced-settings.js +95 -0
  63. package/dist/homebridge-ui/public/js/advanced-settings.js.map +1 -0
  64. package/dist/homebridge-ui/public/js/advanced-settings.ts +94 -0
  65. package/dist/homebridge-ui/public/js/api.d.ts +66 -0
  66. package/dist/homebridge-ui/public/js/api.d.ts.map +1 -0
  67. package/dist/homebridge-ui/public/js/api.js +281 -0
  68. package/dist/homebridge-ui/public/js/api.js.map +1 -0
  69. package/dist/homebridge-ui/public/js/api.ts +342 -0
  70. package/dist/homebridge-ui/public/js/app.d.ts +2 -0
  71. package/dist/homebridge-ui/public/js/app.d.ts.map +1 -0
  72. package/dist/homebridge-ui/public/js/app.js +3863 -0
  73. package/dist/homebridge-ui/public/js/app.js.map +7 -0
  74. package/dist/homebridge-ui/public/js/app.ts +22 -0
  75. package/dist/homebridge-ui/public/js/constants.d.ts +2 -0
  76. package/dist/homebridge-ui/public/js/constants.d.ts.map +1 -0
  77. package/dist/homebridge-ui/public/js/constants.js +2 -0
  78. package/dist/homebridge-ui/public/js/constants.js.map +1 -0
  79. package/dist/homebridge-ui/public/js/constants.ts +1 -0
  80. package/dist/homebridge-ui/public/js/credentials.d.ts +3 -0
  81. package/dist/homebridge-ui/public/js/credentials.d.ts.map +1 -0
  82. package/dist/homebridge-ui/public/js/credentials.js +99 -0
  83. package/dist/homebridge-ui/public/js/credentials.js.map +1 -0
  84. package/dist/homebridge-ui/public/js/credentials.ts +105 -0
  85. package/dist/homebridge-ui/public/js/devices-delete.d.ts +3 -0
  86. package/dist/homebridge-ui/public/js/devices-delete.d.ts.map +1 -0
  87. package/dist/homebridge-ui/public/js/devices-delete.js +199 -0
  88. package/dist/homebridge-ui/public/js/devices-delete.js.map +1 -0
  89. package/dist/homebridge-ui/public/js/devices-delete.ts +227 -0
  90. package/dist/homebridge-ui/public/js/devices.d.ts +9 -0
  91. package/dist/homebridge-ui/public/js/devices.d.ts.map +1 -0
  92. package/dist/homebridge-ui/public/js/devices.js +96 -0
  93. package/dist/homebridge-ui/public/js/devices.js.map +1 -0
  94. package/dist/homebridge-ui/public/js/devices.ts +105 -0
  95. package/dist/homebridge-ui/public/js/discovery.d.ts +4 -0
  96. package/dist/homebridge-ui/public/js/discovery.d.ts.map +1 -0
  97. package/dist/homebridge-ui/public/js/discovery.js +1374 -0
  98. package/dist/homebridge-ui/public/js/discovery.js.map +1 -0
  99. package/dist/homebridge-ui/public/js/discovery.ts +1498 -0
  100. package/dist/homebridge-ui/public/js/logger.d.ts +7 -0
  101. package/dist/homebridge-ui/public/js/logger.d.ts.map +1 -0
  102. package/dist/homebridge-ui/public/js/logger.js +17 -0
  103. package/dist/homebridge-ui/public/js/logger.js.map +1 -0
  104. package/dist/homebridge-ui/public/js/logger.ts +17 -0
  105. package/dist/homebridge-ui/public/js/modal.d.ts +5 -0
  106. package/dist/homebridge-ui/public/js/modal.d.ts.map +1 -0
  107. package/dist/homebridge-ui/public/js/modal.js +26 -0
  108. package/dist/homebridge-ui/public/js/modal.js.map +1 -0
  109. package/dist/homebridge-ui/public/js/modal.ts +28 -0
  110. package/dist/homebridge-ui/public/js/modals.d.ts +15 -0
  111. package/dist/homebridge-ui/public/js/modals.d.ts.map +1 -0
  112. package/dist/homebridge-ui/public/js/modals.js +673 -0
  113. package/dist/homebridge-ui/public/js/modals.js.map +1 -0
  114. package/dist/homebridge-ui/public/js/modals.ts +761 -0
  115. package/dist/homebridge-ui/public/js/render.d.ts +71 -0
  116. package/dist/homebridge-ui/public/js/render.d.ts.map +1 -0
  117. package/dist/homebridge-ui/public/js/render.js +953 -0
  118. package/dist/homebridge-ui/public/js/render.js.map +1 -0
  119. package/dist/homebridge-ui/public/js/render.ts +1077 -0
  120. package/dist/homebridge-ui/public/js/toast.d.ts +6 -0
  121. package/dist/homebridge-ui/public/js/toast.d.ts.map +1 -0
  122. package/dist/homebridge-ui/public/js/toast.js +29 -0
  123. package/dist/homebridge-ui/public/js/toast.js.map +1 -0
  124. package/dist/homebridge-ui/public/js/toast.ts +37 -0
  125. package/dist/homebridge-ui/public/js/types.d.ts +23 -0
  126. package/dist/homebridge-ui/public/js/types.d.ts.map +1 -0
  127. package/dist/homebridge-ui/public/js/types.js +2 -0
  128. package/dist/homebridge-ui/public/js/types.js.map +1 -0
  129. package/dist/homebridge-ui/public/js/types.ts +26 -0
  130. package/dist/homebridge-ui/server.js +9 -41
  131. package/dist/homebridge-ui/server.js.map +1 -1
  132. package/dist/homebridge-ui/utils/config-parser.d.ts +35 -0
  133. package/dist/homebridge-ui/utils/config-parser.d.ts.map +1 -0
  134. package/dist/homebridge-ui/utils/config-parser.js +87 -0
  135. package/dist/homebridge-ui/utils/config-parser.js.map +1 -0
  136. package/dist/homebridge-ui/utils/device-migration.d.ts +35 -0
  137. package/dist/homebridge-ui/utils/device-migration.d.ts.map +1 -0
  138. package/dist/homebridge-ui/utils/device-migration.js +111 -0
  139. package/dist/homebridge-ui/utils/device-migration.js.map +1 -0
  140. package/dist/homebridge-ui/utils/logger.d.ts +7 -0
  141. package/dist/homebridge-ui/utils/logger.d.ts.map +1 -0
  142. package/dist/homebridge-ui/utils/logger.js +17 -0
  143. package/dist/homebridge-ui/utils/logger.js.map +1 -0
  144. package/dist/index.d.ts +10 -0
  145. package/dist/index.d.ts.map +1 -1
  146. package/dist/index.js +12 -4
  147. package/dist/index.js.map +1 -1
  148. package/dist/settings.d.ts +11 -249
  149. package/dist/settings.d.ts.map +1 -1
  150. package/dist/settings.js +6 -30
  151. package/dist/settings.js.map +1 -1
  152. package/dist/switchbotClient.d.ts +28 -0
  153. package/dist/switchbotClient.d.ts.map +1 -0
  154. package/dist/switchbotClient.js +175 -0
  155. package/dist/switchbotClient.js.map +1 -0
  156. package/dist/utils.d.ts +92 -115
  157. package/dist/utils.d.ts.map +1 -1
  158. package/dist/utils.js +1117 -902
  159. package/dist/utils.js.map +1 -1
  160. package/docs/assets/highlight.css +28 -0
  161. package/docs/assets/icons.js +1 -1
  162. package/docs/assets/icons.svg +1 -1
  163. package/docs/assets/main.js +2 -2
  164. package/docs/assets/style.css +3 -3
  165. package/docs/index.html +148 -13
  166. package/docs/variables/default.html +3 -1
  167. package/eslint.config.js +7 -8
  168. package/nodemon.json +2 -2
  169. package/package.json +36 -32
  170. package/scripts/build-ui.js +37 -0
  171. package/scripts/e2e/README.md +25 -0
  172. package/scripts/e2e/curtain-e2e.sh +70 -0
  173. package/scripts/e2e/fan-e2e.sh +75 -0
  174. package/scripts/e2e/light-advanced-e2e.sh +97 -0
  175. package/scripts/e2e/light-e2e.sh +75 -0
  176. package/scripts/e2e/list-accessories.sh +19 -0
  177. package/scripts/e2e/lock-e2e.sh +65 -0
  178. package/scripts/free-dev-ports.mjs +105 -0
  179. package/scripts/generate-matter-maps.js +77 -0
  180. package/scripts/run-e2e-local.sh +14 -0
  181. package/scripts/sync-device-types.mjs +31 -0
  182. package/src/SwitchBotHAPPlatform.ts +558 -0
  183. package/src/SwitchBotMatterPlatform.ts +538 -0
  184. package/src/device-types.ts +261 -0
  185. package/src/deviceCommandMapper.ts +333 -0
  186. package/src/deviceFactory.ts +201 -0
  187. package/src/devices/deviceBase.ts +141 -0
  188. package/src/devices/genericDevice.ts +1337 -0
  189. package/src/errors.ts +35 -0
  190. package/src/homebridge-ui/endpoints/config.ts +110 -0
  191. package/src/homebridge-ui/endpoints/devices.ts +88 -0
  192. package/src/homebridge-ui/endpoints/discovery.ts +233 -0
  193. package/src/homebridge-ui/public/css/styles.css +472 -0
  194. package/src/homebridge-ui/public/index.html +210 -244
  195. package/src/homebridge-ui/public/js/advanced-settings.ts +94 -0
  196. package/src/homebridge-ui/public/js/api.ts +342 -0
  197. package/src/homebridge-ui/public/js/app.ts +22 -0
  198. package/src/homebridge-ui/public/js/constants.ts +1 -0
  199. package/src/homebridge-ui/public/js/credentials.ts +105 -0
  200. package/src/homebridge-ui/public/js/devices-delete.ts +227 -0
  201. package/src/homebridge-ui/public/js/devices.ts +105 -0
  202. package/src/homebridge-ui/public/js/discovery.ts +1498 -0
  203. package/src/homebridge-ui/public/js/logger.ts +17 -0
  204. package/src/homebridge-ui/public/js/modal.ts +28 -0
  205. package/src/homebridge-ui/public/js/modals.ts +761 -0
  206. package/src/homebridge-ui/public/js/render.ts +1077 -0
  207. package/src/homebridge-ui/public/js/toast.ts +37 -0
  208. package/src/homebridge-ui/public/js/types.ts +26 -0
  209. package/src/homebridge-ui/server.ts +9 -43
  210. package/src/homebridge-ui/utils/config-parser.ts +108 -0
  211. package/src/homebridge-ui/utils/device-migration.ts +144 -0
  212. package/src/homebridge-ui/utils/logger.ts +17 -0
  213. package/src/index.ts +12 -4
  214. package/src/settings.ts +14 -277
  215. package/src/switchbotClient.ts +181 -0
  216. package/src/utils.ts +1106 -900
  217. package/test/client/switchbot-client-debounce.spec.ts +35 -0
  218. package/test/client/switchbot-client-openapi.spec.ts +19 -0
  219. package/test/client/switchbotClient.spec.ts +23 -0
  220. package/test/device/device-mapping.spec.ts +23 -0
  221. package/test/device/deviceBase.spec.ts +26 -0
  222. package/test/device/deviceFactory-edge.spec.ts +15 -0
  223. package/test/device/deviceFactory.spec.ts +33 -0
  224. package/test/device/fan-swing.spec.ts +34 -0
  225. package/test/device/genericDevice-blepoll.spec.ts +47 -0
  226. package/test/device/irdevice.spec.ts +9 -0
  227. package/test/device/lock-users.spec.ts +35 -0
  228. package/test/device/matter-descriptors.spec.ts +22 -0
  229. package/test/device/matter-device-state.spec.ts +37 -0
  230. package/test/e2e/run-e2e.spec.ts +48 -0
  231. package/test/errors/errors.spec.ts +10 -0
  232. package/test/helpers/matter-harness.ts +64 -0
  233. package/test/homebridge-ui/server.spec.ts +9 -0
  234. package/test/platform/accessory-restore.spec.ts +37 -0
  235. package/test/platform/matter-childbridge.spec.ts +34 -0
  236. package/test/platform/matter-integration.spec.ts +33 -0
  237. package/test/platform/platform-edge.spec.ts +73 -0
  238. package/test/platform/platform.integration.spec.ts +34 -0
  239. package/test/utils/utils-extra.spec.ts +10 -0
  240. package/test/utils/utils.spec.ts +53 -0
  241. package/todo/TODO.md +80 -0
  242. package/vitest.config.ts +7 -0
  243. package/coverage/base.css +0 -224
  244. package/coverage/block-navigation.js +0 -87
  245. package/coverage/clover.xml +0 -15847
  246. package/coverage/coverage-final.json +0 -42
  247. package/coverage/docs/assets/dmt/dmt-component-data.js.html +0 -85
  248. package/coverage/docs/assets/dmt/dmt-components.js.html +0 -286
  249. package/coverage/docs/assets/dmt/index.html +0 -131
  250. package/coverage/docs/assets/hierarchy.js.html +0 -85
  251. package/coverage/docs/assets/icons.js.html +0 -136
  252. package/coverage/docs/assets/index.html +0 -146
  253. package/coverage/docs/assets/main.js.html +0 -265
  254. package/coverage/favicon.png +0 -0
  255. package/coverage/index.html +0 -191
  256. package/coverage/prettify.css +0 -1
  257. package/coverage/prettify.js +0 -2
  258. package/coverage/sort-arrow-sprite.png +0 -0
  259. package/coverage/sorter.js +0 -196
  260. package/coverage/src/device/blindtilt.ts.html +0 -3238
  261. package/coverage/src/device/bot.ts.html +0 -2803
  262. package/coverage/src/device/ceilinglight.ts.html +0 -2338
  263. package/coverage/src/device/colorbulb.ts.html +0 -2824
  264. package/coverage/src/device/contact.ts.html +0 -1465
  265. package/coverage/src/device/curtain.ts.html +0 -2869
  266. package/coverage/src/device/device.ts.html +0 -2500
  267. package/coverage/src/device/fan.ts.html +0 -2242
  268. package/coverage/src/device/hub.ts.html +0 -1408
  269. package/coverage/src/device/humidifier.ts.html +0 -2116
  270. package/coverage/src/device/index.html +0 -416
  271. package/coverage/src/device/iosensor.ts.html +0 -1375
  272. package/coverage/src/device/lightstrip.ts.html +0 -2617
  273. package/coverage/src/device/lock.ts.html +0 -1963
  274. package/coverage/src/device/meter.ts.html +0 -1372
  275. package/coverage/src/device/meterplus.ts.html +0 -1384
  276. package/coverage/src/device/meterpro.ts.html +0 -1618
  277. package/coverage/src/device/motion.ts.html +0 -1264
  278. package/coverage/src/device/plug.ts.html +0 -1372
  279. package/coverage/src/device/relayswitch.ts.html +0 -2284
  280. package/coverage/src/device/robotvacuumcleaner.ts.html +0 -1810
  281. package/coverage/src/device/waterdetector.ts.html +0 -1294
  282. package/coverage/src/homebridge-ui/index.html +0 -116
  283. package/coverage/src/homebridge-ui/server.ts.html +0 -229
  284. package/coverage/src/index.html +0 -161
  285. package/coverage/src/index.ts.html +0 -124
  286. package/coverage/src/irdevice/airconditioner.ts.html +0 -1687
  287. package/coverage/src/irdevice/airpurifier.ts.html +0 -844
  288. package/coverage/src/irdevice/camera.ts.html +0 -475
  289. package/coverage/src/irdevice/fan.ts.html +0 -766
  290. package/coverage/src/irdevice/index.html +0 -251
  291. package/coverage/src/irdevice/irdevice.ts.html +0 -1117
  292. package/coverage/src/irdevice/light.ts.html +0 -826
  293. package/coverage/src/irdevice/other.ts.html +0 -2458
  294. package/coverage/src/irdevice/tv.ts.html +0 -1222
  295. package/coverage/src/irdevice/vacuumcleaner.ts.html +0 -466
  296. package/coverage/src/irdevice/waterheater.ts.html +0 -469
  297. package/coverage/src/platform.ts.html +0 -8776
  298. package/coverage/src/settings.ts.html +0 -934
  299. package/coverage/src/utils.ts.html +0 -2092
  300. package/dist/baseMatterAccessory.test.d.ts +0 -2
  301. package/dist/baseMatterAccessory.test.d.ts.map +0 -1
  302. package/dist/baseMatterAccessory.test.js +0 -71
  303. package/dist/baseMatterAccessory.test.js.map +0 -1
  304. package/dist/devices-hap/airpurifier.d.ts +0 -54
  305. package/dist/devices-hap/airpurifier.d.ts.map +0 -1
  306. package/dist/devices-hap/airpurifier.js +0 -527
  307. package/dist/devices-hap/airpurifier.js.map +0 -1
  308. package/dist/devices-hap/blindtilt.d.ts +0 -90
  309. package/dist/devices-hap/blindtilt.d.ts.map +0 -1
  310. package/dist/devices-hap/blindtilt.js +0 -974
  311. package/dist/devices-hap/blindtilt.js.map +0 -1
  312. package/dist/devices-hap/bot.d.ts +0 -102
  313. package/dist/devices-hap/bot.d.ts.map +0 -1
  314. package/dist/devices-hap/bot.js +0 -811
  315. package/dist/devices-hap/bot.js.map +0 -1
  316. package/dist/devices-hap/ceilinglight.d.ts +0 -85
  317. package/dist/devices-hap/ceilinglight.d.ts.map +0 -1
  318. package/dist/devices-hap/ceilinglight.js +0 -701
  319. package/dist/devices-hap/ceilinglight.js.map +0 -1
  320. package/dist/devices-hap/colorbulb.d.ts +0 -88
  321. package/dist/devices-hap/colorbulb.d.ts.map +0 -1
  322. package/dist/devices-hap/colorbulb.js +0 -881
  323. package/dist/devices-hap/colorbulb.js.map +0 -1
  324. package/dist/devices-hap/contact.d.ts +0 -44
  325. package/dist/devices-hap/contact.d.ts.map +0 -1
  326. package/dist/devices-hap/contact.js +0 -409
  327. package/dist/devices-hap/contact.js.map +0 -1
  328. package/dist/devices-hap/curtain.d.ts +0 -73
  329. package/dist/devices-hap/curtain.d.ts.map +0 -1
  330. package/dist/devices-hap/curtain.js +0 -869
  331. package/dist/devices-hap/curtain.js.map +0 -1
  332. package/dist/devices-hap/device.d.ts +0 -98
  333. package/dist/devices-hap/device.d.ts.map +0 -1
  334. package/dist/devices-hap/device.js +0 -831
  335. package/dist/devices-hap/device.js.map +0 -1
  336. package/dist/devices-hap/fan.d.ts +0 -69
  337. package/dist/devices-hap/fan.d.ts.map +0 -1
  338. package/dist/devices-hap/fan.js +0 -649
  339. package/dist/devices-hap/fan.js.map +0 -1
  340. package/dist/devices-hap/hub.d.ts +0 -37
  341. package/dist/devices-hap/hub.d.ts.map +0 -1
  342. package/dist/devices-hap/hub.js +0 -392
  343. package/dist/devices-hap/hub.js.map +0 -1
  344. package/dist/devices-hap/humidifier.d.ts +0 -68
  345. package/dist/devices-hap/humidifier.d.ts.map +0 -1
  346. package/dist/devices-hap/humidifier.js +0 -628
  347. package/dist/devices-hap/humidifier.js.map +0 -1
  348. package/dist/devices-hap/iosensor.d.ts +0 -42
  349. package/dist/devices-hap/iosensor.d.ts.map +0 -1
  350. package/dist/devices-hap/iosensor.js +0 -382
  351. package/dist/devices-hap/iosensor.js.map +0 -1
  352. package/dist/devices-hap/lightstrip.d.ts +0 -79
  353. package/dist/devices-hap/lightstrip.d.ts.map +0 -1
  354. package/dist/devices-hap/lightstrip.js +0 -797
  355. package/dist/devices-hap/lightstrip.js.map +0 -1
  356. package/dist/devices-hap/lock.d.ts +0 -53
  357. package/dist/devices-hap/lock.d.ts.map +0 -1
  358. package/dist/devices-hap/lock.js +0 -561
  359. package/dist/devices-hap/lock.js.map +0 -1
  360. package/dist/devices-hap/meter.d.ts +0 -37
  361. package/dist/devices-hap/meter.d.ts.map +0 -1
  362. package/dist/devices-hap/meter.js +0 -379
  363. package/dist/devices-hap/meter.js.map +0 -1
  364. package/dist/devices-hap/meterplus.d.ts +0 -42
  365. package/dist/devices-hap/meterplus.d.ts.map +0 -1
  366. package/dist/devices-hap/meterplus.js +0 -384
  367. package/dist/devices-hap/meterplus.js.map +0 -1
  368. package/dist/devices-hap/meterpro.d.ts +0 -43
  369. package/dist/devices-hap/meterpro.d.ts.map +0 -1
  370. package/dist/devices-hap/meterpro.js +0 -468
  371. package/dist/devices-hap/meterpro.js.map +0 -1
  372. package/dist/devices-hap/motion.d.ts +0 -42
  373. package/dist/devices-hap/motion.d.ts.map +0 -1
  374. package/dist/devices-hap/motion.js +0 -345
  375. package/dist/devices-hap/motion.js.map +0 -1
  376. package/dist/devices-hap/plug.d.ts +0 -49
  377. package/dist/devices-hap/plug.d.ts.map +0 -1
  378. package/dist/devices-hap/plug.js +0 -395
  379. package/dist/devices-hap/plug.js.map +0 -1
  380. package/dist/devices-hap/relayswitch.d.ts +0 -96
  381. package/dist/devices-hap/relayswitch.d.ts.map +0 -1
  382. package/dist/devices-hap/relayswitch.js +0 -642
  383. package/dist/devices-hap/relayswitch.js.map +0 -1
  384. package/dist/devices-hap/robotvacuumcleaner.d.ts +0 -54
  385. package/dist/devices-hap/robotvacuumcleaner.d.ts.map +0 -1
  386. package/dist/devices-hap/robotvacuumcleaner.js +0 -523
  387. package/dist/devices-hap/robotvacuumcleaner.js.map +0 -1
  388. package/dist/devices-hap/waterdetector.d.ts +0 -41
  389. package/dist/devices-hap/waterdetector.d.ts.map +0 -1
  390. package/dist/devices-hap/waterdetector.js +0 -356
  391. package/dist/devices-hap/waterdetector.js.map +0 -1
  392. package/dist/devices-matter/BaseMatterAccessory.d.ts +0 -78
  393. package/dist/devices-matter/BaseMatterAccessory.d.ts.map +0 -1
  394. package/dist/devices-matter/BaseMatterAccessory.js +0 -244
  395. package/dist/devices-matter/BaseMatterAccessory.js.map +0 -1
  396. package/dist/devices-matter/ColorLightAccessory.d.ts +0 -20
  397. package/dist/devices-matter/ColorLightAccessory.d.ts.map +0 -1
  398. package/dist/devices-matter/ColorLightAccessory.js +0 -95
  399. package/dist/devices-matter/ColorLightAccessory.js.map +0 -1
  400. package/dist/devices-matter/ColorTemperatureLightAccessory.d.ts +0 -18
  401. package/dist/devices-matter/ColorTemperatureLightAccessory.d.ts.map +0 -1
  402. package/dist/devices-matter/ColorTemperatureLightAccessory.js +0 -76
  403. package/dist/devices-matter/ColorTemperatureLightAccessory.js.map +0 -1
  404. package/dist/devices-matter/ContactSensorAccessory.d.ts +0 -12
  405. package/dist/devices-matter/ContactSensorAccessory.d.ts.map +0 -1
  406. package/dist/devices-matter/ContactSensorAccessory.js +0 -34
  407. package/dist/devices-matter/ContactSensorAccessory.js.map +0 -1
  408. package/dist/devices-matter/DimmableLightAccessory.d.ts +0 -58
  409. package/dist/devices-matter/DimmableLightAccessory.d.ts.map +0 -1
  410. package/dist/devices-matter/DimmableLightAccessory.js +0 -167
  411. package/dist/devices-matter/DimmableLightAccessory.js.map +0 -1
  412. package/dist/devices-matter/DoorLockAccessory.d.ts +0 -14
  413. package/dist/devices-matter/DoorLockAccessory.d.ts.map +0 -1
  414. package/dist/devices-matter/DoorLockAccessory.js +0 -50
  415. package/dist/devices-matter/DoorLockAccessory.js.map +0 -1
  416. package/dist/devices-matter/ExtendedColorLightAccessory.d.ts +0 -21
  417. package/dist/devices-matter/ExtendedColorLightAccessory.d.ts.map +0 -1
  418. package/dist/devices-matter/ExtendedColorLightAccessory.js +0 -106
  419. package/dist/devices-matter/ExtendedColorLightAccessory.js.map +0 -1
  420. package/dist/devices-matter/FanAccessory.d.ts +0 -16
  421. package/dist/devices-matter/FanAccessory.d.ts.map +0 -1
  422. package/dist/devices-matter/FanAccessory.js +0 -81
  423. package/dist/devices-matter/FanAccessory.js.map +0 -1
  424. package/dist/devices-matter/HumiditySensorAccessory.d.ts +0 -12
  425. package/dist/devices-matter/HumiditySensorAccessory.d.ts.map +0 -1
  426. package/dist/devices-matter/HumiditySensorAccessory.js +0 -34
  427. package/dist/devices-matter/HumiditySensorAccessory.js.map +0 -1
  428. package/dist/devices-matter/LeakSensorAccessory.d.ts +0 -12
  429. package/dist/devices-matter/LeakSensorAccessory.d.ts.map +0 -1
  430. package/dist/devices-matter/LeakSensorAccessory.js +0 -33
  431. package/dist/devices-matter/LeakSensorAccessory.js.map +0 -1
  432. package/dist/devices-matter/LightSensorAccessory.d.ts +0 -12
  433. package/dist/devices-matter/LightSensorAccessory.d.ts.map +0 -1
  434. package/dist/devices-matter/LightSensorAccessory.js +0 -34
  435. package/dist/devices-matter/LightSensorAccessory.js.map +0 -1
  436. package/dist/devices-matter/OccupancySensorAccessory.d.ts +0 -12
  437. package/dist/devices-matter/OccupancySensorAccessory.d.ts.map +0 -1
  438. package/dist/devices-matter/OccupancySensorAccessory.js +0 -39
  439. package/dist/devices-matter/OccupancySensorAccessory.js.map +0 -1
  440. package/dist/devices-matter/OnOffLightAccessory.d.ts +0 -38
  441. package/dist/devices-matter/OnOffLightAccessory.d.ts.map +0 -1
  442. package/dist/devices-matter/OnOffLightAccessory.js +0 -110
  443. package/dist/devices-matter/OnOffLightAccessory.js.map +0 -1
  444. package/dist/devices-matter/OnOffOutletAccessory.d.ts +0 -14
  445. package/dist/devices-matter/OnOffOutletAccessory.d.ts.map +0 -1
  446. package/dist/devices-matter/OnOffOutletAccessory.js +0 -43
  447. package/dist/devices-matter/OnOffOutletAccessory.js.map +0 -1
  448. package/dist/devices-matter/OnOffSwitchAccessory.d.ts +0 -14
  449. package/dist/devices-matter/OnOffSwitchAccessory.d.ts.map +0 -1
  450. package/dist/devices-matter/OnOffSwitchAccessory.js +0 -42
  451. package/dist/devices-matter/OnOffSwitchAccessory.js.map +0 -1
  452. package/dist/devices-matter/RoboticVacuumAccessory.d.ts +0 -68
  453. package/dist/devices-matter/RoboticVacuumAccessory.d.ts.map +0 -1
  454. package/dist/devices-matter/RoboticVacuumAccessory.js +0 -334
  455. package/dist/devices-matter/RoboticVacuumAccessory.js.map +0 -1
  456. package/dist/devices-matter/SmokeCOAlarmAccessory.d.ts +0 -11
  457. package/dist/devices-matter/SmokeCOAlarmAccessory.d.ts.map +0 -1
  458. package/dist/devices-matter/SmokeCOAlarmAccessory.js +0 -49
  459. package/dist/devices-matter/SmokeCOAlarmAccessory.js.map +0 -1
  460. package/dist/devices-matter/TemperatureSensorAccessory.d.ts +0 -12
  461. package/dist/devices-matter/TemperatureSensorAccessory.d.ts.map +0 -1
  462. package/dist/devices-matter/TemperatureSensorAccessory.js +0 -36
  463. package/dist/devices-matter/TemperatureSensorAccessory.js.map +0 -1
  464. package/dist/devices-matter/ThermostatAccessory.d.ts +0 -19
  465. package/dist/devices-matter/ThermostatAccessory.d.ts.map +0 -1
  466. package/dist/devices-matter/ThermostatAccessory.js +0 -95
  467. package/dist/devices-matter/ThermostatAccessory.js.map +0 -1
  468. package/dist/devices-matter/VenetianBlindAccessory.d.ts +0 -19
  469. package/dist/devices-matter/VenetianBlindAccessory.d.ts.map +0 -1
  470. package/dist/devices-matter/VenetianBlindAccessory.js +0 -99
  471. package/dist/devices-matter/VenetianBlindAccessory.js.map +0 -1
  472. package/dist/devices-matter/WindowBlindAccessory.d.ts +0 -17
  473. package/dist/devices-matter/WindowBlindAccessory.d.ts.map +0 -1
  474. package/dist/devices-matter/WindowBlindAccessory.js +0 -80
  475. package/dist/devices-matter/WindowBlindAccessory.js.map +0 -1
  476. package/dist/devices-matter/custom/PowerStripAccessory.d.ts +0 -97
  477. package/dist/devices-matter/custom/PowerStripAccessory.d.ts.map +0 -1
  478. package/dist/devices-matter/custom/PowerStripAccessory.js +0 -265
  479. package/dist/devices-matter/custom/PowerStripAccessory.js.map +0 -1
  480. package/dist/devices-matter/custom/index.d.ts +0 -8
  481. package/dist/devices-matter/custom/index.d.ts.map +0 -1
  482. package/dist/devices-matter/custom/index.js +0 -8
  483. package/dist/devices-matter/custom/index.js.map +0 -1
  484. package/dist/devices-matter/index.d.ts +0 -29
  485. package/dist/devices-matter/index.d.ts.map +0 -1
  486. package/dist/devices-matter/index.js +0 -28
  487. package/dist/devices-matter/index.js.map +0 -1
  488. package/dist/index.test.d.ts +0 -2
  489. package/dist/index.test.d.ts.map +0 -1
  490. package/dist/index.test.js +0 -19
  491. package/dist/index.test.js.map +0 -1
  492. package/dist/irdevice/airconditioner.d.ts +0 -61
  493. package/dist/irdevice/airconditioner.d.ts.map +0 -1
  494. package/dist/irdevice/airconditioner.js +0 -472
  495. package/dist/irdevice/airconditioner.js.map +0 -1
  496. package/dist/irdevice/airpurifier.d.ts +0 -50
  497. package/dist/irdevice/airpurifier.d.ts.map +0 -1
  498. package/dist/irdevice/airpurifier.js +0 -213
  499. package/dist/irdevice/airpurifier.js.map +0 -1
  500. package/dist/irdevice/camera.d.ts +0 -32
  501. package/dist/irdevice/camera.d.ts.map +0 -1
  502. package/dist/irdevice/camera.js +0 -107
  503. package/dist/irdevice/camera.js.map +0 -1
  504. package/dist/irdevice/fan.d.ts +0 -36
  505. package/dist/irdevice/fan.d.ts.map +0 -1
  506. package/dist/irdevice/fan.js +0 -200
  507. package/dist/irdevice/fan.js.map +0 -1
  508. package/dist/irdevice/irdevice.d.ts +0 -68
  509. package/dist/irdevice/irdevice.d.ts.map +0 -1
  510. package/dist/irdevice/irdevice.js +0 -398
  511. package/dist/irdevice/irdevice.js.map +0 -1
  512. package/dist/irdevice/light.d.ts +0 -36
  513. package/dist/irdevice/light.d.ts.map +0 -1
  514. package/dist/irdevice/light.js +0 -206
  515. package/dist/irdevice/light.js.map +0 -1
  516. package/dist/irdevice/other.d.ts +0 -57
  517. package/dist/irdevice/other.d.ts.map +0 -1
  518. package/dist/irdevice/other.js +0 -778
  519. package/dist/irdevice/other.js.map +0 -1
  520. package/dist/irdevice/tv.d.ts +0 -45
  521. package/dist/irdevice/tv.d.ts.map +0 -1
  522. package/dist/irdevice/tv.js +0 -327
  523. package/dist/irdevice/tv.js.map +0 -1
  524. package/dist/irdevice/vacuumcleaner.d.ts +0 -28
  525. package/dist/irdevice/vacuumcleaner.d.ts.map +0 -1
  526. package/dist/irdevice/vacuumcleaner.js +0 -104
  527. package/dist/irdevice/vacuumcleaner.js.map +0 -1
  528. package/dist/irdevice/waterheater.d.ts +0 -30
  529. package/dist/irdevice/waterheater.d.ts.map +0 -1
  530. package/dist/irdevice/waterheater.js +0 -105
  531. package/dist/irdevice/waterheater.js.map +0 -1
  532. package/dist/platform-hap.d.ts +0 -145
  533. package/dist/platform-hap.d.ts.map +0 -1
  534. package/dist/platform-hap.js +0 -2823
  535. package/dist/platform-hap.js.map +0 -1
  536. package/dist/platform-matter.d.ts +0 -131
  537. package/dist/platform-matter.d.ts.map +0 -1
  538. package/dist/platform-matter.js +0 -1002
  539. package/dist/platform-matter.js.map +0 -1
  540. package/dist/utils.test.d.ts +0 -2
  541. package/dist/utils.test.d.ts.map +0 -1
  542. package/dist/utils.test.js +0 -95
  543. package/dist/utils.test.js.map +0 -1
  544. package/dist/verifyconfig.test.d.ts +0 -2
  545. package/dist/verifyconfig.test.d.ts.map +0 -1
  546. package/dist/verifyconfig.test.js +0 -167
  547. package/dist/verifyconfig.test.js.map +0 -1
  548. package/src/baseMatterAccessory.test.ts +0 -88
  549. package/src/custom.d.ts +0 -7
  550. package/src/devices-hap/airpurifier.ts +0 -563
  551. package/src/devices-hap/blindtilt.ts +0 -1049
  552. package/src/devices-hap/bot.ts +0 -900
  553. package/src/devices-hap/ceilinglight.ts +0 -742
  554. package/src/devices-hap/colorbulb.ts +0 -904
  555. package/src/devices-hap/contact.ts +0 -457
  556. package/src/devices-hap/curtain.ts +0 -944
  557. package/src/devices-hap/device.ts +0 -884
  558. package/src/devices-hap/fan.ts +0 -711
  559. package/src/devices-hap/hub.ts +0 -439
  560. package/src/devices-hap/humidifier.ts +0 -669
  561. package/src/devices-hap/iosensor.ts +0 -427
  562. package/src/devices-hap/lightstrip.ts +0 -836
  563. package/src/devices-hap/lock.ts +0 -620
  564. package/src/devices-hap/meter.ts +0 -426
  565. package/src/devices-hap/meterplus.ts +0 -430
  566. package/src/devices-hap/meterpro.ts +0 -522
  567. package/src/devices-hap/motion.ts +0 -390
  568. package/src/devices-hap/plug.ts +0 -423
  569. package/src/devices-hap/relayswitch.ts +0 -727
  570. package/src/devices-hap/robotvacuumcleaner.ts +0 -568
  571. package/src/devices-hap/waterdetector.ts +0 -400
  572. package/src/devices-matter/BaseMatterAccessory.ts +0 -273
  573. package/src/devices-matter/ColorLightAccessory.ts +0 -110
  574. package/src/devices-matter/ColorTemperatureLightAccessory.ts +0 -90
  575. package/src/devices-matter/ContactSensorAccessory.ts +0 -41
  576. package/src/devices-matter/DimmableLightAccessory.ts +0 -192
  577. package/src/devices-matter/DoorLockAccessory.ts +0 -60
  578. package/src/devices-matter/ExtendedColorLightAccessory.ts +0 -122
  579. package/src/devices-matter/FanAccessory.ts +0 -95
  580. package/src/devices-matter/HumiditySensorAccessory.ts +0 -41
  581. package/src/devices-matter/LeakSensorAccessory.ts +0 -40
  582. package/src/devices-matter/LightSensorAccessory.ts +0 -41
  583. package/src/devices-matter/OccupancySensorAccessory.ts +0 -48
  584. package/src/devices-matter/OnOffLightAccessory.ts +0 -125
  585. package/src/devices-matter/OnOffOutletAccessory.ts +0 -51
  586. package/src/devices-matter/OnOffSwitchAccessory.ts +0 -51
  587. package/src/devices-matter/RoboticVacuumAccessory.ts +0 -407
  588. package/src/devices-matter/SmokeCOAlarmAccessory.ts +0 -59
  589. package/src/devices-matter/TemperatureSensorAccessory.ts +0 -43
  590. package/src/devices-matter/ThermostatAccessory.ts +0 -110
  591. package/src/devices-matter/VenetianBlindAccessory.ts +0 -115
  592. package/src/devices-matter/WindowBlindAccessory.ts +0 -92
  593. package/src/devices-matter/custom/PowerStripAccessory.ts +0 -309
  594. package/src/devices-matter/custom/index.ts +0 -8
  595. package/src/devices-matter/index.ts +0 -29
  596. package/src/index.test.ts +0 -24
  597. package/src/irdevice/airconditioner.ts +0 -533
  598. package/src/irdevice/airpurifier.ts +0 -252
  599. package/src/irdevice/camera.ts +0 -129
  600. package/src/irdevice/fan.ts +0 -226
  601. package/src/irdevice/irdevice.ts +0 -435
  602. package/src/irdevice/light.ts +0 -246
  603. package/src/irdevice/other.ts +0 -790
  604. package/src/irdevice/tv.ts +0 -378
  605. package/src/irdevice/vacuumcleaner.ts +0 -126
  606. package/src/irdevice/waterheater.ts +0 -127
  607. package/src/platform-hap.ts +0 -2952
  608. package/src/platform-matter.ts +0 -1129
  609. package/src/utils.test.ts +0 -96
  610. package/src/verifyconfig.test.ts +0 -198
@@ -0,0 +1,6 @@
1
+ import './types.js';
2
+ export declare function toastSuccess(message: string, title?: string): void;
3
+ export declare function toastError(message: string, title?: string): void;
4
+ export declare function toastWarning(message: string, title?: string): void;
5
+ export declare function toastInfo(message: string, title?: string): void;
6
+ //# sourceMappingURL=toast.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"toast.d.ts","sourceRoot":"","sources":["../../../../src/homebridge-ui/public/js/toast.ts"],"names":[],"mappings":"AAAA,OAAO,YAAY,CAAA;AAsBnB,wBAAgB,YAAY,CAAC,OAAO,EAAE,MAAM,EAAE,KAAK,CAAC,EAAE,MAAM,GAAG,IAAI,CAElE;AAED,wBAAgB,UAAU,CAAC,OAAO,EAAE,MAAM,EAAE,KAAK,CAAC,EAAE,MAAM,GAAG,IAAI,CAEhE;AAED,wBAAgB,YAAY,CAAC,OAAO,EAAE,MAAM,EAAE,KAAK,CAAC,EAAE,MAAM,GAAG,IAAI,CAElE;AAED,wBAAgB,SAAS,CAAC,OAAO,EAAE,MAAM,EAAE,KAAK,CAAC,EAAE,MAAM,GAAG,IAAI,CAE/D"}
@@ -0,0 +1,29 @@
1
+ import './types.js';
2
+ import { uiLog } from './logger.js';
3
+ function showToast(method, message, title = 'SwitchBot') {
4
+ try {
5
+ const toast = homebridge?.toast;
6
+ const fn = toast?.[method];
7
+ if (typeof fn === 'function') {
8
+ fn(message, title);
9
+ return;
10
+ }
11
+ uiLog.info(`[Toast:${method}] ${title} - ${message}`);
12
+ }
13
+ catch (e) {
14
+ uiLog.warn(`Toast ${method} failed:`, e);
15
+ }
16
+ }
17
+ export function toastSuccess(message, title) {
18
+ showToast('success', message, title);
19
+ }
20
+ export function toastError(message, title) {
21
+ showToast('error', message, title);
22
+ }
23
+ export function toastWarning(message, title) {
24
+ showToast('warning', message, title);
25
+ }
26
+ export function toastInfo(message, title) {
27
+ showToast('info', message, title);
28
+ }
29
+ //# sourceMappingURL=toast.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"toast.js","sourceRoot":"","sources":["../../../../src/homebridge-ui/public/js/toast.ts"],"names":[],"mappings":"AAAA,OAAO,YAAY,CAAA;AACnB,OAAO,EAAE,KAAK,EAAE,MAAM,aAAa,CAAA;AAEnC,SAAS,SAAS,CAChB,MAAgD,EAChD,OAAe,EACf,KAAK,GAAG,WAAW;IAEnB,IAAI,CAAC;QACH,MAAM,KAAK,GAAG,UAAU,EAAE,KAAK,CAAA;QAC/B,MAAM,EAAE,GAAG,KAAK,EAAE,CAAC,MAAM,CAAC,CAAA;QAC1B,IAAI,OAAO,EAAE,KAAK,UAAU,EAAE,CAAC;YAC7B,EAAE,CAAC,OAAO,EAAE,KAAK,CAAC,CAAA;YAClB,OAAM;QACR,CAAC;QAED,KAAK,CAAC,IAAI,CAAC,UAAU,MAAM,KAAK,KAAK,MAAM,OAAO,EAAE,CAAC,CAAA;IACvD,CAAC;IAAC,OAAO,CAAC,EAAE,CAAC;QACX,KAAK,CAAC,IAAI,CAAC,SAAS,MAAM,UAAU,EAAE,CAAC,CAAC,CAAA;IAC1C,CAAC;AACH,CAAC;AAED,MAAM,UAAU,YAAY,CAAC,OAAe,EAAE,KAAc;IAC1D,SAAS,CAAC,SAAS,EAAE,OAAO,EAAE,KAAK,CAAC,CAAA;AACtC,CAAC;AAED,MAAM,UAAU,UAAU,CAAC,OAAe,EAAE,KAAc;IACxD,SAAS,CAAC,OAAO,EAAE,OAAO,EAAE,KAAK,CAAC,CAAA;AACpC,CAAC;AAED,MAAM,UAAU,YAAY,CAAC,OAAe,EAAE,KAAc;IAC1D,SAAS,CAAC,SAAS,EAAE,OAAO,EAAE,KAAK,CAAC,CAAA;AACtC,CAAC;AAED,MAAM,UAAU,SAAS,CAAC,OAAe,EAAE,KAAc;IACvD,SAAS,CAAC,MAAM,EAAE,OAAO,EAAE,KAAK,CAAC,CAAA;AACnC,CAAC"}
@@ -0,0 +1,37 @@
1
+ import './types.js'
2
+ import { uiLog } from './logger.js'
3
+
4
+ function showToast(
5
+ method: 'success' | 'error' | 'warning' | 'info',
6
+ message: string,
7
+ title = 'SwitchBot',
8
+ ): void {
9
+ try {
10
+ const toast = homebridge?.toast
11
+ const fn = toast?.[method]
12
+ if (typeof fn === 'function') {
13
+ fn(message, title)
14
+ return
15
+ }
16
+
17
+ uiLog.info(`[Toast:${method}] ${title} - ${message}`)
18
+ } catch (e) {
19
+ uiLog.warn(`Toast ${method} failed:`, e)
20
+ }
21
+ }
22
+
23
+ export function toastSuccess(message: string, title?: string): void {
24
+ showToast('success', message, title)
25
+ }
26
+
27
+ export function toastError(message: string, title?: string): void {
28
+ showToast('error', message, title)
29
+ }
30
+
31
+ export function toastWarning(message: string, title?: string): void {
32
+ showToast('warning', message, title)
33
+ }
34
+
35
+ export function toastInfo(message: string, title?: string): void {
36
+ showToast('info', message, title)
37
+ }
@@ -0,0 +1,23 @@
1
+ declare global {
2
+ interface HomebridgeToastApi {
3
+ success?: (message: string, title?: string) => void;
4
+ error?: (message: string, title?: string) => void;
5
+ warning?: (message: string, title?: string) => void;
6
+ info?: (message: string, title?: string) => void;
7
+ }
8
+ interface HomebridgePluginUiAPI {
9
+ request: (endpoint: string, params?: any) => Promise<any>;
10
+ getPluginConfig?: () => Promise<any[]>;
11
+ updatePluginConfig?: (config: any[]) => Promise<void>;
12
+ savePluginConfig?: () => Promise<void>;
13
+ closeSettings?: () => void;
14
+ showSpinner?: () => void;
15
+ hideSpinner?: () => void;
16
+ disableSaveButton?: () => void;
17
+ enableSaveButton?: () => void;
18
+ toast?: HomebridgeToastApi;
19
+ }
20
+ let homebridge: HomebridgePluginUiAPI;
21
+ }
22
+ export {};
23
+ //# sourceMappingURL=types.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../../../src/homebridge-ui/public/js/types.ts"],"names":[],"mappings":"AACA,OAAO,CAAC,MAAM,CAAC;IACb,UAAU,kBAAkB;QAC1B,OAAO,CAAC,EAAE,CAAC,OAAO,EAAE,MAAM,EAAE,KAAK,CAAC,EAAE,MAAM,KAAK,IAAI,CAAA;QACnD,KAAK,CAAC,EAAE,CAAC,OAAO,EAAE,MAAM,EAAE,KAAK,CAAC,EAAE,MAAM,KAAK,IAAI,CAAA;QACjD,OAAO,CAAC,EAAE,CAAC,OAAO,EAAE,MAAM,EAAE,KAAK,CAAC,EAAE,MAAM,KAAK,IAAI,CAAA;QACnD,IAAI,CAAC,EAAE,CAAC,OAAO,EAAE,MAAM,EAAE,KAAK,CAAC,EAAE,MAAM,KAAK,IAAI,CAAA;KACjD;IAED,UAAU,qBAAqB;QAC7B,OAAO,EAAE,CAAC,QAAQ,EAAE,MAAM,EAAE,MAAM,CAAC,EAAE,GAAG,KAAK,OAAO,CAAC,GAAG,CAAC,CAAA;QACzD,eAAe,CAAC,EAAE,MAAM,OAAO,CAAC,GAAG,EAAE,CAAC,CAAA;QACtC,kBAAkB,CAAC,EAAE,CAAC,MAAM,EAAE,GAAG,EAAE,KAAK,OAAO,CAAC,IAAI,CAAC,CAAA;QACrD,gBAAgB,CAAC,EAAE,MAAM,OAAO,CAAC,IAAI,CAAC,CAAA;QACtC,aAAa,CAAC,EAAE,MAAM,IAAI,CAAA;QAC1B,WAAW,CAAC,EAAE,MAAM,IAAI,CAAA;QACxB,WAAW,CAAC,EAAE,MAAM,IAAI,CAAA;QACxB,iBAAiB,CAAC,EAAE,MAAM,IAAI,CAAA;QAC9B,gBAAgB,CAAC,EAAE,MAAM,IAAI,CAAA;QAC7B,KAAK,CAAC,EAAE,kBAAkB,CAAA;KAC3B;IAED,IAAI,UAAU,EAAE,qBAAqB,CAAA;CACtC;AAED,OAAO,EAAE,CAAA"}
@@ -0,0 +1,2 @@
1
+ export {};
2
+ //# sourceMappingURL=types.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"types.js","sourceRoot":"","sources":["../../../../src/homebridge-ui/public/js/types.ts"],"names":[],"mappings":""}
@@ -0,0 +1,26 @@
1
+ // Global homebridge API type declarations
2
+ declare global {
3
+ interface HomebridgeToastApi {
4
+ success?: (message: string, title?: string) => void
5
+ error?: (message: string, title?: string) => void
6
+ warning?: (message: string, title?: string) => void
7
+ info?: (message: string, title?: string) => void
8
+ }
9
+
10
+ interface HomebridgePluginUiAPI {
11
+ request: (endpoint: string, params?: any) => Promise<any>
12
+ getPluginConfig?: () => Promise<any[]>
13
+ updatePluginConfig?: (config: any[]) => Promise<void>
14
+ savePluginConfig?: () => Promise<void>
15
+ closeSettings?: () => void
16
+ showSpinner?: () => void
17
+ hideSpinner?: () => void
18
+ disableSaveButton?: () => void
19
+ enableSaveButton?: () => void
20
+ toast?: HomebridgeToastApi
21
+ }
22
+
23
+ let homebridge: HomebridgePluginUiAPI
24
+ }
25
+
26
+ export {}
@@ -1,43 +1,11 @@
1
- import fs from 'node:fs';
2
1
  import { HomebridgePluginUiServer } from '@homebridge/plugin-ui-utils';
3
- class PluginUiServer extends HomebridgePluginUiServer {
4
- constructor() {
5
- super();
6
- /*
7
- A native method getCachedAccessories() was introduced in config-ui-x v4.37.0
8
- The following is for users who have a lower version of config-ui-x
9
- */
10
- this.onRequest('getCachedAccessories', () => {
11
- try {
12
- const plugin = 'homebridge-switchbot';
13
- const devicesToReturn = [];
14
- // The path and file of the cached accessories
15
- const accFile = `${this.homebridgeStoragePath}/accessories/cachedAccessories`;
16
- // Check the file exists
17
- if (fs.existsSync(accFile)) {
18
- // read the cached accessories file
19
- const cachedAccessories = JSON.parse(fs.readFileSync(accFile, 'utf8'));
20
- cachedAccessories.forEach((accessory) => {
21
- // Check the accessory is from this plugin
22
- if (accessory.plugin === plugin) {
23
- // Add the cached accessory to the array
24
- devicesToReturn.push(accessory.accessory);
25
- }
26
- });
27
- }
28
- // Return the array
29
- return devicesToReturn;
30
- }
31
- catch {
32
- // Just return an empty accessory list in case of any errors
33
- return [];
34
- }
35
- });
36
- this.ready();
37
- }
38
- }
39
- function startPluginUiServer() {
40
- return new PluginUiServer();
41
- }
42
- startPluginUiServer();
2
+ import { registerConfigEndpoints } from './endpoints/config.js';
3
+ import { registerDeviceEndpoints } from './endpoints/devices.js';
4
+ import { registerDiscoveryEndpoint } from './endpoints/discovery.js';
5
+ const server = new HomebridgePluginUiServer();
6
+ // Register all endpoints
7
+ registerConfigEndpoints(server);
8
+ registerDiscoveryEndpoint(server);
9
+ registerDeviceEndpoints(server);
10
+ server.ready();
43
11
  //# sourceMappingURL=server.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"server.js","sourceRoot":"","sources":["../../src/homebridge-ui/server.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,SAAS,CAAA;AAExB,OAAO,EAAE,wBAAwB,EAAE,MAAM,6BAA6B,CAAA;AAEtE,MAAM,cAAe,SAAQ,wBAAwB;IACnD;QACE,KAAK,EAAE,CAAA;QACP;;;UAGE;QACF,IAAI,CAAC,SAAS,CAAC,sBAAsB,EAAE,GAAG,EAAE;YAC1C,IAAI,CAAC;gBACH,MAAM,MAAM,GAAG,sBAAsB,CAAA;gBACrC,MAAM,eAAe,GAAG,EAAE,CAAA;gBAE1B,8CAA8C;gBAC9C,MAAM,OAAO,GAAG,GAAG,IAAI,CAAC,qBAAqB,gCAAgC,CAAA;gBAE7E,wBAAwB;gBACxB,IAAI,EAAE,CAAC,UAAU,CAAC,OAAO,CAAC,EAAE,CAAC;oBAC3B,mCAAmC;oBACnC,MAAM,iBAAiB,GAAU,IAAI,CAAC,KAAK,CAAC,EAAE,CAAC,YAAY,CAAC,OAAO,EAAE,MAAM,CAAC,CAAC,CAAA;oBAE7E,iBAAiB,CAAC,OAAO,CAAC,CAAC,SAAc,EAAE,EAAE;wBAC3C,0CAA0C;wBAC1C,IAAI,SAAS,CAAC,MAAM,KAAK,MAAM,EAAE,CAAC;4BAChC,wCAAwC;4BACxC,eAAe,CAAC,IAAI,CAAC,SAAS,CAAC,SAAkB,CAAC,CAAA;wBACpD,CAAC;oBACH,CAAC,CAAC,CAAA;gBACJ,CAAC;gBACD,mBAAmB;gBACnB,OAAO,eAAe,CAAA;YACxB,CAAC;YAAC,MAAM,CAAC;gBACP,4DAA4D;gBAC5D,OAAO,EAAE,CAAA;YACX,CAAC;QACH,CAAC,CAAC,CAAA;QACF,IAAI,CAAC,KAAK,EAAE,CAAA;IACd,CAAC;CACF;AAED,SAAS,mBAAmB;IAC1B,OAAO,IAAI,cAAc,EAAE,CAAA;AAC7B,CAAC;AAED,mBAAmB,EAAE,CAAA"}
1
+ {"version":3,"file":"server.js","sourceRoot":"","sources":["../../src/homebridge-ui/server.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,wBAAwB,EAAE,MAAM,6BAA6B,CAAA;AAEtE,OAAO,EAAE,uBAAuB,EAAE,MAAM,uBAAuB,CAAA;AAC/D,OAAO,EAAE,uBAAuB,EAAE,MAAM,wBAAwB,CAAA;AAChE,OAAO,EAAE,yBAAyB,EAAE,MAAM,0BAA0B,CAAA;AAEpE,MAAM,MAAM,GAAG,IAAI,wBAAwB,EAAE,CAAA;AAE7C,yBAAyB;AACzB,uBAAuB,CAAC,MAAM,CAAC,CAAA;AAC/B,yBAAyB,CAAC,MAAM,CAAC,CAAA;AACjC,uBAAuB,CAAC,MAAM,CAAC,CAAA;AAE/B,MAAM,CAAC,KAAK,EAAE,CAAA"}
@@ -0,0 +1,35 @@
1
+ import type { HomebridgePluginUiServer } from '@homebridge/plugin-ui-utils';
2
+ export declare const SWITCHBOT_PLATFORM_REGEX: RegExp;
3
+ /**
4
+ * Get reference to the devices array in platform config
5
+ */
6
+ export declare function getDevicesRef(platform: any): any[];
7
+ /**
8
+ * Get all device arrays from platform config
9
+ */
10
+ export declare function getDeviceArrays(platform: any): any[][];
11
+ /**
12
+ * Get all unique devices from platform config
13
+ */
14
+ export declare function getAllDevices(platform: any): any[];
15
+ /**
16
+ * Get credential from platform config
17
+ */
18
+ export declare function getCredential(platform: any, key: 'openApiToken' | 'openApiSecret'): string | undefined;
19
+ /**
20
+ * Set credential in platform config
21
+ */
22
+ export declare function setCredential(platform: any, key: 'openApiToken' | 'openApiSecret', value: string): void;
23
+ /**
24
+ * Find and parse the SwitchBot platform config from Homebridge config file
25
+ */
26
+ export declare function getSwitchBotPlatformConfig(server: HomebridgePluginUiServer): Promise<{
27
+ platform: any;
28
+ cfg: any;
29
+ cfgPath: string;
30
+ }>;
31
+ /**
32
+ * Save the Homebridge config file
33
+ */
34
+ export declare function saveConfig(cfgPath: string, cfg: any): Promise<void>;
35
+ //# sourceMappingURL=config-parser.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"config-parser.d.ts","sourceRoot":"","sources":["../../../src/homebridge-ui/utils/config-parser.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,wBAAwB,EAAE,MAAM,6BAA6B,CAAA;AAO3E,eAAO,MAAM,wBAAwB,QAAe,CAAA;AAEpD;;GAEG;AACH,wBAAgB,aAAa,CAAC,QAAQ,EAAE,GAAG,GAAG,GAAG,EAAE,CAWlD;AAED;;GAEG;AACH,wBAAgB,eAAe,CAAC,QAAQ,EAAE,GAAG,GAAG,GAAG,EAAE,EAAE,CAGtD;AAED;;GAEG;AACH,wBAAgB,aAAa,CAAC,QAAQ,EAAE,GAAG,GAAG,GAAG,EAAE,CAYlD;AAED;;GAEG;AACH,wBAAgB,aAAa,CAAC,QAAQ,EAAE,GAAG,EAAE,GAAG,EAAE,cAAc,GAAG,eAAe,GAAG,MAAM,GAAG,SAAS,CAEtG;AAED;;GAEG;AACH,wBAAgB,aAAa,CAAC,QAAQ,EAAE,GAAG,EAAE,GAAG,EAAE,cAAc,GAAG,eAAe,EAAE,KAAK,EAAE,MAAM,GAAG,IAAI,CAMvG;AAED;;GAEG;AACH,wBAAsB,0BAA0B,CAAC,MAAM,EAAE,wBAAwB;;;;GA6BhF;AAED;;GAEG;AACH,wBAAsB,UAAU,CAAC,OAAO,EAAE,MAAM,EAAE,GAAG,EAAE,GAAG,GAAG,OAAO,CAAC,IAAI,CAAC,CAEzE"}
@@ -0,0 +1,87 @@
1
+ import fs from 'node:fs/promises';
2
+ import { uiLog } from './logger.js';
3
+ // Module-scope regex pattern to avoid recompilation
4
+ export const SWITCHBOT_PLATFORM_REGEX = /switchbot/i;
5
+ /**
6
+ * Get reference to the devices array in platform config
7
+ */
8
+ export function getDevicesRef(platform) {
9
+ if (!platform || typeof platform !== 'object') {
10
+ return [];
11
+ }
12
+ if (Array.isArray(platform.devices)) {
13
+ return platform.devices;
14
+ }
15
+ platform.devices = [];
16
+ return platform.devices;
17
+ }
18
+ /**
19
+ * Get all device arrays from platform config
20
+ */
21
+ export function getDeviceArrays(platform) {
22
+ const rootDevices = getDevicesRef(platform);
23
+ return [rootDevices];
24
+ }
25
+ /**
26
+ * Get all unique devices from platform config
27
+ */
28
+ export function getAllDevices(platform) {
29
+ const all = getDevicesRef(platform);
30
+ const seen = new Set();
31
+ return all.filter((d) => {
32
+ const id = String(d?.deviceId ?? d?.id ?? '').trim().toLowerCase();
33
+ if (!id || seen.has(id)) {
34
+ return false;
35
+ }
36
+ seen.add(id);
37
+ return true;
38
+ });
39
+ }
40
+ /**
41
+ * Get credential from platform config
42
+ */
43
+ export function getCredential(platform, key) {
44
+ return platform?.[key];
45
+ }
46
+ /**
47
+ * Set credential in platform config
48
+ */
49
+ export function setCredential(platform, key, value) {
50
+ if (!platform || typeof platform !== 'object') {
51
+ return;
52
+ }
53
+ platform[key] = value;
54
+ }
55
+ /**
56
+ * Find and parse the SwitchBot platform config from Homebridge config file
57
+ */
58
+ export async function getSwitchBotPlatformConfig(server) {
59
+ const cfgPath = server.homebridgeConfigPath;
60
+ if (!cfgPath) {
61
+ throw new Error('HOMEBRIDGE_CONFIG_PATH not set');
62
+ }
63
+ const raw = await fs.readFile(cfgPath, 'utf-8');
64
+ const cfg = JSON.parse(raw);
65
+ const platforms = Array.isArray(cfg.platforms) ? cfg.platforms : [];
66
+ const candidates = platforms.filter((p) => {
67
+ const platformName = p.platform || p.name || '';
68
+ return !!platformName && (SWITCHBOT_PLATFORM_REGEX.test(String(platformName)) || String(platformName).toLowerCase() === '@switchbot/homebridge-switchbot');
69
+ });
70
+ uiLog.info(`Found ${candidates.length} SwitchBot candidate(s)`);
71
+ const platform = candidates.find((p) => {
72
+ const name = String(p.platform || '').toLowerCase();
73
+ return name === 'switchbot' || name.includes('switchbot');
74
+ });
75
+ if (!platform) {
76
+ throw new Error('SwitchBot platform not found in config. Please add the plugin configuration first.');
77
+ }
78
+ uiLog.info(`Using SwitchBot platform: ${platform.name || platform.platform || 'SwitchBot'}`);
79
+ return { platform, cfg, cfgPath };
80
+ }
81
+ /**
82
+ * Save the Homebridge config file
83
+ */
84
+ export async function saveConfig(cfgPath, cfg) {
85
+ await fs.writeFile(cfgPath, JSON.stringify(cfg, null, 2), 'utf-8');
86
+ }
87
+ //# sourceMappingURL=config-parser.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"config-parser.js","sourceRoot":"","sources":["../../../src/homebridge-ui/utils/config-parser.ts"],"names":[],"mappings":"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"}
@@ -0,0 +1,35 @@
1
+ export interface DeviceMigrationResult {
2
+ migrated: boolean;
3
+ originalType: string | undefined;
4
+ correctedType: string | null;
5
+ message: string;
6
+ }
7
+ /**
8
+ * Validate and optionally correct a device's configDeviceType
9
+ * @param device Device object from config
10
+ * @param autoCorrect Whether to auto-correct invalid types
11
+ * @returns Migration result with details
12
+ */
13
+ export declare function validateAndMigrateDeviceType(device: any, autoCorrect?: boolean): DeviceMigrationResult;
14
+ /**
15
+ * Validate all devices in config and optionally auto-correct invalid types
16
+ * @param config Configuration object containing devices array
17
+ * @param autoCorrect Whether to auto-correct invalid types
18
+ * @returns Array of migration results with statistics
19
+ */
20
+ export declare function validateAndMigrateConfig(config: any, autoCorrect?: boolean): {
21
+ results: DeviceMigrationResult[];
22
+ statistics: {
23
+ total: number;
24
+ valid: number;
25
+ corrected: number;
26
+ invalid: number;
27
+ };
28
+ warnings: string[];
29
+ };
30
+ /**
31
+ * Get list of all valid device types for error messages
32
+ * @returns Array of valid device types grouped by category
33
+ */
34
+ export declare function getValidDeviceTypesList(): Record<string, readonly string[]>;
35
+ //# sourceMappingURL=device-migration.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"device-migration.d.ts","sourceRoot":"","sources":["../../../src/homebridge-ui/utils/device-migration.ts"],"names":[],"mappings":"AAEA,MAAM,WAAW,qBAAqB;IACpC,QAAQ,EAAE,OAAO,CAAA;IACjB,YAAY,EAAE,MAAM,GAAG,SAAS,CAAA;IAChC,aAAa,EAAE,MAAM,GAAG,IAAI,CAAA;IAC5B,OAAO,EAAE,MAAM,CAAA;CAChB;AAED;;;;;GAKG;AACH,wBAAgB,4BAA4B,CAC1C,MAAM,EAAE,GAAG,EACX,WAAW,UAAQ,GAClB,qBAAqB,CA2CvB;AAED;;;;;GAKG;AACH,wBAAgB,wBAAwB,CACtC,MAAM,EAAE,GAAG,EACX,WAAW,UAAQ,GAClB;IACD,OAAO,EAAE,qBAAqB,EAAE,CAAA;IAChC,UAAU,EAAE;QACV,KAAK,EAAE,MAAM,CAAA;QACb,KAAK,EAAE,MAAM,CAAA;QACb,SAAS,EAAE,MAAM,CAAA;QACjB,OAAO,EAAE,MAAM,CAAA;KAChB,CAAA;IACD,QAAQ,EAAE,MAAM,EAAE,CAAA;CACnB,CAsDA;AAED;;;GAGG;AACH,wBAAgB,uBAAuB,IAAI,MAAM,CAAC,MAAM,EAAE,SAAS,MAAM,EAAE,CAAC,CAE3E"}
@@ -0,0 +1,111 @@
1
+ import { DEVICE_TYPES, isValidDeviceType, normalizeDeviceType } from '../../device-types.js';
2
+ /**
3
+ * Validate and optionally correct a device's configDeviceType
4
+ * @param device Device object from config
5
+ * @param autoCorrect Whether to auto-correct invalid types
6
+ * @returns Migration result with details
7
+ */
8
+ export function validateAndMigrateDeviceType(device, autoCorrect = false) {
9
+ const originalType = device.configDeviceType;
10
+ const deviceId = device.deviceId || device.id || 'unknown';
11
+ // Check if type is valid
12
+ if (isValidDeviceType(originalType)) {
13
+ return {
14
+ migrated: false,
15
+ originalType,
16
+ correctedType: originalType,
17
+ message: `Device "${device.configDeviceName || deviceId}" type is valid`,
18
+ };
19
+ }
20
+ // Try to find a valid mapping
21
+ const correctedType = normalizeDeviceType(originalType);
22
+ if (!correctedType) {
23
+ return {
24
+ migrated: false,
25
+ originalType,
26
+ correctedType: null,
27
+ message: `Device "${device.configDeviceName || deviceId}" has invalid type "${originalType}" with no valid mapping`,
28
+ };
29
+ }
30
+ // Found a valid mapping
31
+ if (autoCorrect) {
32
+ device.configDeviceType = correctedType;
33
+ return {
34
+ migrated: true,
35
+ originalType,
36
+ correctedType,
37
+ message: `Device "${device.configDeviceName || deviceId}" type auto-corrected: "${originalType}" → "${correctedType}"`,
38
+ };
39
+ }
40
+ else {
41
+ return {
42
+ migrated: false,
43
+ originalType,
44
+ correctedType,
45
+ message: `Device "${device.configDeviceName || deviceId}" requires migration: "${originalType}" → "${correctedType}"`,
46
+ };
47
+ }
48
+ }
49
+ /**
50
+ * Validate all devices in config and optionally auto-correct invalid types
51
+ * @param config Configuration object containing devices array
52
+ * @param autoCorrect Whether to auto-correct invalid types
53
+ * @returns Array of migration results with statistics
54
+ */
55
+ export function validateAndMigrateConfig(config, autoCorrect = false) {
56
+ const results = [];
57
+ const warnings = [];
58
+ let validCount = 0;
59
+ let correctedCount = 0;
60
+ let invalidCount = 0;
61
+ if (!config?.devices || !Array.isArray(config.devices)) {
62
+ return {
63
+ results,
64
+ statistics: {
65
+ total: 0,
66
+ valid: 0,
67
+ corrected: 0,
68
+ invalid: 0,
69
+ },
70
+ warnings: ['No devices found in config'],
71
+ };
72
+ }
73
+ for (const device of config.devices) {
74
+ const result = validateAndMigrateDeviceType(device, autoCorrect);
75
+ results.push(result);
76
+ if (!result.originalType || isValidDeviceType(result.originalType)) {
77
+ validCount++;
78
+ }
79
+ else if (result.migrated) {
80
+ correctedCount++;
81
+ }
82
+ else if (result.correctedType) {
83
+ warnings.push(`Device "${device.configDeviceName || device.deviceId}" needs correction: "${result.originalType}" → "${result.correctedType}"`);
84
+ invalidCount++;
85
+ }
86
+ else {
87
+ invalidCount++;
88
+ warnings.push(`Device "${device.configDeviceName || device.deviceId}" has INVALID type "${result.originalType}" with no mapping`);
89
+ }
90
+ }
91
+ // Validation complete - results and warnings are returned via return value
92
+ // Caller (config endpoint) will handle logging/reporting
93
+ return {
94
+ results,
95
+ statistics: {
96
+ total: config.devices.length,
97
+ valid: validCount,
98
+ corrected: correctedCount,
99
+ invalid: invalidCount,
100
+ },
101
+ warnings,
102
+ };
103
+ }
104
+ /**
105
+ * Get list of all valid device types for error messages
106
+ * @returns Array of valid device types grouped by category
107
+ */
108
+ export function getValidDeviceTypesList() {
109
+ return DEVICE_TYPES;
110
+ }
111
+ //# sourceMappingURL=device-migration.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"device-migration.js","sourceRoot":"","sources":["../../../src/homebridge-ui/utils/device-migration.ts"],"names":[],"mappings":"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"}
@@ -0,0 +1,7 @@
1
+ export declare const uiLog: {
2
+ info: (message: string, ...parameters: any[]) => void;
3
+ warn: (message: string, ...parameters: any[]) => void;
4
+ error: (message: string, ...parameters: any[]) => void;
5
+ debug: (message: string, ...parameters: any[]) => void;
6
+ };
7
+ //# sourceMappingURL=logger.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"logger.d.ts","sourceRoot":"","sources":["../../../src/homebridge-ui/utils/logger.ts"],"names":[],"mappings":"AAGA,eAAO,MAAM,KAAK;oBACA,MAAM,iBAAiB,GAAG,EAAE;oBAG5B,MAAM,iBAAiB,GAAG,EAAE;qBAG3B,MAAM,iBAAiB,GAAG,EAAE;qBAG5B,MAAM,iBAAiB,GAAG,EAAE;CAG9C,CAAA"}
@@ -0,0 +1,17 @@
1
+ /* eslint-disable no-console */
2
+ const PREFIX = '[SwitchBot UI/Server]';
3
+ export const uiLog = {
4
+ info: (message, ...parameters) => {
5
+ console.log(PREFIX, message, ...parameters);
6
+ },
7
+ warn: (message, ...parameters) => {
8
+ console.warn(PREFIX, message, ...parameters);
9
+ },
10
+ error: (message, ...parameters) => {
11
+ console.error(PREFIX, message, ...parameters);
12
+ },
13
+ debug: (message, ...parameters) => {
14
+ console.debug(PREFIX, message, ...parameters);
15
+ },
16
+ };
17
+ //# sourceMappingURL=logger.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"logger.js","sourceRoot":"","sources":["../../../src/homebridge-ui/utils/logger.ts"],"names":[],"mappings":"AAAA,+BAA+B;AAC/B,MAAM,MAAM,GAAG,uBAAuB,CAAA;AAEtC,MAAM,CAAC,MAAM,KAAK,GAAG;IACnB,IAAI,EAAE,CAAC,OAAe,EAAE,GAAG,UAAiB,EAAE,EAAE;QAC9C,OAAO,CAAC,GAAG,CAAC,MAAM,EAAE,OAAO,EAAE,GAAG,UAAU,CAAC,CAAA;IAC7C,CAAC;IACD,IAAI,EAAE,CAAC,OAAe,EAAE,GAAG,UAAiB,EAAE,EAAE;QAC9C,OAAO,CAAC,IAAI,CAAC,MAAM,EAAE,OAAO,EAAE,GAAG,UAAU,CAAC,CAAA;IAC9C,CAAC;IACD,KAAK,EAAE,CAAC,OAAe,EAAE,GAAG,UAAiB,EAAE,EAAE;QAC/C,OAAO,CAAC,KAAK,CAAC,MAAM,EAAE,OAAO,EAAE,GAAG,UAAU,CAAC,CAAA;IAC/C,CAAC;IACD,KAAK,EAAE,CAAC,OAAe,EAAE,GAAG,UAAiB,EAAE,EAAE;QAC/C,OAAO,CAAC,KAAK,CAAC,MAAM,EAAE,OAAO,EAAE,GAAG,UAAU,CAAC,CAAA;IAC/C,CAAC;CACF,CAAA"}
package/dist/index.d.ts CHANGED
@@ -1,4 +1,14 @@
1
1
  import type { API } from 'homebridge';
2
+ /**
3
+ * Registers the SwitchBot platform with Homebridge.
4
+ *
5
+ * @param api The Homebridge API instance.
6
+ * @property {string} PLATFORM_NAME - The Homebridge platform name.
7
+ * @property {string} PLUGIN_NAME - The Homebridge plugin name.
8
+ * @property {typeof SwitchBotHAPPlatform} SwitchBotHAPPlatform - The HAP platform class.
9
+ * @property {typeof SwitchBotMatterPlatform} SwitchBotMatterPlatform - The Matter platform class.
10
+ * @property {Function} createPlatformProxy - Factory for the platform proxy constructor.
11
+ */
2
12
  declare const _default: (api: API) => void;
3
13
  export default _default;
4
14
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAIA,OAAO,KAAK,EAAE,GAAG,EAAE,MAAM,YAAY,CAAA;yBAQrB,KAAK,GAAG,KAAG,IAAI;AAA/B,wBAIC"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAIA,OAAO,KAAK,EAAE,GAAG,EAAE,MAAM,YAAY,CAAA;AAOrC;;;;;;;;;GASG;yBACa,KAAK,GAAG,KAAG,IAAI;AAA/B,wBAGC"}
package/dist/index.js CHANGED
@@ -1,10 +1,18 @@
1
- import { SwitchBotHAPPlatform } from './platform-hap.js';
2
- import { SwitchBotMatterPlatform } from './platform-matter.js';
3
1
  import { PLATFORM_NAME, PLUGIN_NAME } from './settings.js';
2
+ import { SwitchBotHAPPlatform } from './SwitchBotHAPPlatform.js';
3
+ import { SwitchBotMatterPlatform } from './SwitchBotMatterPlatform.js';
4
4
  import { createPlatformProxy } from './utils.js';
5
- // Register our platform with homebridge.
5
+ /**
6
+ * Registers the SwitchBot platform with Homebridge.
7
+ *
8
+ * @param api The Homebridge API instance.
9
+ * @property {string} PLATFORM_NAME - The Homebridge platform name.
10
+ * @property {string} PLUGIN_NAME - The Homebridge plugin name.
11
+ * @property {typeof SwitchBotHAPPlatform} SwitchBotHAPPlatform - The HAP platform class.
12
+ * @property {typeof SwitchBotMatterPlatform} SwitchBotMatterPlatform - The Matter platform class.
13
+ * @property {Function} createPlatformProxy - Factory for the platform proxy constructor.
14
+ */
6
15
  export default (api) => {
7
- // Create and register a small proxy that selects the correct platform (HAP or Matter) at runtime.
8
16
  const ProxyCtor = createPlatformProxy(SwitchBotHAPPlatform, SwitchBotMatterPlatform);
9
17
  api.registerPlatform(PLUGIN_NAME, PLATFORM_NAME, ProxyCtor);
10
18
  };
package/dist/index.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAMA,OAAO,EAAE,oBAAoB,EAAE,MAAM,mBAAmB,CAAA;AACxD,OAAO,EAAE,uBAAuB,EAAE,MAAM,sBAAsB,CAAA;AAC9D,OAAO,EAAE,aAAa,EAAE,WAAW,EAAE,MAAM,eAAe,CAAA;AAC1D,OAAO,EAAE,mBAAmB,EAAE,MAAM,YAAY,CAAA;AAEhD,yCAAyC;AACzC,eAAe,CAAC,GAAQ,EAAQ,EAAE;IAChC,kGAAkG;IAClG,MAAM,SAAS,GAAG,mBAAmB,CAAC,oBAAoB,EAAE,uBAAuB,CAAC,CAAA;IACpF,GAAG,CAAC,gBAAgB,CAAC,WAAW,EAAE,aAAa,EAAE,SAAgB,CAAC,CAAA;AACpE,CAAC,CAAA"}
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAMA,OAAO,EAAE,aAAa,EAAE,WAAW,EAAE,MAAM,eAAe,CAAA;AAC1D,OAAO,EAAE,oBAAoB,EAAE,MAAM,2BAA2B,CAAA;AAChE,OAAO,EAAE,uBAAuB,EAAE,MAAM,8BAA8B,CAAA;AACtE,OAAO,EAAE,mBAAmB,EAAE,MAAM,YAAY,CAAA;AAEhD;;;;;;;;;GASG;AACH,eAAe,CAAC,GAAQ,EAAQ,EAAE;IAChC,MAAM,SAAS,GAAG,mBAAmB,CAAC,oBAAoB,EAAE,uBAAuB,CAAC,CAAA;IACpF,GAAG,CAAC,gBAAgB,CAAC,WAAW,EAAE,aAAa,EAAE,SAAgB,CAAC,CAAA;AACpE,CAAC,CAAA"}