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

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (446) hide show
  1. package/.github/ISSUE_TEMPLATE/e2e-verification.md +36 -0
  2. package/.github/workflows/ci.yml +61 -0
  3. package/.github/workflows/manual-e2e.yml +103 -0
  4. package/CHANGELOG.md +35 -0
  5. package/E2E-VERIFICATION.md +121 -0
  6. package/MIGRATION.md +44 -0
  7. package/README.md +56 -3
  8. package/config.schema.json +99 -14823
  9. package/dist/deviceFactory.d.ts +13 -0
  10. package/dist/deviceFactory.d.ts.map +1 -0
  11. package/dist/deviceFactory.js +81 -0
  12. package/dist/deviceFactory.js.map +1 -0
  13. package/dist/devices/deviceBase.d.ts +50 -0
  14. package/dist/devices/deviceBase.d.ts.map +1 -0
  15. package/dist/devices/deviceBase.js +119 -0
  16. package/dist/devices/deviceBase.js.map +1 -0
  17. package/dist/devices/genericDevice.d.ts +283 -0
  18. package/dist/devices/genericDevice.d.ts.map +1 -0
  19. package/dist/devices/genericDevice.js +1035 -0
  20. package/dist/devices/genericDevice.js.map +1 -0
  21. package/dist/homebridge-ui/public/index.html +77 -245
  22. package/dist/homebridge-ui/server.d.ts +3 -1
  23. package/dist/homebridge-ui/server.d.ts.map +1 -1
  24. package/dist/homebridge-ui/server.js +42 -36
  25. package/dist/homebridge-ui/server.js.map +1 -1
  26. package/dist/index.d.ts.map +1 -1
  27. package/dist/index.js +5 -12
  28. package/dist/index.js.map +1 -1
  29. package/dist/platform.d.ts +27 -0
  30. package/dist/platform.d.ts.map +1 -0
  31. package/dist/platform.js +404 -0
  32. package/dist/platform.js.map +1 -0
  33. package/dist/settings.d.ts +10 -249
  34. package/dist/settings.d.ts.map +1 -1
  35. package/dist/settings.js +5 -30
  36. package/dist/settings.js.map +1 -1
  37. package/dist/switchbotClient.d.ts +32 -0
  38. package/dist/switchbotClient.d.ts.map +1 -0
  39. package/dist/switchbotClient.js +259 -0
  40. package/dist/switchbotClient.js.map +1 -0
  41. package/dist/utils.d.ts +39 -50
  42. package/dist/utils.d.ts.map +1 -1
  43. package/dist/utils.js +39 -688
  44. package/dist/utils.js.map +1 -1
  45. package/docs/assets/highlight.css +14 -0
  46. package/docs/assets/icons.js +1 -1
  47. package/docs/assets/icons.svg +1 -1
  48. package/docs/assets/main.js +2 -2
  49. package/docs/assets/style.css +3 -3
  50. package/docs/index.html +77 -13
  51. package/docs/variables/default.html +1 -1
  52. package/package.json +22 -21
  53. package/scripts/e2e/README.md +25 -0
  54. package/scripts/e2e/curtain-e2e.sh +70 -0
  55. package/scripts/e2e/fan-e2e.sh +75 -0
  56. package/scripts/e2e/light-advanced-e2e.sh +97 -0
  57. package/scripts/e2e/light-e2e.sh +75 -0
  58. package/scripts/e2e/list-accessories.sh +19 -0
  59. package/scripts/e2e/lock-e2e.sh +65 -0
  60. package/scripts/generate-matter-maps.js +60 -0
  61. package/scripts/run-e2e-local.sh +14 -0
  62. package/src/deviceFactory.ts +122 -0
  63. package/src/devices/deviceBase.ts +141 -0
  64. package/src/devices/genericDevice.ts +965 -0
  65. package/src/homebridge-ui/public/index.html +77 -245
  66. package/src/homebridge-ui/server.ts +49 -41
  67. package/src/index.ts +5 -13
  68. package/src/platform.ts +395 -0
  69. package/src/settings.ts +12 -277
  70. package/src/switchbotClient.ts +266 -0
  71. package/src/utils.ts +45 -713
  72. package/test/accessory-restore.spec.ts +73 -0
  73. package/test/device-mapping.spec.ts +37 -0
  74. package/test/deviceFactory.spec.ts +18 -0
  75. package/test/e2e/run-e2e.spec.ts +50 -0
  76. package/test/fan-swing.spec.ts +29 -0
  77. package/test/helpers/matter-harness.ts +53 -0
  78. package/test/lock-users.spec.ts +44 -0
  79. package/test/matter-childbridge.spec.ts +55 -0
  80. package/test/matter-descriptors.spec.ts +97 -0
  81. package/test/matter-device-state.spec.ts +101 -0
  82. package/test/matter-integration.spec.ts +70 -0
  83. package/test/platform.integration.spec.ts +55 -0
  84. package/test/switchbot-client-debounce.spec.ts +131 -0
  85. package/test/switchbot-client-openapi.spec.ts +56 -0
  86. package/test/switchbotClient.spec.ts +10 -0
  87. package/test/utils.spec.ts +20 -0
  88. package/vitest.config.ts +7 -0
  89. package/coverage/base.css +0 -224
  90. package/coverage/block-navigation.js +0 -87
  91. package/coverage/clover.xml +0 -15847
  92. package/coverage/coverage-final.json +0 -42
  93. package/coverage/docs/assets/dmt/dmt-component-data.js.html +0 -85
  94. package/coverage/docs/assets/dmt/dmt-components.js.html +0 -286
  95. package/coverage/docs/assets/dmt/index.html +0 -131
  96. package/coverage/docs/assets/hierarchy.js.html +0 -85
  97. package/coverage/docs/assets/icons.js.html +0 -136
  98. package/coverage/docs/assets/index.html +0 -146
  99. package/coverage/docs/assets/main.js.html +0 -265
  100. package/coverage/favicon.png +0 -0
  101. package/coverage/index.html +0 -191
  102. package/coverage/prettify.css +0 -1
  103. package/coverage/prettify.js +0 -2
  104. package/coverage/sort-arrow-sprite.png +0 -0
  105. package/coverage/sorter.js +0 -196
  106. package/coverage/src/device/blindtilt.ts.html +0 -3238
  107. package/coverage/src/device/bot.ts.html +0 -2803
  108. package/coverage/src/device/ceilinglight.ts.html +0 -2338
  109. package/coverage/src/device/colorbulb.ts.html +0 -2824
  110. package/coverage/src/device/contact.ts.html +0 -1465
  111. package/coverage/src/device/curtain.ts.html +0 -2869
  112. package/coverage/src/device/device.ts.html +0 -2500
  113. package/coverage/src/device/fan.ts.html +0 -2242
  114. package/coverage/src/device/hub.ts.html +0 -1408
  115. package/coverage/src/device/humidifier.ts.html +0 -2116
  116. package/coverage/src/device/index.html +0 -416
  117. package/coverage/src/device/iosensor.ts.html +0 -1375
  118. package/coverage/src/device/lightstrip.ts.html +0 -2617
  119. package/coverage/src/device/lock.ts.html +0 -1963
  120. package/coverage/src/device/meter.ts.html +0 -1372
  121. package/coverage/src/device/meterplus.ts.html +0 -1384
  122. package/coverage/src/device/meterpro.ts.html +0 -1618
  123. package/coverage/src/device/motion.ts.html +0 -1264
  124. package/coverage/src/device/plug.ts.html +0 -1372
  125. package/coverage/src/device/relayswitch.ts.html +0 -2284
  126. package/coverage/src/device/robotvacuumcleaner.ts.html +0 -1810
  127. package/coverage/src/device/waterdetector.ts.html +0 -1294
  128. package/coverage/src/homebridge-ui/index.html +0 -116
  129. package/coverage/src/homebridge-ui/server.ts.html +0 -229
  130. package/coverage/src/index.html +0 -161
  131. package/coverage/src/index.ts.html +0 -124
  132. package/coverage/src/irdevice/airconditioner.ts.html +0 -1687
  133. package/coverage/src/irdevice/airpurifier.ts.html +0 -844
  134. package/coverage/src/irdevice/camera.ts.html +0 -475
  135. package/coverage/src/irdevice/fan.ts.html +0 -766
  136. package/coverage/src/irdevice/index.html +0 -251
  137. package/coverage/src/irdevice/irdevice.ts.html +0 -1117
  138. package/coverage/src/irdevice/light.ts.html +0 -826
  139. package/coverage/src/irdevice/other.ts.html +0 -2458
  140. package/coverage/src/irdevice/tv.ts.html +0 -1222
  141. package/coverage/src/irdevice/vacuumcleaner.ts.html +0 -466
  142. package/coverage/src/irdevice/waterheater.ts.html +0 -469
  143. package/coverage/src/platform.ts.html +0 -8776
  144. package/coverage/src/settings.ts.html +0 -934
  145. package/coverage/src/utils.ts.html +0 -2092
  146. package/dist/devices-hap/airpurifier.d.ts +0 -54
  147. package/dist/devices-hap/airpurifier.d.ts.map +0 -1
  148. package/dist/devices-hap/airpurifier.js +0 -527
  149. package/dist/devices-hap/airpurifier.js.map +0 -1
  150. package/dist/devices-hap/blindtilt.d.ts +0 -90
  151. package/dist/devices-hap/blindtilt.d.ts.map +0 -1
  152. package/dist/devices-hap/blindtilt.js +0 -974
  153. package/dist/devices-hap/blindtilt.js.map +0 -1
  154. package/dist/devices-hap/bot.d.ts +0 -102
  155. package/dist/devices-hap/bot.d.ts.map +0 -1
  156. package/dist/devices-hap/bot.js +0 -811
  157. package/dist/devices-hap/bot.js.map +0 -1
  158. package/dist/devices-hap/ceilinglight.d.ts +0 -85
  159. package/dist/devices-hap/ceilinglight.d.ts.map +0 -1
  160. package/dist/devices-hap/ceilinglight.js +0 -701
  161. package/dist/devices-hap/ceilinglight.js.map +0 -1
  162. package/dist/devices-hap/colorbulb.d.ts +0 -88
  163. package/dist/devices-hap/colorbulb.d.ts.map +0 -1
  164. package/dist/devices-hap/colorbulb.js +0 -881
  165. package/dist/devices-hap/colorbulb.js.map +0 -1
  166. package/dist/devices-hap/contact.d.ts +0 -44
  167. package/dist/devices-hap/contact.d.ts.map +0 -1
  168. package/dist/devices-hap/contact.js +0 -409
  169. package/dist/devices-hap/contact.js.map +0 -1
  170. package/dist/devices-hap/curtain.d.ts +0 -73
  171. package/dist/devices-hap/curtain.d.ts.map +0 -1
  172. package/dist/devices-hap/curtain.js +0 -869
  173. package/dist/devices-hap/curtain.js.map +0 -1
  174. package/dist/devices-hap/device.d.ts +0 -98
  175. package/dist/devices-hap/device.d.ts.map +0 -1
  176. package/dist/devices-hap/device.js +0 -749
  177. package/dist/devices-hap/device.js.map +0 -1
  178. package/dist/devices-hap/fan.d.ts +0 -69
  179. package/dist/devices-hap/fan.d.ts.map +0 -1
  180. package/dist/devices-hap/fan.js +0 -649
  181. package/dist/devices-hap/fan.js.map +0 -1
  182. package/dist/devices-hap/hub.d.ts +0 -37
  183. package/dist/devices-hap/hub.d.ts.map +0 -1
  184. package/dist/devices-hap/hub.js +0 -392
  185. package/dist/devices-hap/hub.js.map +0 -1
  186. package/dist/devices-hap/humidifier.d.ts +0 -68
  187. package/dist/devices-hap/humidifier.d.ts.map +0 -1
  188. package/dist/devices-hap/humidifier.js +0 -628
  189. package/dist/devices-hap/humidifier.js.map +0 -1
  190. package/dist/devices-hap/iosensor.d.ts +0 -42
  191. package/dist/devices-hap/iosensor.d.ts.map +0 -1
  192. package/dist/devices-hap/iosensor.js +0 -382
  193. package/dist/devices-hap/iosensor.js.map +0 -1
  194. package/dist/devices-hap/lightstrip.d.ts +0 -79
  195. package/dist/devices-hap/lightstrip.d.ts.map +0 -1
  196. package/dist/devices-hap/lightstrip.js +0 -797
  197. package/dist/devices-hap/lightstrip.js.map +0 -1
  198. package/dist/devices-hap/lock.d.ts +0 -53
  199. package/dist/devices-hap/lock.d.ts.map +0 -1
  200. package/dist/devices-hap/lock.js +0 -561
  201. package/dist/devices-hap/lock.js.map +0 -1
  202. package/dist/devices-hap/meter.d.ts +0 -37
  203. package/dist/devices-hap/meter.d.ts.map +0 -1
  204. package/dist/devices-hap/meter.js +0 -379
  205. package/dist/devices-hap/meter.js.map +0 -1
  206. package/dist/devices-hap/meterplus.d.ts +0 -42
  207. package/dist/devices-hap/meterplus.d.ts.map +0 -1
  208. package/dist/devices-hap/meterplus.js +0 -384
  209. package/dist/devices-hap/meterplus.js.map +0 -1
  210. package/dist/devices-hap/meterpro.d.ts +0 -43
  211. package/dist/devices-hap/meterpro.d.ts.map +0 -1
  212. package/dist/devices-hap/meterpro.js +0 -468
  213. package/dist/devices-hap/meterpro.js.map +0 -1
  214. package/dist/devices-hap/motion.d.ts +0 -42
  215. package/dist/devices-hap/motion.d.ts.map +0 -1
  216. package/dist/devices-hap/motion.js +0 -345
  217. package/dist/devices-hap/motion.js.map +0 -1
  218. package/dist/devices-hap/plug.d.ts +0 -49
  219. package/dist/devices-hap/plug.d.ts.map +0 -1
  220. package/dist/devices-hap/plug.js +0 -395
  221. package/dist/devices-hap/plug.js.map +0 -1
  222. package/dist/devices-hap/relayswitch.d.ts +0 -96
  223. package/dist/devices-hap/relayswitch.d.ts.map +0 -1
  224. package/dist/devices-hap/relayswitch.js +0 -642
  225. package/dist/devices-hap/relayswitch.js.map +0 -1
  226. package/dist/devices-hap/robotvacuumcleaner.d.ts +0 -54
  227. package/dist/devices-hap/robotvacuumcleaner.d.ts.map +0 -1
  228. package/dist/devices-hap/robotvacuumcleaner.js +0 -523
  229. package/dist/devices-hap/robotvacuumcleaner.js.map +0 -1
  230. package/dist/devices-hap/waterdetector.d.ts +0 -41
  231. package/dist/devices-hap/waterdetector.d.ts.map +0 -1
  232. package/dist/devices-hap/waterdetector.js +0 -356
  233. package/dist/devices-hap/waterdetector.js.map +0 -1
  234. package/dist/devices-matter/BaseMatterAccessory.d.ts +0 -63
  235. package/dist/devices-matter/BaseMatterAccessory.d.ts.map +0 -1
  236. package/dist/devices-matter/BaseMatterAccessory.js +0 -100
  237. package/dist/devices-matter/BaseMatterAccessory.js.map +0 -1
  238. package/dist/devices-matter/ColorLightAccessory.d.ts +0 -20
  239. package/dist/devices-matter/ColorLightAccessory.d.ts.map +0 -1
  240. package/dist/devices-matter/ColorLightAccessory.js +0 -95
  241. package/dist/devices-matter/ColorLightAccessory.js.map +0 -1
  242. package/dist/devices-matter/ColorTemperatureLightAccessory.d.ts +0 -18
  243. package/dist/devices-matter/ColorTemperatureLightAccessory.d.ts.map +0 -1
  244. package/dist/devices-matter/ColorTemperatureLightAccessory.js +0 -78
  245. package/dist/devices-matter/ColorTemperatureLightAccessory.js.map +0 -1
  246. package/dist/devices-matter/ContactSensorAccessory.d.ts +0 -12
  247. package/dist/devices-matter/ContactSensorAccessory.d.ts.map +0 -1
  248. package/dist/devices-matter/ContactSensorAccessory.js +0 -34
  249. package/dist/devices-matter/ContactSensorAccessory.js.map +0 -1
  250. package/dist/devices-matter/DimmableLightAccessory.d.ts +0 -58
  251. package/dist/devices-matter/DimmableLightAccessory.d.ts.map +0 -1
  252. package/dist/devices-matter/DimmableLightAccessory.js +0 -167
  253. package/dist/devices-matter/DimmableLightAccessory.js.map +0 -1
  254. package/dist/devices-matter/DoorLockAccessory.d.ts +0 -14
  255. package/dist/devices-matter/DoorLockAccessory.d.ts.map +0 -1
  256. package/dist/devices-matter/DoorLockAccessory.js +0 -50
  257. package/dist/devices-matter/DoorLockAccessory.js.map +0 -1
  258. package/dist/devices-matter/ExtendedColorLightAccessory.d.ts +0 -21
  259. package/dist/devices-matter/ExtendedColorLightAccessory.d.ts.map +0 -1
  260. package/dist/devices-matter/ExtendedColorLightAccessory.js +0 -107
  261. package/dist/devices-matter/ExtendedColorLightAccessory.js.map +0 -1
  262. package/dist/devices-matter/FanAccessory.d.ts +0 -16
  263. package/dist/devices-matter/FanAccessory.d.ts.map +0 -1
  264. package/dist/devices-matter/FanAccessory.js +0 -81
  265. package/dist/devices-matter/FanAccessory.js.map +0 -1
  266. package/dist/devices-matter/HumiditySensorAccessory.d.ts +0 -12
  267. package/dist/devices-matter/HumiditySensorAccessory.d.ts.map +0 -1
  268. package/dist/devices-matter/HumiditySensorAccessory.js +0 -34
  269. package/dist/devices-matter/HumiditySensorAccessory.js.map +0 -1
  270. package/dist/devices-matter/LeakSensorAccessory.d.ts +0 -12
  271. package/dist/devices-matter/LeakSensorAccessory.d.ts.map +0 -1
  272. package/dist/devices-matter/LeakSensorAccessory.js +0 -33
  273. package/dist/devices-matter/LeakSensorAccessory.js.map +0 -1
  274. package/dist/devices-matter/LightSensorAccessory.d.ts +0 -12
  275. package/dist/devices-matter/LightSensorAccessory.d.ts.map +0 -1
  276. package/dist/devices-matter/LightSensorAccessory.js +0 -34
  277. package/dist/devices-matter/LightSensorAccessory.js.map +0 -1
  278. package/dist/devices-matter/OccupancySensorAccessory.d.ts +0 -12
  279. package/dist/devices-matter/OccupancySensorAccessory.d.ts.map +0 -1
  280. package/dist/devices-matter/OccupancySensorAccessory.js +0 -39
  281. package/dist/devices-matter/OccupancySensorAccessory.js.map +0 -1
  282. package/dist/devices-matter/OnOffLightAccessory.d.ts +0 -38
  283. package/dist/devices-matter/OnOffLightAccessory.d.ts.map +0 -1
  284. package/dist/devices-matter/OnOffLightAccessory.js +0 -118
  285. package/dist/devices-matter/OnOffLightAccessory.js.map +0 -1
  286. package/dist/devices-matter/OnOffOutletAccessory.d.ts +0 -12
  287. package/dist/devices-matter/OnOffOutletAccessory.d.ts.map +0 -1
  288. package/dist/devices-matter/OnOffOutletAccessory.js +0 -40
  289. package/dist/devices-matter/OnOffOutletAccessory.js.map +0 -1
  290. package/dist/devices-matter/OnOffSwitchAccessory.d.ts +0 -14
  291. package/dist/devices-matter/OnOffSwitchAccessory.d.ts.map +0 -1
  292. package/dist/devices-matter/OnOffSwitchAccessory.js +0 -42
  293. package/dist/devices-matter/OnOffSwitchAccessory.js.map +0 -1
  294. package/dist/devices-matter/RoboticVacuumAccessory.d.ts +0 -68
  295. package/dist/devices-matter/RoboticVacuumAccessory.d.ts.map +0 -1
  296. package/dist/devices-matter/RoboticVacuumAccessory.js +0 -334
  297. package/dist/devices-matter/RoboticVacuumAccessory.js.map +0 -1
  298. package/dist/devices-matter/SmokeCOAlarmAccessory.d.ts +0 -11
  299. package/dist/devices-matter/SmokeCOAlarmAccessory.d.ts.map +0 -1
  300. package/dist/devices-matter/SmokeCOAlarmAccessory.js +0 -49
  301. package/dist/devices-matter/SmokeCOAlarmAccessory.js.map +0 -1
  302. package/dist/devices-matter/TemperatureSensorAccessory.d.ts +0 -12
  303. package/dist/devices-matter/TemperatureSensorAccessory.d.ts.map +0 -1
  304. package/dist/devices-matter/TemperatureSensorAccessory.js +0 -36
  305. package/dist/devices-matter/TemperatureSensorAccessory.js.map +0 -1
  306. package/dist/devices-matter/ThermostatAccessory.d.ts +0 -19
  307. package/dist/devices-matter/ThermostatAccessory.d.ts.map +0 -1
  308. package/dist/devices-matter/ThermostatAccessory.js +0 -95
  309. package/dist/devices-matter/ThermostatAccessory.js.map +0 -1
  310. package/dist/devices-matter/VenetianBlindAccessory.d.ts +0 -19
  311. package/dist/devices-matter/VenetianBlindAccessory.d.ts.map +0 -1
  312. package/dist/devices-matter/VenetianBlindAccessory.js +0 -99
  313. package/dist/devices-matter/VenetianBlindAccessory.js.map +0 -1
  314. package/dist/devices-matter/WindowBlindAccessory.d.ts +0 -17
  315. package/dist/devices-matter/WindowBlindAccessory.d.ts.map +0 -1
  316. package/dist/devices-matter/WindowBlindAccessory.js +0 -80
  317. package/dist/devices-matter/WindowBlindAccessory.js.map +0 -1
  318. package/dist/devices-matter/custom/PowerStripAccessory.d.ts +0 -97
  319. package/dist/devices-matter/custom/PowerStripAccessory.d.ts.map +0 -1
  320. package/dist/devices-matter/custom/PowerStripAccessory.js +0 -265
  321. package/dist/devices-matter/custom/PowerStripAccessory.js.map +0 -1
  322. package/dist/devices-matter/custom/index.d.ts +0 -8
  323. package/dist/devices-matter/custom/index.d.ts.map +0 -1
  324. package/dist/devices-matter/custom/index.js +0 -8
  325. package/dist/devices-matter/custom/index.js.map +0 -1
  326. package/dist/devices-matter/index.d.ts +0 -29
  327. package/dist/devices-matter/index.d.ts.map +0 -1
  328. package/dist/devices-matter/index.js +0 -28
  329. package/dist/devices-matter/index.js.map +0 -1
  330. package/dist/index.test.d.ts +0 -2
  331. package/dist/index.test.d.ts.map +0 -1
  332. package/dist/index.test.js +0 -14
  333. package/dist/index.test.js.map +0 -1
  334. package/dist/irdevice/airconditioner.d.ts +0 -61
  335. package/dist/irdevice/airconditioner.d.ts.map +0 -1
  336. package/dist/irdevice/airconditioner.js +0 -472
  337. package/dist/irdevice/airconditioner.js.map +0 -1
  338. package/dist/irdevice/airpurifier.d.ts +0 -50
  339. package/dist/irdevice/airpurifier.d.ts.map +0 -1
  340. package/dist/irdevice/airpurifier.js +0 -213
  341. package/dist/irdevice/airpurifier.js.map +0 -1
  342. package/dist/irdevice/camera.d.ts +0 -32
  343. package/dist/irdevice/camera.d.ts.map +0 -1
  344. package/dist/irdevice/camera.js +0 -107
  345. package/dist/irdevice/camera.js.map +0 -1
  346. package/dist/irdevice/fan.d.ts +0 -36
  347. package/dist/irdevice/fan.d.ts.map +0 -1
  348. package/dist/irdevice/fan.js +0 -200
  349. package/dist/irdevice/fan.js.map +0 -1
  350. package/dist/irdevice/irdevice.d.ts +0 -68
  351. package/dist/irdevice/irdevice.d.ts.map +0 -1
  352. package/dist/irdevice/irdevice.js +0 -298
  353. package/dist/irdevice/irdevice.js.map +0 -1
  354. package/dist/irdevice/light.d.ts +0 -36
  355. package/dist/irdevice/light.d.ts.map +0 -1
  356. package/dist/irdevice/light.js +0 -206
  357. package/dist/irdevice/light.js.map +0 -1
  358. package/dist/irdevice/other.d.ts +0 -57
  359. package/dist/irdevice/other.d.ts.map +0 -1
  360. package/dist/irdevice/other.js +0 -778
  361. package/dist/irdevice/other.js.map +0 -1
  362. package/dist/irdevice/tv.d.ts +0 -45
  363. package/dist/irdevice/tv.d.ts.map +0 -1
  364. package/dist/irdevice/tv.js +0 -327
  365. package/dist/irdevice/tv.js.map +0 -1
  366. package/dist/irdevice/vacuumcleaner.d.ts +0 -28
  367. package/dist/irdevice/vacuumcleaner.d.ts.map +0 -1
  368. package/dist/irdevice/vacuumcleaner.js +0 -104
  369. package/dist/irdevice/vacuumcleaner.js.map +0 -1
  370. package/dist/irdevice/waterheater.d.ts +0 -30
  371. package/dist/irdevice/waterheater.d.ts.map +0 -1
  372. package/dist/irdevice/waterheater.js +0 -105
  373. package/dist/irdevice/waterheater.js.map +0 -1
  374. package/dist/platform-hap.d.ts +0 -149
  375. package/dist/platform-hap.d.ts.map +0 -1
  376. package/dist/platform-hap.js +0 -2861
  377. package/dist/platform-hap.js.map +0 -1
  378. package/dist/platform-matter.d.ts +0 -101
  379. package/dist/platform-matter.d.ts.map +0 -1
  380. package/dist/platform-matter.js +0 -896
  381. package/dist/platform-matter.js.map +0 -1
  382. package/dist/verifyconfig.test.d.ts +0 -2
  383. package/dist/verifyconfig.test.d.ts.map +0 -1
  384. package/dist/verifyconfig.test.js +0 -167
  385. package/dist/verifyconfig.test.js.map +0 -1
  386. package/src/custom.d.ts +0 -7
  387. package/src/devices-hap/airpurifier.ts +0 -563
  388. package/src/devices-hap/blindtilt.ts +0 -1049
  389. package/src/devices-hap/bot.ts +0 -900
  390. package/src/devices-hap/ceilinglight.ts +0 -742
  391. package/src/devices-hap/colorbulb.ts +0 -904
  392. package/src/devices-hap/contact.ts +0 -457
  393. package/src/devices-hap/curtain.ts +0 -944
  394. package/src/devices-hap/device.ts +0 -811
  395. package/src/devices-hap/fan.ts +0 -711
  396. package/src/devices-hap/hub.ts +0 -439
  397. package/src/devices-hap/humidifier.ts +0 -669
  398. package/src/devices-hap/iosensor.ts +0 -427
  399. package/src/devices-hap/lightstrip.ts +0 -836
  400. package/src/devices-hap/lock.ts +0 -620
  401. package/src/devices-hap/meter.ts +0 -426
  402. package/src/devices-hap/meterplus.ts +0 -430
  403. package/src/devices-hap/meterpro.ts +0 -522
  404. package/src/devices-hap/motion.ts +0 -390
  405. package/src/devices-hap/plug.ts +0 -423
  406. package/src/devices-hap/relayswitch.ts +0 -727
  407. package/src/devices-hap/robotvacuumcleaner.ts +0 -568
  408. package/src/devices-hap/waterdetector.ts +0 -400
  409. package/src/devices-matter/BaseMatterAccessory.ts +0 -131
  410. package/src/devices-matter/ColorLightAccessory.ts +0 -110
  411. package/src/devices-matter/ColorTemperatureLightAccessory.ts +0 -92
  412. package/src/devices-matter/ContactSensorAccessory.ts +0 -41
  413. package/src/devices-matter/DimmableLightAccessory.ts +0 -192
  414. package/src/devices-matter/DoorLockAccessory.ts +0 -60
  415. package/src/devices-matter/ExtendedColorLightAccessory.ts +0 -123
  416. package/src/devices-matter/FanAccessory.ts +0 -95
  417. package/src/devices-matter/HumiditySensorAccessory.ts +0 -41
  418. package/src/devices-matter/LeakSensorAccessory.ts +0 -40
  419. package/src/devices-matter/LightSensorAccessory.ts +0 -41
  420. package/src/devices-matter/OccupancySensorAccessory.ts +0 -48
  421. package/src/devices-matter/OnOffLightAccessory.ts +0 -133
  422. package/src/devices-matter/OnOffOutletAccessory.ts +0 -46
  423. package/src/devices-matter/OnOffSwitchAccessory.ts +0 -51
  424. package/src/devices-matter/RoboticVacuumAccessory.ts +0 -407
  425. package/src/devices-matter/SmokeCOAlarmAccessory.ts +0 -59
  426. package/src/devices-matter/TemperatureSensorAccessory.ts +0 -43
  427. package/src/devices-matter/ThermostatAccessory.ts +0 -110
  428. package/src/devices-matter/VenetianBlindAccessory.ts +0 -115
  429. package/src/devices-matter/WindowBlindAccessory.ts +0 -92
  430. package/src/devices-matter/custom/PowerStripAccessory.ts +0 -309
  431. package/src/devices-matter/custom/index.ts +0 -8
  432. package/src/devices-matter/index.ts +0 -29
  433. package/src/index.test.ts +0 -19
  434. package/src/irdevice/airconditioner.ts +0 -533
  435. package/src/irdevice/airpurifier.ts +0 -252
  436. package/src/irdevice/camera.ts +0 -129
  437. package/src/irdevice/fan.ts +0 -226
  438. package/src/irdevice/irdevice.ts +0 -344
  439. package/src/irdevice/light.ts +0 -246
  440. package/src/irdevice/other.ts +0 -790
  441. package/src/irdevice/tv.ts +0 -378
  442. package/src/irdevice/vacuumcleaner.ts +0 -126
  443. package/src/irdevice/waterheater.ts +0 -127
  444. package/src/platform-hap.ts +0 -2997
  445. package/src/platform-matter.ts +0 -1010
  446. package/src/verifyconfig.test.ts +0 -197
