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

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 (271) hide show
  1. package/CHANGELOG.md +15 -0
  2. package/README.md +45 -3
  3. package/config.schema.json +871 -13754
  4. package/dist/devices-hap/airpurifier.d.ts.map +1 -1
  5. package/dist/devices-hap/airpurifier.js +12 -6
  6. package/dist/devices-hap/airpurifier.js.map +1 -1
  7. package/dist/devices-hap/blindtilt.js +3 -3
  8. package/dist/devices-hap/bot.d.ts.map +1 -1
  9. package/dist/devices-hap/bot.js +16 -5
  10. package/dist/devices-hap/bot.js.map +1 -1
  11. package/dist/devices-hap/ceilinglight.d.ts.map +1 -1
  12. package/dist/devices-hap/ceilinglight.js +13 -7
  13. package/dist/devices-hap/ceilinglight.js.map +1 -1
  14. package/dist/devices-hap/colorbulb.d.ts.map +1 -1
  15. package/dist/devices-hap/colorbulb.js +49 -9
  16. package/dist/devices-hap/colorbulb.js.map +1 -1
  17. package/dist/devices-hap/contact.js +3 -3
  18. package/dist/devices-hap/curtain.js +2 -2
  19. package/dist/devices-hap/curtain.js.map +1 -1
  20. package/dist/devices-hap/device.d.ts +18 -8
  21. package/dist/devices-hap/device.d.ts.map +1 -1
  22. package/dist/devices-hap/device.js +141 -69
  23. package/dist/devices-hap/device.js.map +1 -1
  24. package/dist/devices-hap/fan.d.ts.map +1 -1
  25. package/dist/devices-hap/fan.js +12 -6
  26. package/dist/devices-hap/fan.js.map +1 -1
  27. package/dist/devices-hap/hub.d.ts.map +1 -1
  28. package/dist/devices-hap/hub.js +6 -5
  29. package/dist/devices-hap/hub.js.map +1 -1
  30. package/dist/devices-hap/humidifier.d.ts +5 -0
  31. package/dist/devices-hap/humidifier.d.ts.map +1 -1
  32. package/dist/devices-hap/humidifier.js +92 -4
  33. package/dist/devices-hap/humidifier.js.map +1 -1
  34. package/dist/devices-hap/iosensor.d.ts.map +1 -1
  35. package/dist/devices-hap/iosensor.js +36 -21
  36. package/dist/devices-hap/iosensor.js.map +1 -1
  37. package/dist/devices-hap/lightstrip.d.ts.map +1 -1
  38. package/dist/devices-hap/lightstrip.js +38 -8
  39. package/dist/devices-hap/lightstrip.js.map +1 -1
  40. package/dist/devices-hap/lock.d.ts.map +1 -1
  41. package/dist/devices-hap/lock.js +14 -6
  42. package/dist/devices-hap/lock.js.map +1 -1
  43. package/dist/devices-hap/meter.d.ts.map +1 -1
  44. package/dist/devices-hap/meter.js +6 -5
  45. package/dist/devices-hap/meter.js.map +1 -1
  46. package/dist/devices-hap/meterplus.d.ts.map +1 -1
  47. package/dist/devices-hap/meterplus.js +6 -5
  48. package/dist/devices-hap/meterplus.js.map +1 -1
  49. package/dist/devices-hap/meterpro.d.ts.map +1 -1
  50. package/dist/devices-hap/meterpro.js +7 -6
  51. package/dist/devices-hap/meterpro.js.map +1 -1
  52. package/dist/devices-hap/motion.js +3 -3
  53. package/dist/devices-hap/plug.d.ts.map +1 -1
  54. package/dist/devices-hap/plug.js +11 -6
  55. package/dist/devices-hap/plug.js.map +1 -1
  56. package/dist/devices-hap/relayswitch.js +3 -3
  57. package/dist/devices-hap/robotvacuumcleaner.d.ts.map +1 -1
  58. package/dist/devices-hap/robotvacuumcleaner.js +13 -6
  59. package/dist/devices-hap/robotvacuumcleaner.js.map +1 -1
  60. package/dist/devices-hap/waterdetector.js +3 -3
  61. package/dist/devices-matter/BaseMatterAccessory.d.ts +27 -0
  62. package/dist/devices-matter/BaseMatterAccessory.d.ts.map +1 -1
  63. package/dist/devices-matter/BaseMatterAccessory.js +169 -5
  64. package/dist/devices-matter/BaseMatterAccessory.js.map +1 -1
  65. package/dist/devices-matter/ColorLightAccessory.d.ts.map +1 -1
  66. package/dist/devices-matter/ColorLightAccessory.js +12 -12
  67. package/dist/devices-matter/ColorLightAccessory.js.map +1 -1
  68. package/dist/devices-matter/ColorTemperatureLightAccessory.d.ts.map +1 -1
  69. package/dist/devices-matter/ColorTemperatureLightAccessory.js +5 -7
  70. package/dist/devices-matter/ColorTemperatureLightAccessory.js.map +1 -1
  71. package/dist/devices-matter/DimmableLightAccessory.js +9 -9
  72. package/dist/devices-matter/DimmableLightAccessory.js.map +1 -1
  73. package/dist/devices-matter/ExtendedColorLightAccessory.d.ts.map +1 -1
  74. package/dist/devices-matter/ExtendedColorLightAccessory.js +14 -15
  75. package/dist/devices-matter/ExtendedColorLightAccessory.js.map +1 -1
  76. package/dist/devices-matter/OnOffLightAccessory.d.ts.map +1 -1
  77. package/dist/devices-matter/OnOffLightAccessory.js +8 -16
  78. package/dist/devices-matter/OnOffLightAccessory.js.map +1 -1
  79. package/dist/devices-matter/OnOffOutletAccessory.d.ts +2 -0
  80. package/dist/devices-matter/OnOffOutletAccessory.d.ts.map +1 -1
  81. package/dist/devices-matter/OnOffOutletAccessory.js +10 -7
  82. package/dist/devices-matter/OnOffOutletAccessory.js.map +1 -1
  83. package/dist/devices-matter/OnOffSwitchAccessory.js +2 -2
  84. package/dist/devices-matter/OnOffSwitchAccessory.js.map +1 -1
  85. package/dist/devices-matter/RoboticVacuumAccessory.d.ts +36 -43
  86. package/dist/devices-matter/RoboticVacuumAccessory.d.ts.map +1 -1
  87. package/dist/devices-matter/RoboticVacuumAccessory.js +478 -268
  88. package/dist/devices-matter/RoboticVacuumAccessory.js.map +1 -1
  89. package/dist/devices-matter/VenetianBlindAccessory.d.ts +6 -6
  90. package/dist/devices-matter/VenetianBlindAccessory.d.ts.map +1 -1
  91. package/dist/devices-matter/VenetianBlindAccessory.js.map +1 -1
  92. package/dist/devices-matter/WindowBlindAccessory.d.ts +5 -5
  93. package/dist/devices-matter/WindowBlindAccessory.d.ts.map +1 -1
  94. package/dist/devices-matter/WindowBlindAccessory.js +57 -6
  95. package/dist/devices-matter/WindowBlindAccessory.js.map +1 -1
  96. package/dist/homebridge-ui/public/index.html +219 -19
  97. package/dist/homebridge-ui/server.js +0 -31
  98. package/dist/homebridge-ui/server.js.map +1 -1
  99. package/dist/index.d.ts.map +1 -1
  100. package/dist/index.js +4 -9
  101. package/dist/index.js.map +1 -1
  102. package/dist/irdevice/irdevice.d.ts +11 -10
  103. package/dist/irdevice/irdevice.d.ts.map +1 -1
  104. package/dist/irdevice/irdevice.js +76 -35
  105. package/dist/irdevice/irdevice.js.map +1 -1
  106. package/dist/platform-hap.d.ts +26 -15
  107. package/dist/platform-hap.d.ts.map +1 -1
  108. package/dist/platform-hap.js +333 -153
  109. package/dist/platform-hap.js.map +1 -1
  110. package/dist/platform-matter.d.ts +93 -6
  111. package/dist/platform-matter.d.ts.map +1 -1
  112. package/dist/platform-matter.js +1878 -229
  113. package/dist/platform-matter.js.map +1 -1
  114. package/dist/settings.d.ts +75 -7
  115. package/dist/settings.d.ts.map +1 -1
  116. package/dist/settings.js.map +1 -1
  117. package/dist/test/apiRequestTracker.test.d.ts +2 -0
  118. package/dist/test/apiRequestTracker.test.d.ts.map +1 -0
  119. package/dist/test/apiRequestTracker.test.js +392 -0
  120. package/dist/test/apiRequestTracker.test.js.map +1 -0
  121. package/dist/test/hap/device-webhook-context.test.d.ts +2 -0
  122. package/dist/test/hap/device-webhook-context.test.d.ts.map +1 -0
  123. package/dist/test/hap/device-webhook-context.test.js +128 -0
  124. package/dist/test/hap/device-webhook-context.test.js.map +1 -0
  125. package/dist/test/hap/platform-hap.logging.test.d.ts +2 -0
  126. package/dist/test/hap/platform-hap.logging.test.d.ts.map +1 -0
  127. package/dist/test/hap/platform-hap.logging.test.js +33 -0
  128. package/dist/test/hap/platform-hap.logging.test.js.map +1 -0
  129. package/dist/test/hap/platform-hap.test.d.ts +2 -0
  130. package/dist/test/hap/platform-hap.test.d.ts.map +1 -0
  131. package/dist/test/hap/platform-hap.test.js +62 -0
  132. package/dist/test/hap/platform-hap.test.js.map +1 -0
  133. package/dist/test/helpers/platform-fixtures.d.ts +9 -0
  134. package/dist/test/helpers/platform-fixtures.d.ts.map +1 -0
  135. package/dist/test/helpers/platform-fixtures.js +30 -0
  136. package/dist/test/helpers/platform-fixtures.js.map +1 -0
  137. package/dist/test/homebridge-ui/server.test.d.ts +2 -0
  138. package/dist/test/homebridge-ui/server.test.d.ts.map +1 -0
  139. package/dist/test/homebridge-ui/server.test.js +445 -0
  140. package/dist/test/homebridge-ui/server.test.js.map +1 -0
  141. package/dist/{index.test.d.ts.map → test/index.test.d.ts.map} +1 -1
  142. package/dist/test/index.test.js +19 -0
  143. package/dist/test/index.test.js.map +1 -0
  144. package/dist/test/matter/devices-matter/baseMatterAccessory.test.d.ts +2 -0
  145. package/dist/test/matter/devices-matter/baseMatterAccessory.test.d.ts.map +1 -0
  146. package/dist/test/matter/devices-matter/baseMatterAccessory.test.js +71 -0
  147. package/dist/test/matter/devices-matter/baseMatterAccessory.test.js.map +1 -0
  148. package/dist/test/matter/platform-matter.additional.test.d.ts +2 -0
  149. package/dist/test/matter/platform-matter.additional.test.d.ts.map +1 -0
  150. package/dist/test/matter/platform-matter.additional.test.js +35 -0
  151. package/dist/test/matter/platform-matter.additional.test.js.map +1 -0
  152. package/dist/test/matter/platform-matter.bleparse.test.d.ts +2 -0
  153. package/dist/test/matter/platform-matter.bleparse.test.d.ts.map +1 -0
  154. package/dist/test/matter/platform-matter.bleparse.test.js +43 -0
  155. package/dist/test/matter/platform-matter.bleparse.test.js.map +1 -0
  156. package/dist/test/matter/platform-matter.cleanup.test.d.ts +2 -0
  157. package/dist/test/matter/platform-matter.cleanup.test.d.ts.map +1 -0
  158. package/dist/test/matter/platform-matter.cleanup.test.js +70 -0
  159. package/dist/test/matter/platform-matter.cleanup.test.js.map +1 -0
  160. package/dist/test/matter/platform-matter.keepstale.test.d.ts +2 -0
  161. package/dist/test/matter/platform-matter.keepstale.test.d.ts.map +1 -0
  162. package/dist/test/matter/platform-matter.keepstale.test.js +27 -0
  163. package/dist/test/matter/platform-matter.keepstale.test.js.map +1 -0
  164. package/dist/test/matter/platform-matter.logging.test.d.ts +2 -0
  165. package/dist/test/matter/platform-matter.logging.test.d.ts.map +1 -0
  166. package/dist/test/matter/platform-matter.logging.test.js +29 -0
  167. package/dist/test/matter/platform-matter.logging.test.js.map +1 -0
  168. package/dist/test/matter/platform-matter.mapping.test.d.ts +2 -0
  169. package/dist/test/matter/platform-matter.mapping.test.d.ts.map +1 -0
  170. package/dist/test/matter/platform-matter.mapping.test.js +43 -0
  171. package/dist/test/matter/platform-matter.mapping.test.js.map +1 -0
  172. package/dist/test/matter/platform-matter.openapi-mapping.test.d.ts +2 -0
  173. package/dist/test/matter/platform-matter.openapi-mapping.test.d.ts.map +1 -0
  174. package/dist/test/matter/platform-matter.openapi-mapping.test.js +84 -0
  175. package/dist/test/matter/platform-matter.openapi-mapping.test.js.map +1 -0
  176. package/dist/test/matter/platform-matter.test.d.ts +2 -0
  177. package/dist/test/matter/platform-matter.test.d.ts.map +1 -0
  178. package/dist/test/matter/platform-matter.test.js +117 -0
  179. package/dist/test/matter/platform-matter.test.js.map +1 -0
  180. package/dist/test/matter/platform-matter.unregister.test.d.ts +2 -0
  181. package/dist/test/matter/platform-matter.unregister.test.d.ts.map +1 -0
  182. package/dist/test/matter/platform-matter.unregister.test.js +30 -0
  183. package/dist/test/matter/platform-matter.unregister.test.js.map +1 -0
  184. package/dist/test/matter/platform-matter.webhook.test.d.ts +2 -0
  185. package/dist/test/matter/platform-matter.webhook.test.d.ts.map +1 -0
  186. package/dist/test/matter/platform-matter.webhook.test.js +46 -0
  187. package/dist/test/matter/platform-matter.webhook.test.js.map +1 -0
  188. package/dist/test/utils.test.d.ts +2 -0
  189. package/dist/test/utils.test.d.ts.map +1 -0
  190. package/dist/test/utils.test.js +95 -0
  191. package/dist/test/utils.test.js.map +1 -0
  192. package/dist/test/verifyconfig.test.d.ts.map +1 -0
  193. package/dist/{verifyconfig.test.js → test/verifyconfig.test.js} +2 -2
  194. package/dist/test/verifyconfig.test.js.map +1 -0
  195. package/dist/utils.d.ts +204 -3
  196. package/dist/utils.d.ts.map +1 -1
  197. package/dist/utils.js +713 -33
  198. package/dist/utils.js.map +1 -1
  199. package/docs/assets/highlight.css +14 -0
  200. package/docs/assets/main.js +2 -2
  201. package/docs/index.html +31 -2
  202. package/docs/variables/default.html +1 -1
  203. package/package.json +15 -15
  204. package/src/devices-hap/airpurifier.ts +11 -6
  205. package/src/devices-hap/blindtilt.ts +3 -3
  206. package/src/devices-hap/bot.ts +15 -5
  207. package/src/devices-hap/ceilinglight.ts +12 -7
  208. package/src/devices-hap/colorbulb.ts +46 -10
  209. package/src/devices-hap/contact.ts +3 -3
  210. package/src/devices-hap/curtain.ts +2 -2
  211. package/src/devices-hap/device.ts +149 -70
  212. package/src/devices-hap/fan.ts +11 -6
  213. package/src/devices-hap/hub.ts +6 -5
  214. package/src/devices-hap/humidifier.ts +97 -4
  215. package/src/devices-hap/iosensor.ts +36 -21
  216. package/src/devices-hap/lightstrip.ts +35 -8
  217. package/src/devices-hap/lock.ts +13 -6
  218. package/src/devices-hap/meter.ts +6 -5
  219. package/src/devices-hap/meterplus.ts +6 -5
  220. package/src/devices-hap/meterpro.ts +7 -6
  221. package/src/devices-hap/motion.ts +3 -3
  222. package/src/devices-hap/plug.ts +10 -6
  223. package/src/devices-hap/relayswitch.ts +3 -3
  224. package/src/devices-hap/robotvacuumcleaner.ts +12 -6
  225. package/src/devices-hap/waterdetector.ts +3 -3
  226. package/src/devices-matter/BaseMatterAccessory.ts +176 -5
  227. package/src/devices-matter/ColorLightAccessory.ts +12 -12
  228. package/src/devices-matter/ColorTemperatureLightAccessory.ts +5 -7
  229. package/src/devices-matter/DimmableLightAccessory.ts +9 -9
  230. package/src/devices-matter/ExtendedColorLightAccessory.ts +14 -15
  231. package/src/devices-matter/OnOffLightAccessory.ts +8 -16
  232. package/src/devices-matter/OnOffOutletAccessory.ts +12 -7
  233. package/src/devices-matter/OnOffSwitchAccessory.ts +2 -2
  234. package/src/devices-matter/RoboticVacuumAccessory.ts +529 -315
  235. package/src/devices-matter/VenetianBlindAccessory.ts +5 -5
  236. package/src/devices-matter/WindowBlindAccessory.ts +53 -10
  237. package/src/homebridge-ui/public/index.html +219 -19
  238. package/src/homebridge-ui/server.ts +0 -34
  239. package/src/index.ts +4 -10
  240. package/src/irdevice/irdevice.ts +74 -35
  241. package/src/platform-hap.ts +365 -169
  242. package/src/platform-matter.ts +1923 -230
  243. package/src/settings.ts +78 -3
  244. package/src/test/apiRequestTracker.test.ts +417 -0
  245. package/src/test/hap/device-webhook-context.test.ts +136 -0
  246. package/src/test/hap/platform-hap.logging.test.ts +36 -0
  247. package/src/test/hap/platform-hap.test.ts +70 -0
  248. package/src/test/helpers/platform-fixtures.ts +33 -0
  249. package/src/test/homebridge-ui/server.test.ts +486 -0
  250. package/src/test/index.test.ts +24 -0
  251. package/src/test/matter/devices-matter/baseMatterAccessory.test.ts +88 -0
  252. package/src/test/matter/platform-matter.additional.test.ts +44 -0
  253. package/src/test/matter/platform-matter.bleparse.test.ts +47 -0
  254. package/src/test/matter/platform-matter.cleanup.test.ts +86 -0
  255. package/src/test/matter/platform-matter.keepstale.test.ts +37 -0
  256. package/src/test/matter/platform-matter.logging.test.ts +33 -0
  257. package/src/test/matter/platform-matter.mapping.test.ts +57 -0
  258. package/src/test/matter/platform-matter.openapi-mapping.test.ts +109 -0
  259. package/src/test/matter/platform-matter.test.ts +144 -0
  260. package/src/test/matter/platform-matter.unregister.test.ts +39 -0
  261. package/src/test/matter/platform-matter.webhook.test.ts +54 -0
  262. package/src/test/utils.test.ts +96 -0
  263. package/src/{verifyconfig.test.ts → test/verifyconfig.test.ts} +12 -11
  264. package/src/utils.ts +777 -36
  265. package/dist/index.test.js +0 -14
  266. package/dist/index.test.js.map +0 -1
  267. package/dist/verifyconfig.test.d.ts.map +0 -1
  268. package/dist/verifyconfig.test.js.map +0 -1
  269. package/src/index.test.ts +0 -19
  270. /package/dist/{index.test.d.ts → test/index.test.d.ts} +0 -0
  271. /package/dist/{verifyconfig.test.d.ts → test/verifyconfig.test.d.ts} +0 -0
