@switchbot/homebridge-switchbot 3.5.1-beta.2 → 3.5.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 (187) hide show
  1. package/dist/device/blindtilt.d.ts +15 -6
  2. package/dist/device/blindtilt.d.ts.map +1 -1
  3. package/dist/device/blindtilt.js +203 -255
  4. package/dist/device/blindtilt.js.map +1 -1
  5. package/dist/device/bot.d.ts +9 -4
  6. package/dist/device/bot.d.ts.map +1 -1
  7. package/dist/device/bot.js +196 -218
  8. package/dist/device/bot.js.map +1 -1
  9. package/dist/device/ceilinglight.d.ts +9 -4
  10. package/dist/device/ceilinglight.d.ts.map +1 -1
  11. package/dist/device/ceilinglight.js +202 -247
  12. package/dist/device/ceilinglight.js.map +1 -1
  13. package/dist/device/colorbulb.d.ts +10 -5
  14. package/dist/device/colorbulb.d.ts.map +1 -1
  15. package/dist/device/colorbulb.js +329 -378
  16. package/dist/device/colorbulb.js.map +1 -1
  17. package/dist/device/contact.d.ts +9 -4
  18. package/dist/device/contact.d.ts.map +1 -1
  19. package/dist/device/contact.js +99 -142
  20. package/dist/device/contact.js.map +1 -1
  21. package/dist/device/curtain.d.ts +19 -7
  22. package/dist/device/curtain.d.ts.map +1 -1
  23. package/dist/device/curtain.js +203 -264
  24. package/dist/device/curtain.js.map +1 -1
  25. package/dist/device/device.d.ts +28 -32
  26. package/dist/device/device.d.ts.map +1 -1
  27. package/dist/device/device.js +186 -225
  28. package/dist/device/device.js.map +1 -1
  29. package/dist/device/fan.d.ts +9 -4
  30. package/dist/device/fan.d.ts.map +1 -1
  31. package/dist/device/fan.js +198 -227
  32. package/dist/device/fan.js.map +1 -1
  33. package/dist/device/hub.d.ts +9 -5
  34. package/dist/device/hub.d.ts.map +1 -1
  35. package/dist/device/hub.js +106 -231
  36. package/dist/device/hub.js.map +1 -1
  37. package/dist/device/humidifier.d.ts +12 -4
  38. package/dist/device/humidifier.d.ts.map +1 -1
  39. package/dist/device/humidifier.js +192 -232
  40. package/dist/device/humidifier.js.map +1 -1
  41. package/dist/device/iosensor.d.ts +9 -4
  42. package/dist/device/iosensor.d.ts.map +1 -1
  43. package/dist/device/iosensor.js +91 -157
  44. package/dist/device/iosensor.js.map +1 -1
  45. package/dist/device/lightstrip.d.ts +10 -5
  46. package/dist/device/lightstrip.d.ts.map +1 -1
  47. package/dist/device/lightstrip.js +287 -367
  48. package/dist/device/lightstrip.js.map +1 -1
  49. package/dist/device/lock.d.ts +10 -5
  50. package/dist/device/lock.d.ts.map +1 -1
  51. package/dist/device/lock.js +171 -216
  52. package/dist/device/lock.js.map +1 -1
  53. package/dist/device/meter.d.ts +9 -4
  54. package/dist/device/meter.d.ts.map +1 -1
  55. package/dist/device/meter.js +93 -158
  56. package/dist/device/meter.js.map +1 -1
  57. package/dist/device/meterplus.d.ts +9 -4
  58. package/dist/device/meterplus.d.ts.map +1 -1
  59. package/dist/device/meterplus.js +94 -155
  60. package/dist/device/meterplus.js.map +1 -1
  61. package/dist/device/motion.d.ts +9 -4
  62. package/dist/device/motion.d.ts.map +1 -1
  63. package/dist/device/motion.js +84 -142
  64. package/dist/device/motion.js.map +1 -1
  65. package/dist/device/plug.d.ts +9 -4
  66. package/dist/device/plug.d.ts.map +1 -1
  67. package/dist/device/plug.js +99 -124
  68. package/dist/device/plug.js.map +1 -1
  69. package/dist/device/robotvacuumcleaner.d.ts +9 -6
  70. package/dist/device/robotvacuumcleaner.d.ts.map +1 -1
  71. package/dist/device/robotvacuumcleaner.js +170 -253
  72. package/dist/device/robotvacuumcleaner.js.map +1 -1
  73. package/dist/device/waterdetector.d.ts +12 -4
  74. package/dist/device/waterdetector.d.ts.map +1 -1
  75. package/dist/device/waterdetector.js +102 -128
  76. package/dist/device/waterdetector.js.map +1 -1
  77. package/dist/irdevice/airconditioner.d.ts +2 -1
  78. package/dist/irdevice/airconditioner.d.ts.map +1 -1
  79. package/dist/irdevice/airconditioner.js.map +1 -1
  80. package/dist/irdevice/airpurifier.d.ts +2 -1
  81. package/dist/irdevice/airpurifier.d.ts.map +1 -1
  82. package/dist/irdevice/airpurifier.js.map +1 -1
  83. package/dist/irdevice/camera.d.ts +2 -1
  84. package/dist/irdevice/camera.d.ts.map +1 -1
  85. package/dist/irdevice/camera.js.map +1 -1
  86. package/dist/irdevice/fan.d.ts +2 -1
  87. package/dist/irdevice/fan.d.ts.map +1 -1
  88. package/dist/irdevice/fan.js.map +1 -1
  89. package/dist/irdevice/irdevice.d.ts +2 -1
  90. package/dist/irdevice/irdevice.d.ts.map +1 -1
  91. package/dist/irdevice/irdevice.js +1 -1
  92. package/dist/irdevice/irdevice.js.map +1 -1
  93. package/dist/irdevice/light.d.ts +2 -1
  94. package/dist/irdevice/light.d.ts.map +1 -1
  95. package/dist/irdevice/light.js.map +1 -1
  96. package/dist/irdevice/other.d.ts +2 -1
  97. package/dist/irdevice/other.d.ts.map +1 -1
  98. package/dist/irdevice/other.js.map +1 -1
  99. package/dist/irdevice/tv.d.ts +2 -1
  100. package/dist/irdevice/tv.d.ts.map +1 -1
  101. package/dist/irdevice/tv.js.map +1 -1
  102. package/dist/irdevice/vacuumcleaner.d.ts +2 -1
  103. package/dist/irdevice/vacuumcleaner.d.ts.map +1 -1
  104. package/dist/irdevice/vacuumcleaner.js.map +1 -1
  105. package/dist/irdevice/waterheater.d.ts +2 -1
  106. package/dist/irdevice/waterheater.d.ts.map +1 -1
  107. package/dist/irdevice/waterheater.js.map +1 -1
  108. package/dist/platform.d.ts +5 -7
  109. package/dist/platform.d.ts.map +1 -1
  110. package/dist/platform.js +51 -34
  111. package/dist/platform.js.map +1 -1
  112. package/dist/settings.d.ts +49 -191
  113. package/dist/settings.d.ts.map +1 -1
  114. package/dist/settings.js +19 -0
  115. package/dist/settings.js.map +1 -1
  116. package/dist/types/bledevicestatus.d.ts +279 -0
  117. package/dist/types/bledevicestatus.d.ts.map +1 -0
  118. package/dist/types/bledevicestatus.js +2 -0
  119. package/dist/types/bledevicestatus.js.map +1 -0
  120. package/dist/types/devicelist.d.ts +89 -0
  121. package/dist/types/devicelist.d.ts.map +1 -0
  122. package/dist/types/devicelist.js +6 -0
  123. package/dist/types/devicelist.js.map +1 -0
  124. package/dist/types/deviceresponse.d.ts +13 -0
  125. package/dist/types/deviceresponse.d.ts.map +1 -0
  126. package/dist/types/deviceresponse.js +2 -0
  127. package/dist/types/deviceresponse.js.map +1 -0
  128. package/dist/types/devicestatus.d.ts +149 -0
  129. package/dist/types/devicestatus.d.ts.map +1 -0
  130. package/dist/types/devicestatus.js +3 -0
  131. package/dist/types/devicestatus.js.map +1 -0
  132. package/dist/types/devicewebhookstatus.d.ts +156 -0
  133. package/dist/types/devicewebhookstatus.d.ts.map +1 -0
  134. package/dist/types/devicewebhookstatus.js +2 -0
  135. package/dist/types/devicewebhookstatus.js.map +1 -0
  136. package/dist/types/irdevicelist.d.ts +10 -0
  137. package/dist/types/irdevicelist.d.ts.map +1 -0
  138. package/dist/types/irdevicelist.js +2 -0
  139. package/dist/types/irdevicelist.js.map +1 -0
  140. package/dist/types/pushbody.d.ts +6 -0
  141. package/dist/types/pushbody.d.ts.map +1 -0
  142. package/dist/types/pushbody.js +2 -0
  143. package/dist/types/pushbody.js.map +1 -0
  144. package/dist/utils.d.ts +25 -0
  145. package/dist/utils.d.ts.map +1 -1
  146. package/dist/utils.js +28 -0
  147. package/dist/utils.js.map +1 -1
  148. package/package.json +10 -10
  149. package/src/device/blindtilt.ts +223 -263
  150. package/src/device/bot.ts +208 -221
  151. package/src/device/ceilinglight.ts +210 -257
  152. package/src/device/colorbulb.ts +334 -397
  153. package/src/device/contact.ts +111 -146
  154. package/src/device/curtain.ts +220 -283
  155. package/src/device/device.ts +194 -245
  156. package/src/device/fan.ts +214 -230
  157. package/src/device/hub.ts +126 -246
  158. package/src/device/humidifier.ts +216 -243
  159. package/src/device/iosensor.ts +114 -166
  160. package/src/device/lightstrip.ts +302 -377
  161. package/src/device/lock.ts +187 -221
  162. package/src/device/meter.ts +116 -177
  163. package/src/device/meterplus.ts +117 -174
  164. package/src/device/motion.ts +99 -144
  165. package/src/device/plug.ts +110 -128
  166. package/src/device/robotvacuumcleaner.ts +189 -252
  167. package/src/device/waterdetector.ts +120 -138
  168. package/src/irdevice/airconditioner.ts +2 -1
  169. package/src/irdevice/airpurifier.ts +2 -1
  170. package/src/irdevice/camera.ts +2 -1
  171. package/src/irdevice/fan.ts +2 -1
  172. package/src/irdevice/irdevice.ts +3 -2
  173. package/src/irdevice/light.ts +2 -1
  174. package/src/irdevice/other.ts +2 -1
  175. package/src/irdevice/tv.ts +2 -1
  176. package/src/irdevice/vacuumcleaner.ts +2 -1
  177. package/src/irdevice/waterheater.ts +2 -1
  178. package/src/platform.ts +52 -34
  179. package/src/settings.ts +30 -239
  180. package/src/types/bledevicestatus.ts +305 -0
  181. package/src/types/devicelist.ts +124 -0
  182. package/src/types/deviceresponse.ts +15 -0
  183. package/src/types/devicestatus.ts +178 -0
  184. package/src/types/devicewebhookstatus.ts +196 -0
  185. package/src/types/irdevicelist.ts +15 -0
  186. package/src/types/pushbody.ts +9 -0
  187. package/src/utils.ts +33 -0