@@ -0,0 +1,395 @@
1
+ import type { API, Logger, PlatformConfig } from 'homebridge'
2
+ import { SwitchBotClient } from './switchbotClient'
3
+ import { createDevice } from './deviceFactory'
4
+ import type { SwitchBotPluginConfig } from './settings'
5
+ import { PLUGIN_NAME, PLATFORM_NAME } from './settings'
6
+
7
+ // Which device types should prefer Matter if available
8
+ const DEVICE_MATTER_SUPPORTED: Record<string, boolean> = {
9
+ bot: false,
10
+ curtain: true,
11
+ fan: true,
12
+ light: true,
13
+ lightstrip: true,
14
+ motion: true,
15
+ contact: true,
16
+ vacuum: false,
17
+ lock: true,
18
+ humidifier: true,
19
+ temperature: true,
20
+ }
21
+
22
+ export class SwitchBotHAPPlatform {
23
+ api: API | undefined
24
+ log: Logger
25
+ config: SwitchBotPluginConfig
26
+ devices: any[] = []
27
+ // cached accessories restored by Homebridge
28
+ accessories: Map<string, any>
29
+
30
+ constructor(log: Logger, config: PlatformConfig, api?: API) {
31
+ this.log = log
32
+ this.config = (config as any) ?? {}
33
+ this.api = api
34
+ this.accessories = new Map()
35
+ this.log.info('SwitchBot HAP platform initialized')
36
+
37
+ // Create/shared SwitchBot client and attach to config so child devices reuse it.
38
+ try {
39
+ const client = new SwitchBotClient(this.config)
40
+ void client.init()
41
+ ;(this.config as any)._client = client
42
+ } catch (e) {
43
+ this.log.debug('Failed to create shared SwitchBot client', e)
44
+ }
45
+
46
+ // Create/shared SwitchBot client and attach to config so child devices reuse it.
47
+ try {
48
+ const client = new SwitchBotClient(this.config)
49
+ void client.init()
50
+ ;(this.config as any)._client = client
51
+ } catch (e) {
52
+ this.log.debug('Failed to create shared SwitchBot client', e)
53
+ }
54
+
55
+ // Wait for Homebridge to finish launching to create/register accessories
56
+ if (this.api && typeof (this.api as any).on === 'function') {
57
+ ;(this.api as any).on('didFinishLaunching', () => {
58
+ void this.loadDevices()
59
+ })
60
+ } else {
61
+ void this.loadDevices()
62
+ }
63
+ }
64
+
65
+ async loadDevices() {
66
+ const devices = (this.config as any)?.devices ?? []
67
+ for (const raw of devices) {
68
+ // Normalize config keys from UI schema to internal shape
69
+ const d: any = {
70
+ id: raw.deviceId ?? raw.id,
71
+ name: raw.configDeviceName ?? raw.name,
72
+ type: raw.configDeviceType ?? raw.type ?? raw.deviceType ?? 'unknown',
73
+ _raw: raw,
74
+ }
75
+
76
+ const type: string = d.type
77
+ const matterSupported = !!DEVICE_MATTER_SUPPORTED[(type || '').toLowerCase()]
78
+ const useMatter = !!this.config.enableMatter && matterSupported && !!this.config.preferMatter
79
+
80
+ try {
81
+ const created = await createDevice({ id: d.id, type, name: d.name }, this.config, useMatter)
82
+ this.devices.push(created)
83
+ // Prefer Matter: try registering to the Matter child bridge first.
84
+ let matterRegistered = false
85
+ if (useMatter) {
86
+ this.log.info(`Attempting Matter registration for ${d.id} (${type})`)
87
+ // If Homebridge Matter APIs are available, register the accessory
88
+ try {
89
+ const matterApi = (this.api as any)?.matter
90
+ if (this.api?.isMatterAvailable?.() && this.api?.isMatterEnabled?.() && matterApi && typeof matterApi.registerPlatformAccessories === 'function') {
91
+ const createdDesc = created.createAccessory?.(this.api) || { id: d.id, name: d.name || type }
92
+ const uuid = matterApi.uuid.generate(`${d.id}`)
93
+ const accessory: any = {
94
+ uuid,
95
+ displayName: createdDesc.name || d.name || type,
96
+ context: { deviceId: d.id, type: type, _created: true },
97
+ }
98
+ try {
99
+ await matterApi.registerPlatformAccessories(PLUGIN_NAME, PLATFORM_NAME, [accessory])
100
+ this.accessories.set(uuid, accessory)
101
+ matterRegistered = true
102
+ this.log.info(`Registered Matter accessory ${d.id} (${type}) with uuid=${uuid}`)
103
+ } catch (e) {
104
+ this.log.warn('Failed to register Matter accessory with Homebridge matter API', e)
105
+ }
106
+ } else {
107
+ this.log.info('Homebridge Matter API not available or not enabled; will fallback to HAP')
108
+ }
109
+ } catch (e) {
110
+ this.log.warn('Matter registration attempt failed', e)
111
+ }
112
+ }
113
+
114
+ // If Matter wasn't registered (either not supported, API missing, or registration failed), fall back to HAP registration.
115
+ if (!matterRegistered && this.api && (this.api as any).hap) {
116
+ // Basic HAP accessory creation using homebridge API when available
117
+ try {
118
+ const hap = (this.api as any).hap
119
+ const uuid = hap.uuid.generate(`${d.id}`)
120
+ // Reuse cached accessory if available by uuid
121
+ let accessory: any = this.accessories.get(uuid)
122
+ // If not found by uuid, attempt to find by stored deviceId in accessory.context
123
+ if (!accessory) {
124
+ for (const [k, a] of Array.from(this.accessories.entries())) {
125
+ try {
126
+ if (a && a.context && a.context.deviceId === d.id) {
127
+ accessory = a
128
+ break
129
+ }
130
+ } catch (e) {
131
+ // ignore
132
+ }
133
+ }
134
+ }
135
+
136
+ if (!accessory) {
137
+ accessory = new (this.api as any).platformAccessory(d.name || type, uuid)
138
+ // Store device metadata on accessory.context for persistence across restarts
139
+ try {
140
+ accessory.context = accessory.context || {}
141
+ accessory.context.deviceId = d.id
142
+ accessory.context.type = type
143
+ } catch (e) {
144
+ // ignore context failures
145
+ }
146
+ // Register new accessory with Homebridge so it's cached
147
+ try {
148
+ ;(this.api as any).registerPlatformAccessories(PLUGIN_NAME, PLATFORM_NAME, [accessory])
149
+ } catch (e) {
150
+ // older API variations may require different registration; ignore if unavailable
151
+ }
152
+ this.accessories.set(uuid, accessory)
153
+ } else {
154
+ // ensure context includes deviceId (in case restored accessory lacked it)
155
+ try {
156
+ accessory.context = accessory.context || {}
157
+ accessory.context.deviceId = accessory.context.deviceId || d.id
158
+ accessory.context.type = accessory.context.type || type
159
+ } catch (e) {
160
+ // ignore
161
+ }
162
+ }
163
+ // Add basic service descriptor from device
164
+ const accDesc = created.createAccessory?.(this.api)
165
+ if (accDesc && accDesc.services) {
166
+ for (const s of accDesc.services) {
167
+ const Service = hap.Service[s.type] || hap.Service[s.type]
168
+ if (!Service) continue
169
+ const service = accessory.getService(Service) || accessory.addService(Service)
170
+ for (const [charName, getterSetterRaw] of Object.entries(s.characteristics || {})) {
171
+ const getterSetter: any = getterSetterRaw
172
+ const Characteristic = (hap.Characteristic as any)[charName]
173
+ if (!Characteristic) continue
174
+ // Apply characteristic props if provided (min/max/step)
175
+ if (getterSetter && getterSetter.props) {
176
+ try {
177
+ service.getCharacteristic(Characteristic).setProps(getterSetter.props)
178
+ } catch (e) {
179
+ // ignore setProps failures on older HAP implementations
180
+ }
181
+ }
182
+
183
+ // Wire simple get/set handlers if provided
184
+ if (getterSetter && typeof getterSetter.get === 'function') {
185
+ service.getCharacteristic(Characteristic).onGet(getterSetter.get)
186
+ }
187
+ if (getterSetter && typeof getterSetter.set === 'function') {
188
+ service.getCharacteristic(Characteristic).onSet(getterSetter.set)
189
+ }
190
+ }
191
+ }
192
+ }
193
+ this.log.info(`Created/updated HAP accessory ${d.id} (${type})`)
194
+ } catch (e) {
195
+ this.log.warn('HAP accessory creation failed', e)
196
+ }
197
+ } else if (!matterRegistered) {
198
+ this.log.info(`Created HAP descriptor for ${d.id} (${type}) (API not available to register)`)
199
+ }
200
+ } catch (e) {
201
+ this.log.error(`Failed to create device ${d.id}:`, e as any)
202
+ }
203
+ }
204
+ }
205
+
206
+ // Example lifecycle method called by Homebridge
207
+ async configureAccessory(accessory: any) {
208
+ // Homebridge calls this for restored cached accessories — keep a reference.
209
+ try {
210
+ const uuid = accessory.UUID || accessory.UUID
211
+ this.accessories.set(uuid, accessory)
212
+ this.log.info(`Restored cached accessory ${accessory.displayName || uuid}`)
213
+ } catch (e) {
214
+ this.log.warn('configureAccessory failed to restore accessory', e)
215
+ }
216
+ }
217
+
218
+ // Called by Homebridge when a cached Matter accessory is restored
219
+ configureMatterAccessory?(accessory: any) {
220
+ try {
221
+ const uuid = accessory.uuid || accessory.UUID || accessory.uuid
222
+ this.accessories.set(uuid, accessory)
223
+ this.log.info(`Restored cached Matter accessory ${accessory.displayName || uuid}`)
224
+ } catch (e) {
225
+ this.log.warn('configureMatterAccessory failed to restore accessory', e)
226
+ }
227
+ }
228
+ }
229
+
230
+ // Matter platform implementation (placeholder)
231
+ export class SwitchBotMatterPlatform {
232
+ api: API | undefined
233
+ log: Logger
234
+ config: SwitchBotPluginConfig
235
+ devices: any[] = []
236
+ accessories: Map<string, any>
237
+
238
+ constructor(log: Logger, config: PlatformConfig, api?: API) {
239
+ this.log = log
240
+ this.config = (config as any) ?? {}
241
+ this.api = api
242
+ this.accessories = new Map()
243
+ this.log.info('SwitchBot Matter platform initialized')
244
+
245
+ if (this.api && typeof (this.api as any).on === 'function') {
246
+ ;(this.api as any).on('didFinishLaunching', () => {
247
+ ;(async () => {
248
+ // After launch, perform discovery (if any) and register Matter accessories
249
+ try {
250
+ await this.loadDevices()
251
+ if ((this.api as any).isMatterAvailable?.() && (this.api as any).isMatterEnabled?.() && (this.api as any).matter && typeof (this.api as any).matter.registerPlatformAccessories === 'function') {
252
+ try {
253
+ await (this as any).registerMatterAccessories?.()
254
+ } catch (e) {
255
+ this.log.warn('registerMatterAccessories failed', e)
256
+ }
257
+ }
258
+ } catch (e) {
259
+ this.log.warn('Error during Matter platform startup', e)
260
+ }
261
+ })()
262
+ })
263
+ } else {
264
+ void this.loadDevices()
265
+ }
266
+ // Create/shared SwitchBot client and attach to config so child devices reuse it.
267
+ try {
268
+ const client = new SwitchBotClient(this.config)
269
+ void client.init()
270
+ ;(this.config as any)._client = client
271
+ } catch (e) {
272
+ this.log.debug('Failed to create shared SwitchBot client', e)
273
+ }
274
+ }
275
+
276
+ async loadDevices() {
277
+ const devices = (this.config as any)?.devices ?? []
278
+ for (const raw of devices) {
279
+ // Normalize config keys produced by the UI schema
280
+ const d: any = {
281
+ id: raw.deviceId ?? raw.id,
282
+ name: raw.configDeviceName ?? raw.name,
283
+ type: raw.configDeviceType ?? raw.type ?? raw.deviceType ?? 'unknown',
284
+ _raw: raw,
285
+ }
286
+
287
+ const type: string = d.type
288
+ const matterSupported = !!DEVICE_MATTER_SUPPORTED[(type || '').toLowerCase()]
289
+ const useMatter = !!this.config.enableMatter && matterSupported
290
+ try {
291
+ const created = await createDevice({ id: d.id, type, name: d.name }, this.config, useMatter)
292
+ this.devices.push(created)
293
+ if (useMatter) {
294
+ this.log.info(`Prepared Matter accessory for ${d.id} (${type})`)
295
+ } else {
296
+ this.log.info(`Skipping Matter for ${d.id} (${type}) - not supported`)
297
+ }
298
+ } catch (e) {
299
+ this.log.error(`Failed to create Matter device ${d.id}:`, e as any)
300
+ }
301
+ }
302
+ }
303
+
304
+ async configureAccessory(accessory: any) {
305
+ try {
306
+ const uuid = accessory.UUID || accessory.UUID
307
+ this.accessories.set(uuid, accessory)
308
+ this.log.info(`Restored cached Matter accessory ${accessory.displayName || uuid}`)
309
+ } catch (e) {
310
+ this.log.warn('configureAccessory failed to restore Matter accessory', e)
311
+ }
312
+ }
313
+
314
+ // Homebridge calls this when restoring cached Matter accessories
315
+ configureMatterAccessory(accessory: any) {
316
+ try {
317
+ const uuid = accessory.uuid || accessory.UUID || accessory.uuid
318
+ this.accessories.set(uuid, accessory)
319
+ this.log.info(`Restored cached Matter accessory ${accessory.displayName || uuid}`)
320
+ } catch (e) {
321
+ this.log.warn('configureMatterAccessory failed to restore Matter accessory', e)
322
+ }
323
+ }
324
+
325
+ // Register serialized Matter accessories via Homebridge Matter API
326
+ async registerMatterAccessories() {
327
+ if (!this.api) return
328
+ const matterApi = (this.api as any).matter
329
+ if (!matterApi || typeof matterApi.registerPlatformAccessories !== 'function') {
330
+ this.log.info('Homebridge Matter API not available; skipping Matter accessory registration')
331
+ return
332
+ }
333
+
334
+ const devices = (this.config as any)?.devices ?? []
335
+ const accessoriesToRegister: any[] = []
336
+
337
+ for (const d of devices) {
338
+ const type: string = d.type || d.deviceType || 'unknown'
339
+ const matterSupported = !!DEVICE_MATTER_SUPPORTED[(type || '').toLowerCase()]
340
+ const useMatter = !!this.config.enableMatter && matterSupported
341
+ if (!useMatter) continue
342
+
343
+ try {
344
+ const created = await createDevice({ id: d.id, type, name: d.name }, this.config, true)
345
+ const createdDesc = created.createAccessory?.(this.api) || { id: d.id, name: d.name || type }
346
+ const uuid = matterApi.uuid.generate(`${d.id}`)
347
+ // Try to find existing restored accessory by deviceId
348
+ let existing: any | undefined
349
+ for (const [k, a] of Array.from(this.accessories.entries())) {
350
+ try {
351
+ if (a && a.context && a.context.deviceId === d.id) {
352
+ existing = a
353
+ break
354
+ }
355
+ } catch (e) {
356
+ // ignore
357
+ }
358
+ }
359
+
360
+ if (existing) {
361
+ // Ensure context and displayName are up to date
362
+ existing.context = existing.context || {}
363
+ existing.context.deviceId = existing.context.deviceId || d.id
364
+ existing.context.type = existing.context.type || type
365
+ existing.displayName = createdDesc.name || d.name || type
366
+ accessoriesToRegister.push(existing)
367
+ this.accessories.set(existing.uuid || uuid, existing)
368
+ } else {
369
+ const serialized: any = {
370
+ uuid,
371
+ displayName: createdDesc.name || d.name || type,
372
+ context: { deviceId: d.id, type, created: true },
373
+ }
374
+ accessoriesToRegister.push(serialized)
375
+ this.accessories.set(uuid, serialized)
376
+ }
377
+ } catch (e) {
378
+ this.log.warn(`Failed to prepare Matter accessory for ${d.id} (${type})`, e)
379
+ }
380
+ }
381
+
382
+ if (accessoriesToRegister.length > 0) {
383
+ try {
384
+ await matterApi.registerPlatformAccessories(PLUGIN_NAME, PLATFORM_NAME, accessoriesToRegister)
385
+ this.log.info(`Registered ${accessoriesToRegister.length} Matter accessory(ies) with Homebridge`)
386
+ } catch (e) {
387
+ this.log.warn('Failed to register Matter accessories', e)
388
+ }
389
+ } else {
390
+ this.log.info('No Matter accessories to register')
391
+ }
392
+ }
393
+ }
394
+
395
+ export default SwitchBotHAPPlatform
package/src/settings.ts CHANGED
@@ -1,283 +1,18 @@
1
- /* Copyright(C) 2017-2024, donavanbecker (https://github.com/donavanbecker). All rights reserved.
2
- *
3
- * settings.ts: @switchbot/homebridge-switchbot platform class.
4
- */
5
- import type { IClientOptions } from 'async-mqtt'
6
- import type { PlatformConfig } from 'homebridge'
7
- /*
8
- * For Testing Locally:
9
- * import type { device, irdevice, SwitchBotBLEModel, SwitchBotBLEModelFriendlyName, SwitchBotBLEModelName } from '/Users/Shared/GitHub/OpenWonderLabs/node-switchbot/dist/index.js';
10
- */
11
- import type { device, irdevice, SwitchBotBLEModel, SwitchBotBLEModelFriendlyName, SwitchBotBLEModelName, SwitchBotModel } from 'node-switchbot'
12
- /**
13
- * This is the name of the platform that users will use to register the plugin in the Homebridge config.json
14
- */
15
- export const PLATFORM_NAME = 'SwitchBot'
16
-
17
- /**
18
- * This must match the name of your plugin as defined the package.json
19
- */
20
1
  export const PLUGIN_NAME = '@switchbot/homebridge-switchbot'
