@switchbot/homebridge-switchbot 3.6.1-beta.1 → 3.6.1-beta.3

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 (91) hide show
  1. package/CHANGELOG.md +11 -0
  2. package/dist/device/blindtilt.d.ts.map +1 -1
  3. package/dist/device/blindtilt.js +35 -17
  4. package/dist/device/blindtilt.js.map +1 -1
  5. package/dist/device/bot.d.ts +1 -2
  6. package/dist/device/bot.d.ts.map +1 -1
  7. package/dist/device/bot.js +186 -396
  8. package/dist/device/bot.js.map +1 -1
  9. package/dist/device/ceilinglight.d.ts.map +1 -1
  10. package/dist/device/ceilinglight.js +35 -18
  11. package/dist/device/ceilinglight.js.map +1 -1
  12. package/dist/device/colorbulb.d.ts.map +1 -1
  13. package/dist/device/colorbulb.js +43 -19
  14. package/dist/device/colorbulb.js.map +1 -1
  15. package/dist/device/contact.d.ts.map +1 -1
  16. package/dist/device/contact.js +35 -18
  17. package/dist/device/contact.js.map +1 -1
  18. package/dist/device/curtain.d.ts.map +1 -1
  19. package/dist/device/curtain.js +7 -5
  20. package/dist/device/curtain.js.map +1 -1
  21. package/dist/device/device.js +1 -1
  22. package/dist/device/device.js.map +1 -1
  23. package/dist/device/fan.d.ts.map +1 -1
  24. package/dist/device/fan.js +35 -18
  25. package/dist/device/fan.js.map +1 -1
  26. package/dist/device/hub.d.ts.map +1 -1
  27. package/dist/device/hub.js +35 -16
  28. package/dist/device/hub.js.map +1 -1
  29. package/dist/device/humidifier.d.ts.map +1 -1
  30. package/dist/device/humidifier.js +35 -16
  31. package/dist/device/humidifier.js.map +1 -1
  32. package/dist/device/iosensor.d.ts.map +1 -1
  33. package/dist/device/iosensor.js +35 -16
  34. package/dist/device/iosensor.js.map +1 -1
  35. package/dist/device/lightstrip.d.ts.map +1 -1
  36. package/dist/device/lightstrip.js +35 -16
  37. package/dist/device/lightstrip.js.map +1 -1
  38. package/dist/device/lock.d.ts.map +1 -1
  39. package/dist/device/lock.js +36 -17
  40. package/dist/device/lock.js.map +1 -1
  41. package/dist/device/meter.d.ts.map +1 -1
  42. package/dist/device/meter.js +35 -16
  43. package/dist/device/meter.js.map +1 -1
  44. package/dist/device/meterplus.d.ts.map +1 -1
  45. package/dist/device/meterplus.js +35 -16
  46. package/dist/device/meterplus.js.map +1 -1
  47. package/dist/device/motion.d.ts.map +1 -1
  48. package/dist/device/motion.js +35 -16
  49. package/dist/device/motion.js.map +1 -1
  50. package/dist/device/plug.d.ts.map +1 -1
  51. package/dist/device/plug.js +36 -17
  52. package/dist/device/plug.js.map +1 -1
  53. package/dist/device/robotvacuumcleaner.d.ts.map +1 -1
  54. package/dist/device/robotvacuumcleaner.js +35 -16
  55. package/dist/device/robotvacuumcleaner.js.map +1 -1
  56. package/dist/device/waterdetector.d.ts.map +1 -1
  57. package/dist/device/waterdetector.js +35 -16
  58. package/dist/device/waterdetector.js.map +1 -1
  59. package/dist/irdevice/other.d.ts +1 -0
  60. package/dist/irdevice/other.d.ts.map +1 -1
  61. package/dist/irdevice/other.js +186 -228
  62. package/dist/irdevice/other.js.map +1 -1
  63. package/dist/platform.js +2 -2
  64. package/dist/platform.js.map +1 -1
  65. package/dist/utils.d.ts +2 -0
  66. package/dist/utils.d.ts.map +1 -1
  67. package/dist/utils.js +10 -0
  68. package/dist/utils.js.map +1 -1
  69. package/package.json +1 -1
  70. package/src/device/blindtilt.ts +32 -17
  71. package/src/device/bot.ts +179 -406
  72. package/src/device/ceilinglight.ts +32 -19
  73. package/src/device/colorbulb.ts +41 -20
  74. package/src/device/contact.ts +32 -19
  75. package/src/device/curtain.ts +7 -6
  76. package/src/device/device.ts +1 -1
  77. package/src/device/fan.ts +32 -19
  78. package/src/device/hub.ts +32 -16
  79. package/src/device/humidifier.ts +32 -16
  80. package/src/device/iosensor.ts +32 -16
  81. package/src/device/lightstrip.ts +32 -16
  82. package/src/device/lock.ts +33 -17
  83. package/src/device/meter.ts +32 -16
  84. package/src/device/meterplus.ts +32 -16
  85. package/src/device/motion.ts +32 -16
  86. package/src/device/plug.ts +33 -17
  87. package/src/device/robotvacuumcleaner.ts +32 -16
  88. package/src/device/waterdetector.ts +32 -16
  89. package/src/irdevice/other.ts +214 -283
  90. package/src/platform.ts +2 -2
  91. package/src/utils.ts +11 -0
package/src/platform.ts CHANGED
@@ -330,9 +330,9 @@ export class SwitchBotPlatform implements DynamicPlatformPlugin {
330
330
  // Set an event handler to monitor advertisement packets
331
331
  switchbot.onadvertisement = async (ad: any) => {
332
332
  try {
333
- this.bleEventHandler[ad.id]?.(ad);
333
+ this.bleEventHandler[ad.address]?.(ad.serviceData);
334
334
  } catch (e: any) {
335
- this.errorLog(`Failed to handle BLE event. Error:${e}`);
335
+ await this.errorLog(`Failed to handle BLE event. Error:${e}`);
336
336
  }
337
337
  };
338
338
  })();
package/src/utils.ts CHANGED
@@ -115,6 +115,7 @@ export enum BlindTiltMappingMode {
115
115
  UseTiltForDirection = 'use_tilt_for_direction',
116
116
  }
117
117
 
118
+ import type { Nullable, CharacteristicValue } from 'homebridge';
118
119
  import type { devicesConfig } from './settings.js';
119
120
  import type { blindTilt, curtain, curtain3, device } from './types/devicelist.js';
120
121
 
@@ -130,6 +131,16 @@ export function sleep(ms: number): Promise<void> {
130
131
  return new Promise((resolve) => setTimeout(resolve, ms));
131
132
  }
132
133
 
134
+ export function checkName(displayName: string, name: string, value: Nullable<CharacteristicValue>): string {
135
+ if (typeof value === 'string' && !(new RegExp(/^[\p{L}\p{N}][\p{L}\p{N} ']*[\p{L}\p{N}]$/u)).test(value)) {
136
+ return `WARNING: The accessory '${displayName}' has an invalid '${name}' characteristic ('${value}'). Please use only alphanumeric, space, and`
137
+ + ' apostrophe characters. Ensure it starts and ends with an alphabetic or numeric character, and avoid emojis. This may prevent the accessory '
138
+ + 'from being added in the Home App or cause unresponsiveness.';
139
+ } else {
140
+ return 'false';
141
+ }
142
+ }
143
+
133
144
  /**
134
145
  * Converts the value to celsius if the temperature units are in Fahrenheit
135
146
  **/