@@ -58,7 +58,7 @@ export class VenetianBlindAccessory extends BaseMatterAccessory {
58
58
  this.logInfo('initialized.')
59
59
  }
60
60
 
61
- private async handleGoToLift(request: MatterRequests.GoToLiftPercentage): Promise<void> {
61
+ public async handleGoToLift(request: MatterRequests.GoToLiftPercentage): Promise<void> {
62
62
  this.logInfo(`GoToLiftPercentage request: ${JSON.stringify(request)}`)
63
63
 
64
64
  // Matter uses 0=open, 10000=closed, so invert to get open percentage
@@ -68,7 +68,7 @@ export class VenetianBlindAccessory extends BaseMatterAccessory {
68
68
  // TODO: await myBlindAPI.setPosition(openPercent)
69
69
  }
70
70
 
71
- private async handleGoToTilt(request: MatterRequests.GoToTiltPercentage): Promise<void> {
71
+ public async handleGoToTilt(request: MatterRequests.GoToTiltPercentage): Promise<void> {
72
72
  this.logInfo(`GoToTiltPercentage request: ${JSON.stringify(request)}`)
73
73
 
74
74
  // Matter tilt: 0=horizontal/open (0deg), 10000=vertical/closed (90deg)
@@ -77,17 +77,17 @@ export class VenetianBlindAccessory extends BaseMatterAccessory {
77
77
  // TODO: await myBlindAPI.setTiltAngle(degrees)
78
78
  }
79
79
 
80
- private async handleUpOrOpen(): Promise<void> {
80
+ public async handleUpOrOpen(): Promise<void> {
81
81
  this.logInfo('opened blind.')
82
82
  // TODO: await myBlindAPI.open()
83
83
  }
84
84
 
85
- private async handleDownOrClose(): Promise<void> {
85
+ public async handleDownOrClose(): Promise<void> {
86
86
  this.logInfo('closed blind.')
87
87
  // TODO: await myBlindAPI.close()
88
88
  }
89
89
 
90
- private async handleStop(): Promise<void> {
90
+ public async handleStop(): Promise<void> {
91
91
  this.logInfo('stopped blind.')
92
92
  // TODO: await myBlindAPI.stop()
93
93
  }
@@ -55,28 +55,71 @@ export class WindowBlindAccessory extends BaseMatterAccessory {
55
55
  this.logInfo('initialized.')
56
56
  }
57
57
 
58
- private async handleGoToLift(request: MatterRequests.GoToLiftPercentage): Promise<void> {
58
+ public async handleGoToLift(request: MatterRequests.GoToLiftPercentage): Promise<void> {
59
59
  this.logInfo(`GoToLiftPercentage request: ${JSON.stringify(request)}`)
60
60
  // Matter uses 0=open, 10000=closed, so invert to get open percentage
61
61
  const closedPercent = request.liftPercent100thsValue / 100
62
- const openPercent = (100 - closedPercent).toFixed(0)
63
- this.logInfo(`moved to ${openPercent}% open.`)
64
- // TODO: await myBlindAPI.setPosition(openPercent)
62
+ // SwitchBot API expects position: 0=open, 100=closed
63
+ const position = Math.max(0, Math.min(100, closedPercent))
64
+ // Default to performance mode (ff), index is always 0
65
+ const mode = 'ff' // or '01' for silent mode if needed
66
+ const parameter = `0,${mode},${position}`
67
+ this.logInfo(`Sending setPosition to OpenAPI: parameter=${parameter}`)
68
+ try {
69
+ if (this.context?.sendOpenAPI) {
70
+ await this.sendOpenAPICommand('setPosition', parameter)
71
+ this.logInfo('OpenAPI setPosition command sent.')
72
+ } else {
73
+ this.logWarn('OpenAPI sender not available in context.')
74
+ }
75
+ } catch (e: any) {
76
+ this.logWarn(`OpenAPI setPosition failed: ${String(e?.message ?? e)}`)
77
+ }
65
78
  }
66
79
 
67
- private async handleUpOrOpen(): Promise<void> {
80
+ public async handleUpOrOpen(): Promise<void> {
68
81
  this.logInfo('opened blind.')
69
- // TODO: await myBlindAPI.open()
82
+ try {
83
+ // Send open command to SwitchBot OpenAPI
84
+ if (this.context?.sendOpenAPI) {
85
+ await this.sendOpenAPICommand('turnOn')
86
+ this.logInfo('OpenAPI open command sent.')
87
+ } else {
88
+ this.logWarn('OpenAPI sender not available in context.')
89
+ }
90
+ } catch (e: any) {
91
+ this.logWarn(`OpenAPI open failed: ${String(e?.message ?? e)}`)
92
+ }
70
93
  }
71
94
 
72
- private async handleDownOrClose(): Promise<void> {
95
+ public async handleDownOrClose(): Promise<void> {
73
96
  this.logInfo('closed blind.')
74
- // TODO: await myBlindAPI.close()
97
+ try {
98
+ // Send close command to SwitchBot OpenAPI
99
+ if (this.context?.sendOpenAPI) {
100
+ await this.sendOpenAPICommand('turnOff')
101
+ this.logInfo('OpenAPI close command sent.')
102
+ } else {
103
+ this.logWarn('OpenAPI sender not available in context.')
104
+ }
105
+ } catch (e: any) {
106
+ this.logWarn(`OpenAPI close failed: ${String(e?.message ?? e)}`)
107
+ }
75
108
  }
76
109
 
77
- private async handleStop(): Promise<void> {
110
+ public async handleStop(): Promise<void> {
78
111
  this.logInfo('stopped blind.')
79
- // TODO: await myBlindAPI.stop()
112
+ try {
113
+ // Send pause command to SwitchBot OpenAPI
114
+ if (this.context?.sendOpenAPI) {
115
+ await this.sendOpenAPICommand('pause')
116
+ this.logInfo('OpenAPI pause command sent.')
117
+ } else {
118
+ this.logWarn('OpenAPI sender not available in context.')
119
+ }
120
+ } catch (e: any) {
121
+ this.logWarn(`OpenAPI pause failed: ${String(e?.message ?? e)}`)
122
+ }
80
123
  }
81
124
 
82
125
  public updateLiftPosition(openPercent: number): void {
@@ -28,7 +28,8 @@
28
28
  <div id="menuWrapper" class="btn-group w-100 mb-0" role="group" aria-label="UI Menu" style="display: none">
29
29
  <button type="button" class="btn btn-primary" id="menuSettings">Settings</button>
30
30
  <button type="button" class="btn btn-primary" id="menuDevices">Devices</button>
31
- <button type="button" class="btn btn-primary mr-0" id="menuHome">Support</button>
31
+ <button type="button" class="btn btn-primary" id="menuHome">Support</button>
32
+ <button type="button" class="btn btn-primary mr-0" id="dynamic-config-tab">Dynamic Config</button>
32
33
  </div>
33
34
  <div id="disabledBanner" class="alert alert-secondary mb-0 mt-3" role="alert" style="display: none">
34
35
  Plugin is currently disabled
@@ -43,7 +44,7 @@
43
44
  </form>
44
45
  <table class="table w-100" id="deviceTable" style="display: none">
45
46
  <thead>
46
- <tr class="table-active">
47
+ <tr>
47
48
  <th scope="col" style="width: 40%">Device Name</th>
48
49
  <th scope="col" style="width: 60%" id="displayName"></th>
49
50
  </tr>
@@ -69,8 +70,22 @@
69
70
  <th scope="row">Connection Type</th>
70
71
  <td id="connectionType"></td>
71
72
  </tr>
73
+ <tr>
74
+ <th scope="row">Refresh Rate</th>
75
+ <td id="refreshRate"></td>
76
+ </tr>
77
+ <tr>
78
+ <th scope="row">Update Rate</th>
79
+ <td id="updateRate"></td>
80
+ </tr>
81
+ <tr>
82
+ <th scope="row">Push Rate</th>
83
+ <td id="pushRate"></td>
84
+ </tr>
72
85
  </tbody>
73
86
  </table>
87
+ <h5 class="mt-4">Cached Accessories</h5>
88
+ <ul id="cachedAccessoriesList"></ul>
74
89
  <p class="text-center">External accessories will not be displayed here.</p>
75
90
  </div>
76
91
  </div>
@@ -118,10 +133,50 @@
118
133
  </li>
119
134
  </ul>
120
135
  </div>
136
+ <div id="dynamic-config-content" class="tab-content" style="display: none;">
137
+ <h2>Dynamic Config</h2>
138
+ <p>Discover and configure devices dynamically.</p>
139
+ <!-- Placeholder for dynamic content -->
140
+ </div>
121
141
  <script>
122
142
  (async () => {
123
143
  try {
124
144
  const currentConfig = await homebridge.getPluginConfig();
145
+
146
+ // Defensive wrapper: ensure token/secret aren't accidentally cleared by
147
+ // the UI/schema form. Some versions of config UI can omit sensitive
148
+ // fields from the submitted payload; when that happens we copy the
149
+ // existing values from `currentConfig` into the outgoing payload so
150
+ // saved config does not inadvertently remove credentials.
151
+ try {
152
+ if (typeof homebridge.updatePluginConfig === 'function') {
153
+ const _origUpdatePluginConfig = homebridge.updatePluginConfig.bind(homebridge)
154
+ homebridge.updatePluginConfig = async (cfg) => {
155
+ try {
156
+ if (Array.isArray(cfg) && cfg.length > 0 && Array.isArray(currentConfig) && currentConfig.length > 0) {
157
+ const incoming = cfg[0] || {}
158
+ const existing = currentConfig[0] || {}
159
+ incoming.credentials = incoming.credentials || {}
160
+ // Preserve token/secret when incoming payload leaves them blank/undefined
161
+ if ((incoming.credentials.token === undefined || String(incoming.credentials.token).trim() === '') && existing.credentials && existing.credentials.token) {
162
+ incoming.credentials.token = existing.credentials.token
163
+ }
164
+ if ((incoming.credentials.secret === undefined || String(incoming.credentials.secret).trim() === '') && existing.credentials && existing.credentials.secret) {
165
+ incoming.credentials.secret = existing.credentials.secret
166
+ }
167
+ cfg[0] = incoming
168
+ }
169
+ } catch (e) {
170
+ // Swallow any wrapper errors but log to console for debugging
171
+ // (do not expose secrets).
172
+ console.error('updatePluginConfig wrapper error', e)
173
+ }
174
+ return await _origUpdatePluginConfig(cfg)
175
+ }
176
+ }
177
+ } catch (e) {
178
+ console.error('Failed to attach updatePluginConfig wrapper', e)
179
+ }
125
180
  showIntro = () => {
126
181
  const introLink = document.getElementById('introLink');
127
182
  introLink.addEventListener('click', () => {
@@ -144,13 +199,33 @@
144
199
  document.getElementById('menuSettings').classList.add('btn-primary');
145
200
  document.getElementById('pageSupport').style.display = 'none';
146
201
  document.getElementById('pageDevices').style.display = 'block';
147
- const cachedAccessories =
202
+ let cachedAccessories =
148
203
  typeof homebridge.getCachedAccessories === 'function'
149
204
  ? await homebridge.getCachedAccessories()
150
205
  : await homebridge.request('/getCachedAccessories');
206
+
207
+ // If no HAP cached accessories were returned, try the Matter cached list using the new native method
208
+ if ((!cachedAccessories || cachedAccessories.length === 0)) {
209
+ try {
210
+ // Use the new native getCachedMatterAccessories() method from @homebridge/plugin-ui-utils v2.1.1-beta.0+
211
+ const matter = typeof homebridge.getCachedMatterAccessories === 'function'
212
+ ? await homebridge.getCachedMatterAccessories()
213
+ : await homebridge.request('/getCachedMatterAccessories'); // Fallback to custom handler for older UI versions
214
+ if (Array.isArray(matter) && matter.length > 0) {
215
+ cachedAccessories = matter
216
+ }
217
+ } catch (e) {
218
+ // ignore
219
+ }
220
+ }
221
+ console.log('Cached Accessories:', cachedAccessories); // Log cached accessories for debugging
151
222
  if (cachedAccessories.length > 0) {
152
223
  cachedAccessories.sort((a, b) => {
153
- return a.displayName.toLowerCase() > b.displayName.toLowerCase() ? 1 : b.displayName.toLowerCase() > a.displayName.toLowerCase() ? -1 : 0;
224
+ return a.displayName.toLowerCase() > b.displayName.toLowerCase()
225
+ ? 1
226
+ : b.displayName.toLowerCase() > a.displayName.toLowerCase()
227
+ ? -1
228
+ : 0;
154
229
  });
155
230
  }
156
231
  const deviceSelect = document.getElementById('deviceSelect');
@@ -158,24 +233,141 @@
158
233
  cachedAccessories.forEach((a) => {
159
234
  const option = document.createElement('option');
160
235
  option.text = a.displayName;
161
- option.value = a.UUID;
236
+ option.value = a.UUID || a.uuid; // Handle both HAP and Matter UUID formats
162
237
  deviceSelect.add(option);
163
238
  });
239
+ const cachedAccessoriesList = document.getElementById('cachedAccessoriesList');
240
+ cachedAccessoriesList.innerHTML = ''; // Clear previous entries
241
+ cachedAccessories.forEach((a) => {
242
+ const listItem = document.createElement('li');
243
+ listItem.textContent = `${a.displayName} (${a.UUID || a.uuid})`;
244
+ cachedAccessoriesList.appendChild(listItem);
245
+ });
246
+ const validateConfig = (config) => {
247
+ const deviceIds = new Set();
248
+ const isValid = config[0].options.devices.every((device) => {
249
+ if (!device.deviceId || typeof device.deviceId !== 'string') {
250
+ homebridge.toast.error(`Invalid device ID: ${device.deviceId}`, 'Error');
251
+ return false;
252
+ }
253
+ if (deviceIds.has(device.deviceId)) {
254
+ homebridge.toast.error(`Duplicate device ID found: ${device.deviceId}`, 'Error');
255
+ return false;
256
+ }
257
+ deviceIds.add(device.deviceId);
258
+ return true;
259
+ });
260
+ return isValid;
261
+ };
262
+
263
+ const addDeviceToConfig = async (deviceId) => {
264
+ try {
265
+ homebridge.showSpinner();
266
+ const currentConfig = await homebridge.getPluginConfig();
267
+ if (!currentConfig[0].options.devices) {
268
+ currentConfig[0].options.devices = [];
269
+ }
270
+ currentConfig[0].options.devices.push({
271
+ deviceId: deviceId.replace(/:/g, ''),
272
+ hide_device: false,
273
+ disablePlatformBLE: false,
274
+ allowPush: false,
275
+ disableCaching: false,
276
+ });
277
+ if (!validateConfig(currentConfig)) {
278
+ homebridge.hideSpinner();
279
+ return;
280
+ }
281
+ await homebridge.updatePluginConfig(currentConfig);
282
+ await homebridge.savePluginConfig();
283
+ homebridge.toast.success('Device added to config successfully!', 'Success');
284
+ } catch (error) {
285
+ homebridge.toast.error('Failed to add device to config!', 'Error');
286
+ } finally {
287
+ homebridge.hideSpinner();
288
+ }
289
+ };
290
+
291
+ const protocolInfo = document.createElement('p');
292
+ protocolInfo.id = 'protocolInfo';
293
+ protocolInfo.style.marginTop = '10px';
294
+ document.getElementById('deviceInfo').appendChild(protocolInfo);
295
+
296
+ const addDeviceButton = document.createElement('button');
297
+ addDeviceButton.textContent = 'Add Device to Config';
298
+ addDeviceButton.className = 'btn btn-success';
299
+ addDeviceButton.style.marginTop = '10px';
300
+ addDeviceButton.addEventListener('click', () => {
301
+ const deviceId = document.getElementById('deviceId').textContent;
302
+ if (deviceId) {
303
+ addDeviceToConfig(deviceId);
304
+ } else {
305
+ homebridge.toast.error('No device ID found!', 'Error');
306
+ }
307
+ });
308
+ document.getElementById('deviceInfo').appendChild(addDeviceButton);
309
+
310
+ const updateTableWithDetails = (deviceContext) => {
311
+ const tableBody = document.querySelector('#deviceTable tbody');
312
+
313
+ Object.entries(deviceContext).forEach(([key, value]) => {
314
+ if (/string|number|boolean/.test(typeof value) && (typeof value !== 'string' || value.trim())) {
315
+ let existingCell = document.getElementById(key);
316
+ if (existingCell) {
317
+ existingCell.textContent = value;
318
+ } else {
319
+ const row = document.createElement('tr');
320
+ const keyCell = document.createElement('th');
321
+ keyCell.scope = 'row';
322
+ keyCell.textContent = key;
323
+ const valueCell = document.createElement('td');
324
+ valueCell.textContent = value;
325
+ row.appendChild(keyCell);
326
+ row.appendChild(valueCell);
327
+ tableBody.appendChild(row);
328
+ }
329
+ }
330
+ });
331
+ };
332
+
333
+ // Ensure the element exists before attempting to set its innerHTML
334
+ const safeSetInnerHTML = (id, value) => {
335
+ const element = document.getElementById(id);
336
+ if (element) {
337
+ element.innerHTML = value;
338
+ } else {
339
+ console.warn(`Element with id '${id}' not found.`);
340
+ }
341
+ };
342
+
164
343
  showDeviceInfo = async (UUID) => {
165
- homebridge.showSpinner();
166
- const thisAcc = cachedAccessories.find((x) => x.UUID === UUID);
167
- const context = thisAcc.context;
168
- document.getElementById('displayName').innerHTML = thisAcc.displayName;
169
- document.getElementById('deviceId').innerHTML = context.deviceId;
170
- document.getElementById('model').innerHTML = context.model;
171
- document.getElementById('version').innerHTML = context.version;
172
- document.getElementById('deviceType').innerHTML = context.deviceType;
173
- document.getElementById('connectionType').innerHTML = context.connectionType;
174
- document.getElementById('refreshRate').innerHTML = context.refreshRate;
175
- document.getElementById('updateRate').innerHTML = context.updateRate;
176
- document.getElementById('pushRate').innerHTML = context.pushRate;
177
- document.getElementById('deviceTable').style.display = 'inline-table';
178
- homebridge.hideSpinner();
344
+ try {
345
+ homebridge.showSpinner();
346
+ const thisAcc = cachedAccessories.find((x) => x.UUID === UUID);
347
+ if (!thisAcc) {
348
+ throw new Error('Device not found');
349
+ }
350
+ const context = thisAcc.context;
351
+ const protocol = thisAcc.isMatter ? 'Matter Protocol' : 'HAP Protocol';
352
+ safeSetInnerHTML('displayName', thisAcc.displayName);
353
+ safeSetInnerHTML('deviceId', context.deviceId);
354
+ safeSetInnerHTML('model', context.model);
355
+ safeSetInnerHTML('version', context.version);
356
+ safeSetInnerHTML('deviceType', context.deviceType);
357
+ safeSetInnerHTML('connectionType', context.connectionType);
358
+ safeSetInnerHTML('refreshRate', context.refreshRate);
359
+ safeSetInnerHTML('updateRate', context.updateRate);
360
+ safeSetInnerHTML('pushRate', context.pushRate);
361
+ safeSetInnerHTML('protocolInfo', protocol);
362
+ document.getElementById('deviceTable').style.display = 'inline-table';
363
+
364
+
365
+ updateTableWithDetails(context);
366
+ } catch (error) {
367
+ homebridge.toast.error(error.message, 'Error');
368
+ } finally {
369
+ homebridge.hideSpinner();
370
+ }
179
371
  };
180
372
  deviceSelect.addEventListener('change', (event) => showDeviceInfo(event.target.value));
181
373
  if (cachedAccessories.length > 0) {
@@ -246,4 +438,12 @@
246
438
  homebridge.hideSpinner();
247
439
  }
248
440
  })();
441
+
442
+ document.getElementById('dynamic-config-tab').addEventListener('click', function() {
443
+ // Hide other tabs
444
+ document.querySelectorAll('.tab-content').forEach(tab => tab.style.display = 'none');
445
+
446
+ // Show Dynamic Config tab
447
+ document.getElementById('dynamic-config-content').style.display = 'block';
448
+ });
249
449
  </script>
@@ -1,42 +1,8 @@
1
- import fs from 'node:fs'
2
-
3
1
  import { HomebridgePluginUiServer } from '@homebridge/plugin-ui-utils'
4
2
 
5
3
  class PluginUiServer extends HomebridgePluginUiServer {
6
4
  constructor() {
7
5
  super()
8
- /*
9
- A native method getCachedAccessories() was introduced in config-ui-x v4.37.0
10
- The following is for users who have a lower version of config-ui-x
11
- */
12
- this.onRequest('getCachedAccessories', () => {
13
- try {
14
- const plugin = 'homebridge-switchbot'
15
- const devicesToReturn = []
16
-
17
- // The path and file of the cached accessories
18
- const accFile = `${this.homebridgeStoragePath}/accessories/cachedAccessories`
19
-
20
- // Check the file exists
21
- if (fs.existsSync(accFile)) {
22
- // read the cached accessories file
23
- const cachedAccessories: any[] = JSON.parse(fs.readFileSync(accFile, 'utf8'))
24
-
25
- cachedAccessories.forEach((accessory: any) => {
26
- // Check the accessory is from this plugin
27
- if (accessory.plugin === plugin) {
28
- // Add the cached accessory to the array
29
- devicesToReturn.push(accessory.accessory as never)
30
- }
31
- })
32
- }
33
- // Return the array
34
- return devicesToReturn
35
- } catch {
36
- // Just return an empty accessory list in case of any errors
37
- return []
38
- }
39
- })
40
6
  this.ready()
41
7
  }
42
8
  }
package/src/index.ts CHANGED
@@ -7,17 +7,11 @@ import type { API } from 'homebridge'
7
7
  import { SwitchBotHAPPlatform } from './platform-hap.js'
8
8
  import { SwitchBotMatterPlatform } from './platform-matter.js'
9
9
  import { PLATFORM_NAME, PLUGIN_NAME } from './settings.js'
10
+ import { createPlatformProxy } from './utils.js'
10
11
 
11
12
  // Register our platform with homebridge.
12
13
  export default (api: API): void => {
13
- // Call the instance method on the runtime `api` object (optional chaining in case
14
- // older homebridge doesn't provide it). Treat undefined as false.
15
- const isMatter = typeof api.isMatterEnabled === 'function'
16
- ? Boolean(api.isMatterEnabled())
17
- : Boolean((api as any).isMatterEnabled)
18
-
19
- const log = (api as any).logger ?? (api as any).log ?? console
20
- log.info?.(`Homebridge SwitchBot Plugin initializing in ${isMatter ? 'Matter' : 'HAP'} mode.`)
21
- // If Matter is enabled register the Matter platform, otherwise use HAP platform.
22
- api.registerPlatform(PLUGIN_NAME, PLATFORM_NAME, isMatter ? SwitchBotMatterPlatform : SwitchBotHAPPlatform)
14
+ // Create and register a small proxy that selects the correct platform (HAP or Matter) at runtime.
15
+ const ProxyCtor = createPlatformProxy(SwitchBotHAPPlatform, SwitchBotMatterPlatform)
16
+ api.registerPlatform(PLUGIN_NAME, PLATFORM_NAME, ProxyCtor as any)
23
17
  }
@@ -276,69 +276,108 @@ export abstract class irdeviceBase {
276
276
  /**
277
277
  * Logging for Device
278
278
  */
279
- async infoLog(...log: any[]): Promise<void> {
280
- if (await this.enablingDeviceLogging()) {
281
- this.log.info(`${this.device.remoteType}: ${this.accessory.displayName}`, String(...log))
279
+ infoLog(...log: any[]): void {
280
+ if (!this.enablingDeviceLogging()) {
281
+ return
282
282
  }
283
+ // Delegate to a single helper that prefers platform-provided loggers.
284
+ this.logWith('info', `${this.device.remoteType}: ${this.accessory.displayName}`, undefined, String(...log))
283
285
  }
284
286
 
285
- async successLog(...log: any[]): Promise<void> {
286
- if (await this.enablingDeviceLogging()) {
287
- this.log.success(`${this.device.remoteType}: ${this.accessory.displayName}`, String(...log))
287
+ successLog(...log: any[]): void {
288
+ if (!this.enablingDeviceLogging()) {
289
+ return
288
290
  }
291
+ this.logWith('success', `${this.device.remoteType}: ${this.accessory.displayName}`, undefined, String(...log))
289
292
  }
290
293
 
291
- async debugSuccessLog(...log: any[]): Promise<void> {
292
- if (await this.enablingDeviceLogging()) {
293
- if (await this.loggingIsDebug()) {
294
- this.log.success(`[DEBUG] ${this.device.remoteType}: ${this.accessory.displayName}`, String(...log))
295
- }
294
+ debugSuccessLog(...log: any[]): void {
295
+ if (!this.enablingDeviceLogging()) {
296
+ return
297
+ }
298
+ if (!this.loggingIsDebug()) {
299
+ return
296
300
  }
301
+ this.logWith('success', `[DEBUG] ${this.device.remoteType}: ${this.accessory.displayName}`, 'debugSuccessLog', String(...log))
297
302
  }
298
303
 
299
- async warnLog(...log: any[]): Promise<void> {
300
- if (await this.enablingDeviceLogging()) {
301
- this.log.warn(`${this.device.remoteType}: ${this.accessory.displayName}`, String(...log))
304
+ warnLog(...log: any[]): void {
305
+ if (!this.enablingDeviceLogging()) {
306
+ return
302
307
  }
308
+ this.logWith('warn', `${this.device.remoteType}: ${this.accessory.displayName}`, undefined, String(...log))
303
309
  }
304
310
 
305
- async debugWarnLog(...log: any[]): Promise<void> {
306
- if (await this.enablingDeviceLogging()) {
307
- if (await this.loggingIsDebug()) {
308
- this.log.warn(`[DEBUG] ${this.device.remoteType}: ${this.accessory.displayName}`, String(...log))
309
- }
311
+ debugWarnLog(...log: any[]): void {
312
+ if (!this.enablingDeviceLogging() || !this.loggingIsDebug()) {
313
+ return
310
314
  }
315
+ this.logWith('warn', `[DEBUG] ${this.device.remoteType}: ${this.accessory.displayName}`, 'debugWarnLog', String(...log))
311
316
  }
312
317
 
313
- async errorLog(...log: any[]): Promise<void> {
314
- if (await this.enablingDeviceLogging()) {
315
- this.log.error(`${this.device.remoteType}: ${this.accessory.displayName}`, String(...log))
318
+ errorLog(...log: any[]): void {
319
+ if (!this.enablingDeviceLogging()) {
320
+ return
316
321
  }
322
+ this.logWith('error', `${this.device.remoteType}: ${this.accessory.displayName}`, undefined, String(...log))
317
323
  }
318
324
 
319
- async debugErrorLog(...log: any[]): Promise<void> {
320
- if (await this.enablingDeviceLogging()) {
321
- if (await this.loggingIsDebug()) {
322
- this.log.error(`[DEBUG] ${this.device.remoteType}: ${this.accessory.displayName}`, String(...log))
323
- }
325
+ debugErrorLog(...log: any[]): void {
326
+ if (!this.enablingDeviceLogging() || !this.loggingIsDebug()) {
327
+ return
324
328
  }
329
+ this.logWith('error', `[DEBUG] ${this.device.remoteType}: ${this.accessory.displayName}`, 'debugErrorLog', String(...log))
325
330
  }
326
331
 
327
- async debugLog(...log: any[]): Promise<void> {
328
- if (await this.enablingDeviceLogging()) {
329
- if (this.deviceLogging === 'debug') {
330
- this.log.info(`[DEBUG] ${this.device.remoteType}: ${this.accessory.displayName}`, String(...log))
331
- } else if (this.deviceLogging === 'debugMode') {
332
- this.log.debug(`${this.device.remoteType}: ${this.accessory.displayName}`, String(...log))
332
+ debugLog(...log: any[]): void {
333
+ if (!this.enablingDeviceLogging()) {
334
+ return
335
+ }
336
+ if (this.deviceLogging === 'debug') {
337
+ this.logWith('debug', `[DEBUG] ${this.device.remoteType}: ${this.accessory.displayName}`, 'debugLog', String(...log))
338
+ } else if (this.deviceLogging === 'debugMode') {
339
+ this.logWith('debug', `${this.device.remoteType}: ${this.accessory.displayName}`, 'debugLog', String(...log))
340
+ }
341
+ }
342
+
343
+ // Generic platform/local logger delegate
344
+ protected logWith(level: string, message: string, platformMethodName?: string, payload?: string): void {
345
+ const method = platformMethodName ?? `${level}Log`
346
+ const pFn = (this.platform as any)?.[method]
347
+ if (typeof pFn === 'function') {
348
+ try {
349
+ if (payload !== undefined) {
350
+ pFn(message, payload)
351
+ } else {
352
+ pFn(message)
353
+ }
354
+ return
355
+ } catch (_err) {
356
+ // fallthrough to local logger
357
+ }
358
+ }
359
+ const map: Record<string, string> = {
360
+ info: 'info',
361
+ success: 'success',
362
+ debug: 'debug',
363
+ warn: 'warn',
364
+ error: 'error',
365
+ }
366
+ const local = (this.log as any)[map[level] ?? level]
367
+ if (typeof local === 'function') {
368
+ if (payload !== undefined) {
369
+ local.call(this.log, message, payload)
370
+ } else {
371
+ local.call(this.log, message)
333
372
  }
334
373
  }
335
374
  }
336
375
 
337
- async loggingIsDebug(): Promise<boolean> {
376
+ loggingIsDebug(): boolean {
338
377
  return this.deviceLogging === 'debugMode' || this.deviceLogging === 'debug'
339
378
  }
340
379
 
341
- async enablingDeviceLogging(): Promise<boolean> {
380
+ enablingDeviceLogging(): boolean {
342
381
  return this.deviceLogging === 'debugMode' || this.deviceLogging === 'debug' || this.deviceLogging === 'standard'
343
382
  }
344
383
  }