@@ -0,0 +1,196 @@
1
+ /* Copyright(C) 2017-2024, donavanbecker (https://github.com/donavanbecker). All rights reserved.
2
+ *
3
+ * devicestatus.ts: @switchbot/homebridge-switchbot platform class.
4
+ */
5
+ export { deviceWebhook };
6
+
7
+ type deviceWebhook = {
8
+ eventType: string,
9
+ eventVersion: string,
10
+ context: deviceWebhookContext
11
+ };
12
+
13
+ type deviceWebhookContext = {
14
+ //properties on all devices
15
+ deviceMac: string;
16
+ deviceType: string;
17
+ timeOfSample: number
18
+ };
19
+
20
+ export type botWebhookContext = deviceWebhookContext & {
21
+ power: string, //"on"or"off"
22
+ battery: number,
23
+ deviceMode: 'pressMode' | 'switchMode' | 'customizeMode',
24
+ };
25
+
26
+ export type curtainWebhookContext = deviceWebhookContext & {
27
+ calibrate: boolean,
28
+ group: boolean,
29
+ slidePosition: number, //0~100
30
+ battery: number,
31
+ };
32
+
33
+ export type curtain3WebhookContext = deviceWebhookContext & {
34
+ calibrate: boolean,
35
+ group: boolean,
36
+ slidePosition: number, //0~100
37
+ battery: number,
38
+ };
39
+
40
+ export type motionSensorWebhookContext = deviceWebhookContext & {
41
+ detectionState: 'NOT_DETECTED' | 'DETECTED',
42
+ };
43
+
44
+ export type contactSensorWebhookContext = deviceWebhookContext & {
45
+ detectionState: 'NOT_DETECTED' | 'DETECTED',
46
+ doorMode: 'IN_DOOR' | 'OUT_DOOR',
47
+ brightness: 'dim' | 'bright',
48
+ openState: 'open' | 'close' | 'timeOutNotClose',
49
+ };
50
+
51
+ export type waterLeakDetectorWebhookContext = deviceWebhookContext & {
52
+ detectionState: 0 | 1,
53
+ battery: number, //0~100
54
+ };
55
+
56
+ export type meterWebhookContext = deviceWebhookContext & {
57
+ temperature: number,
58
+ scale: 'CELSIUS' | 'FAHRENHEIT',
59
+ humidity: number,
60
+ };
61
+
62
+ export type meterPlusWebhookContext = deviceWebhookContext & {
63
+ temperature: number,
64
+ scale: 'CELSIUS' | 'FAHRENHEIT',
65
+ humidity: number,
66
+ };
67
+
68
+ export type outdoorMeterWebhookContext = deviceWebhookContext & {
69
+ temperature: number,
70
+ scale: 'CELSIUS' | 'FAHRENHEIT',
71
+ humidity: number,
72
+ };
73
+
74
+ export type lockWebhookContext = deviceWebhookContext & {
75
+ lockState: 'UNLOCKED' | 'LOCKED' | 'JAMMED',
76
+ };
77
+
78
+ export type lockProWebhookContext = deviceWebhookContext & {
79
+ lockState: 'UNLOCKED' | 'LOCKED' | 'JAMMED',
80
+ };
81
+
82
+ export type indoorCameraWebhookContext = deviceWebhookContext & {
83
+ detectionState: 'DETECTED',
84
+ };
85
+
86
+ export type panTiltCamWebhookContext = deviceWebhookContext & {
87
+ detectionState: 'DETECTED',
88
+ };
89
+
90
+ export type colorBulbWebhookContext = deviceWebhookContext & {
91
+ powerState: 'ON' | 'OFF',
92
+ brightness: number,
93
+ color: string, //RGB 255:255:255
94
+ colorTemperature: number, // 2700~6500
95
+ };
96
+
97
+ export type stripLightWebhookContext = deviceWebhookContext & {
98
+ powerState: 'ON' | 'OFF',
99
+ brightness: number,
100
+ color: string, //RGB 255:255:255
101
+ };
102
+
103
+ export type plugWebhookContext = deviceWebhookContext & {
104
+ powerState: 'ON' | 'OFF',
105
+ };
106
+
107
+ export type plugMiniUSWebhookContext = deviceWebhookContext & {
108
+ powerState: 'ON' | 'OFF',
109
+ };
110
+
111
+ export type plugMiniJPWebhookContext = deviceWebhookContext & {
112
+ powerState: 'ON' | 'OFF',
113
+ };
114
+
115
+ export type robotVacuumCleanerS1WebhookContext = deviceWebhookContext & {
116
+ workingStatus: 'Standby' | 'Clearing' | 'Paused' | 'GotoChargeBase' | 'Charging' | 'ChargeDone' | 'Dormant' | 'InTrouble'
117
+ | 'InRemoteControl' | 'InDustCollecting',
118
+ onlineStatus: 'online' | 'offline',
119
+ battery: number, //0~100
120
+ };
121
+
122
+ export type robotVacuumCleanerS1PlusWebhookContext = deviceWebhookContext & {
123
+ workingStatus: 'Standby' | 'Clearing' | 'Paused' | 'GotoChargeBase' | 'Charging' | 'ChargeDone' | 'Dormant' | 'InTrouble'
124
+ | 'InRemoteControl' | 'InDustCollecting',
125
+ onlineStatus: 'online' | 'offline',
126
+ battery: number, //0~100
127
+ };
128
+
129
+ export type floorCleaningRobotS10WebhookContext = deviceWebhookContext & {
130
+ workingStatus: 'Standby' | 'Clearing' | 'Paused' | 'GotoChargeBase' | 'Charging' | 'ChargeDone' | 'Dormant' | 'InTrouble'
131
+ | 'InRemoteControl' | 'InDustCollecting',
132
+ onlineStatus: 'online' | 'offline',
133
+ battery: number, //0~100
134
+ waterBaseBattery: number, //0~100
135
+ taskType: 'standBy' | 'explore' | 'cleanAll' | 'cleanArea' | 'cleanRoom' | 'fillWater' | 'deepWashing' | 'backToCharge' | 'markingWaterBase'
136
+ | 'drying' | 'collectDust' | 'remoteControl' | 'cleanWithExplorer' | 'fillWaterForHumi' | 'markingHumi',
137
+ };
138
+
139
+ export type ceilingLightWebhookContext = deviceWebhookContext & {
140
+ powerState: 'ON' | 'OFF',
141
+ brightness: number,
142
+ colorTemperature: number, // 2700~6500
143
+ };
144
+
145
+ export type ceilingLightProWebhookContext = deviceWebhookContext & {
146
+ powerState: 'ON' | 'OFF',
147
+ brightness: number,
148
+ colorTemperature: number, // 2700~6500
149
+ };
150
+
151
+ export type keypadWebhookContext = deviceWebhookContext & {
152
+ eventName: 'createKey' | 'deleteKey',
153
+ commandId: string,
154
+ result: 'success' | 'failed' | 'timeout',
155
+ };
156
+
157
+ export type keypadTouchWebhookContext = deviceWebhookContext & {
158
+ eventName: 'createKey' | 'deleteKey',
159
+ commandId: string,
160
+ result: 'success' | 'failed' | 'timeout',
161
+ };
162
+
163
+ export type hub2WebhookContext = deviceWebhookContext & {
164
+ temperature: number,
165
+ humidity: number,
166
+ lightLevel: number,
167
+ scale: 'CELSIUS' | 'FAHRENHEIT',
168
+ };
169
+
170
+ export type batteryCirculatorFanWebhookContext = deviceWebhookContext & {
171
+ mode: 'direct' | 'natural' | 'sleep' | 'baby',
172
+ version: string,
173
+ battery: number,
174
+ powerState: 'ON' | 'OFF',
175
+ nightStatus: 'off' | 1 | 2,
176
+ oscillation: 'on' | 'off',
177
+ verticalOscillation: 'on' | 'off',
178
+ chargingStatus: 'charging' | 'uncharged',
179
+ fanSpeed: number, //1~100
180
+ };
181
+
182
+ export type blindTiltWebhookContext = deviceWebhookContext & {
183
+ version: string,
184
+ calibrate: boolean,
185
+ group: boolean,
186
+ direction: string,
187
+ slidePosition: number, //0~100
188
+ battery: number,
189
+ };
190
+
191
+ export type humidifierWebhookContext = deviceWebhookContext & {
192
+ temperature: number,
193
+ humidity: number,
194
+ scale: 'CELSIUS' | 'FAHRENHEIT',
195
+ };
196
+
@@ -0,0 +1,15 @@
1
+ /* Copyright(C) 2017-2024, donavanbecker (https://github.com/donavanbecker). All rights reserved.
2
+ *
3
+ * irdevicelist.ts: @switchbot/homebridge-switchbot platform class.
4
+ */
5
+ //a list of virtual infrared remote devices that are linked to SwitchBot Hubs.
6
+ export type infraredRemoteList = {
7
+ device: irdevice[];
8
+ };
9
+
10
+ export type irdevice = {
11
+ deviceId?: string;
12
+ deviceName: string;
13
+ remoteType: string;
14
+ hubDeviceId: string;
15
+ };
@@ -0,0 +1,9 @@
1
+ /* Copyright(C) 2017-2024, donavanbecker (https://github.com/donavanbecker). All rights reserved.
2
+ *
3
+ * pushbody.ts: @switchbot/homebridge-switchbot platform class.
4
+ */
5
+ export type body = {
6
+ command: string;
7
+ parameter: string;
8
+ commandType: string;
9
+ };
package/src/utils.ts CHANGED
@@ -85,6 +85,28 @@ export enum SwitchBotBLEModelName {
85
85
  Unknown = 'Unknown',
86
86
  }