2
+ export const PLATFORM_NAME = 'SwitchBot'
21
3
 
22
- // Config
23
- export interface SwitchBotPlatformConfig extends PlatformConfig {
24
- credentials?: credentials
25
- options?: options
26
- }
27
- interface credentials {
28
- token?: string
29
- secret?: string
30
- notice?: string
31
- }
32
-
33
- export interface options {
34
- devices?: devicesConfig[]
35
- deviceConfig?: { [deviceType: string]: devicesConfig }
36
- irdevices?: irDevicesConfig[]
37
- irdeviceConfig?: { [remoteType: string]: irDevicesConfig }
38
- allowInvalidCharacters?: boolean
39
- mqttURL?: string
40
- mqttOptions?: IClientOptions
41
- mqttPubOptions?: IClientOptions
42
- BLE?: boolean
43
- discoverBLE?: boolean
44
- disableLogsforBLE?: boolean
45
- disableLogsforOpenAPI?: boolean
46
- hostname?: string
47
- webhookURL?: string
48
- maxRetries?: number
49
- delayBetweenRetries?: number
50
- refreshRate?: number
51
- updateRate?: number
52
- pushRate?: number
53
- logging?: string
54
- };
55
-
56
- export type devicesConfig = botConfig | relaySwitch1Config | relaySwitch1PMConfig | meterConfig | meterProConfig | indoorOutdoorSensorConfig | humidifierConfig | curtainConfig | blindTiltConfig | contactConfig | motionConfig | waterDetectorConfig | plugConfig | colorBulbConfig | stripLightConfig | ceilingLightConfig | lockConfig | hubConfig
57
-
58
- export interface BaseDeviceConfig extends device {
59
- bleMac?: string
60
- model: SwitchBotModel
61
- bleModel: SwitchBotBLEModel
62
- bleModelName: SwitchBotBLEModelName
63
- bleModelFriednlyName: SwitchBotBLEModelFriendlyName
64
- configDeviceType: string
65
- configDeviceName?: string
66
- deviceId: string
67
- external?: boolean
68
- refreshRate?: number
69
- updateRate?: number
70
- pushRate?: number
71
- firmware?: string
72
- logging?: string
73
- connectionType?: string
74
- customBLEaddress?: string
75
- scanDuration?: number
76
- hide_device?: boolean
77
- offline?: boolean
78
- maxRetry?: number
79
- maxRetries?: number
80
- delayBetweenRetries?: number
81
- disableCaching?: boolean
82
- disablePlatformBLE?: boolean
83
- mqttURL?: string
84
- mqttOptions?: IClientOptions
85
- mqttPubOptions?: IClientOptions
86
- history?: boolean
87
- webhook?: boolean
4
+ export interface SwitchBotPluginConfig {
5
+ openApiToken?: string
6
+ openApiSecret?: string
7
+ preferMatter?: boolean
8
+ enableMatter?: boolean
9
+ // other plugin-specific configuration
10
+ [key: string]: any
88
11
  }
89
12
 
90
- export interface botConfig extends BaseDeviceConfig {
91
- configDeviceType: 'Bot'
92
- mode?: string
93
- type: string
94
- doublePress?: number
95
- pushRatePress?: number
96
- allowPush?: boolean
97
- multiPress?: boolean
98
- };
99
-
100
- export interface relaySwitch1Config extends BaseDeviceConfig {
101
- configDeviceType: 'Relay Switch 1'
102
- type: string
103
- allowPush?: boolean
104
- };
105
-
106
- export interface relaySwitch1PMConfig extends BaseDeviceConfig {
107
- configDeviceType: 'Relay Switch 1PM'
108
- type: string
109
- allowPush?: boolean
110
- };
111
-
112
- export interface meterConfig extends BaseDeviceConfig {
113
- configDeviceType: 'Meter' | 'MeterPlus'
114
- hide_temperature?: boolean
115
- convertUnitTo?: string
116
- hide_humidity?: boolean
117
- };
118
-
119
- export interface meterProConfig extends BaseDeviceConfig {
120
- configDeviceType: 'Meter Pro' | 'MeterPro(CO2)'
121
- hide_temperature?: boolean
122
- convertUnitTo?: string
123
- hide_humidity?: boolean
124
- hide_co2?: boolean
125
- };
126
-
127
- export interface indoorOutdoorSensorConfig extends BaseDeviceConfig {
128
- configDeviceType: 'WoIOSensor'
129
- hide_temperature?: boolean
130
- convertUnitTo?: string
131
- hide_humidity?: boolean
132
- };
133
-
134
- export interface humidifierConfig extends BaseDeviceConfig {
135
- configDeviceType: 'Humidifier' | 'Humidifier2'
136
- hide_temperature?: boolean
137
- convertUnitTo?: string
138
- set_minStep?: number
139
- };
140
-
141
- export interface curtainConfig extends BaseDeviceConfig {
142
- configDeviceType: 'Curtain' | 'Curtain3' | 'WoRollerShade' | 'Roller Shade'
143
- disable_group?: boolean
144
- hide_lightsensor?: boolean
145
- set_minLux?: number
146
- set_maxLux?: number
147
- set_max?: number
148
- set_min?: number
149
- set_minStep?: number
150
- setCloseMode?: string
151
- setOpenMode?: string
152
- silentModeSwitch?: boolean
153
- };
154
-
155
- export interface blindTiltConfig extends BaseDeviceConfig {
156
- configDeviceType: 'Blind Tilt'
157
- disable_group?: boolean
158
- mapping?: string
159
- hide_lightsensor?: boolean
160
- set_minLux?: number
161
- set_maxLux?: number
162
- set_max?: number
163
- set_min?: number
164
- set_minStep?: number
165
- setCloseMode?: string
166
- setOpenMode?: string
167
- silentModeSwitch?: boolean
168
- };
169
-
170
- export interface contactConfig extends BaseDeviceConfig {
171
- configDeviceType: 'Contact Sensor'
172
- hide_lightsensor?: boolean
173
- set_minLux?: number
174
- set_maxLux?: number
175
- hide_motionsensor?: boolean
176
- };
177
-
178
- export interface motionConfig extends BaseDeviceConfig {
179
- configDeviceType: 'Motion Sensor'
180
- hide_lightsensor?: boolean
181
- set_minLux?: number
182
- set_maxLux?: number
183
- };
184
-
185
- export interface waterDetectorConfig extends BaseDeviceConfig {
186
- configDeviceType: 'Water Detector'
187
- hide_leak?: boolean
188
- dry?: boolean
189
- };
190
-
191
- export interface plugConfig extends BaseDeviceConfig {
192
- configDeviceType: 'Plug' | 'Plug Mini (US)' | 'Plug Mini (JP)'
193
- };
194
-
195
- export interface colorBulbConfig extends BaseDeviceConfig {
196
- configDeviceType: 'Color Bulb'
197
- set_minStep?: number
198
- adaptiveLightingShift?: number
199
- };
200
-
201
- export interface stripLightConfig extends BaseDeviceConfig {
202
- configDeviceType: 'Strip Light'
203
- set_minStep?: number
204
- adaptiveLightingShift?: number
205
- };
206
-
207
- export interface ceilingLightConfig extends BaseDeviceConfig {
208
- configDeviceType: 'Ceiling Light' | 'Ceiling Light Pro'
209
- set_minStep?: number
210
- adaptiveLightingShift?: number
211
- };
212
-
213
- export interface lockConfig extends BaseDeviceConfig {
214
- configDeviceType: 'Smart Lock' | 'Smart Lock Pro'
215
- hide_contactsensor?: boolean
216
- activate_latchbutton?: boolean
217
- };
218
-
219
- export interface hubConfig extends BaseDeviceConfig {
220
- configDeviceType: 'Hub 2'
221
- hide_temperature?: boolean
222
- convertUnitTo?: string
223
- hide_humidity?: boolean
224
- hide_lightsensor?: boolean
225
- set_minLux?: number
226
- set_maxLux?: number
227
- };
228
-
229
- export type irDevicesConfig = irFanConfig | irLightConfig | irAirConfig | irOtherConfig
230
-
231
- export interface irBaseDeviceConfig extends irdevice {
232
- configDeviceName?: string
233
- configRemoteType?: string
234
- connectionType?: string
235
- hide_device?: boolean
236
- external?: boolean
237
- refreshRate?: number
238
- updateRate?: number
239
- pushRate?: number
240
- maxRetries?: number
241
- delayBetweenRetries?: number
242
- firmware?: string
243
- deviceId: string
244
- logging?: string
245
- customOn?: string
246
- customOff?: string
247
- customize?: boolean
248
- commandType?: string
249
- disablePushOn?: boolean
250
- disablePushOff?: boolean
251
- disablePushDetail?: boolean
13
+ export const DEFAULT_CONFIG: Partial<SwitchBotPluginConfig> = {
14
+ preferMatter: true,
15
+ enableMatter: true,
252
16
  }
253
17
 
254
- export interface irFanConfig extends irBaseDeviceConfig {
255
- configRemoteType?: 'Fan' | 'DIY Fan'
256
- swing_mode?: boolean
257
- rotation_speed?: boolean
258
- set_minStep?: number
259
- set_max?: number
260
- set_min?: number
261
- };
262
-
263
- export interface irLightConfig extends irBaseDeviceConfig {
264
- configRemoteType?: 'Light' | 'DIY Light'
265
- stateless?: boolean
266
- };
267
-
268
- export interface irAirConfig extends irBaseDeviceConfig {
269
- configRemoteType?: 'Air Conditioner' | 'DIY Air Conditioner'
270
- hide_automode?: boolean
271
- set_max_heat?: number
272
- set_min_heat?: number
273
- set_max_cool?: number
274
- set_min_cool?: number
275
- meterType?: string
276
- meterId?: string
277
- meterUuid?: string
278
- };
279
-
280
- export interface irOtherConfig extends irBaseDeviceConfig {
281
- configRemoteType?: 'Others'
282
- type?: string
283
- };
18
+ export type DeviceType = string