87
87
 
88
+ export enum SwitchBotBLEModelFriendlyName {
89
+ Bot = 'Bot',
90
+ Hub2 = 'Hub 2',
91
+ ColorBulb = 'Color Bulb',
92
+ Curtain = 'Curtain',
93
+ Curtain3 = 'Curtain 3',
94
+ Humidifier = 'Humidifier',
95
+ Meter = 'Meter',
96
+ Lock = 'Lock',
97
+ LockPro = 'Lock Pro',
98
+ PlugMini = 'Plug Mini',
99
+ StripLight = 'Strip Light',
100
+ MeterPlus = 'Meter Plus',
101
+ OutdoorMeter = 'Outdoor Meter',
102
+ ContactSensor = 'Contact Sensor',
103
+ MotionSensor = 'Motion Sensor',
104
+ BlindTilt = 'Blind Tilt',
105
+ CeilingLight = 'Ceiling Light',
106
+ CeilingLightPro = 'Ceiling Light Pro',
107
+ Unknown = 'Unknown',
108
+ }
109
+
88
110
  export enum BlindTiltMappingMode {
89
111
  OnlyUp = 'only_up',
90
112
  OnlyDown = 'only_down',
@@ -93,6 +115,17 @@ export enum BlindTiltMappingMode {
93
115
  UseTiltForDirection = 'use_tilt_for_direction',
94
116
  }
95
117
 
118
+ import type { devicesConfig } from './settings.js';
119
+ import type { blindTilt, curtain, curtain3, device } from './types/devicelist.js';
120
+
121
+ export function isCurtainDevice(device: device & devicesConfig): device is (curtain | curtain3) & devicesConfig {
122
+ return device.deviceType === 'Curtain' || device.deviceType === 'Curtain3';
123
+ }
124
+
125
+ export function isBlindTiltDevice(device: device & devicesConfig): device is blindTilt & devicesConfig {
126
+ return device.deviceType === 'Blind Tilt';
127
+ }
128
+
96
129
  export function sleep(ms: number): Promise<void> {
97
130
  return new Promise((resolve) => setTimeout(resolve, ms));
98
131
  }