@switchbot/homebridge-switchbot 3.5.1-beta.1 → 3.5.1-beta.10

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 (188) hide show
  1. package/README.md +16 -0
  2. package/dist/device/blindtilt.d.ts +15 -6
  3. package/dist/device/blindtilt.d.ts.map +1 -1
  4. package/dist/device/blindtilt.js +203 -255
  5. package/dist/device/blindtilt.js.map +1 -1
  6. package/dist/device/bot.d.ts +9 -4
  7. package/dist/device/bot.d.ts.map +1 -1
  8. package/dist/device/bot.js +196 -218
  9. package/dist/device/bot.js.map +1 -1
  10. package/dist/device/ceilinglight.d.ts +9 -4
  11. package/dist/device/ceilinglight.d.ts.map +1 -1
  12. package/dist/device/ceilinglight.js +202 -247
  13. package/dist/device/ceilinglight.js.map +1 -1
  14. package/dist/device/colorbulb.d.ts +10 -5
  15. package/dist/device/colorbulb.d.ts.map +1 -1
  16. package/dist/device/colorbulb.js +329 -378
  17. package/dist/device/colorbulb.js.map +1 -1
  18. package/dist/device/contact.d.ts +9 -4
  19. package/dist/device/contact.d.ts.map +1 -1
  20. package/dist/device/contact.js +99 -142
  21. package/dist/device/contact.js.map +1 -1
  22. package/dist/device/curtain.d.ts +19 -7
  23. package/dist/device/curtain.d.ts.map +1 -1
  24. package/dist/device/curtain.js +203 -264
  25. package/dist/device/curtain.js.map +1 -1
  26. package/dist/device/device.d.ts +28 -32
  27. package/dist/device/device.d.ts.map +1 -1
  28. package/dist/device/device.js +186 -225
  29. package/dist/device/device.js.map +1 -1
  30. package/dist/device/fan.d.ts +9 -4
  31. package/dist/device/fan.d.ts.map +1 -1
  32. package/dist/device/fan.js +198 -227
  33. package/dist/device/fan.js.map +1 -1
  34. package/dist/device/hub.d.ts +9 -5
  35. package/dist/device/hub.d.ts.map +1 -1
  36. package/dist/device/hub.js +106 -231
  37. package/dist/device/hub.js.map +1 -1
  38. package/dist/device/humidifier.d.ts +12 -4
  39. package/dist/device/humidifier.d.ts.map +1 -1
  40. package/dist/device/humidifier.js +192 -232
  41. package/dist/device/humidifier.js.map +1 -1
  42. package/dist/device/iosensor.d.ts +9 -4
  43. package/dist/device/iosensor.d.ts.map +1 -1
  44. package/dist/device/iosensor.js +91 -157
  45. package/dist/device/iosensor.js.map +1 -1
  46. package/dist/device/lightstrip.d.ts +10 -5
  47. package/dist/device/lightstrip.d.ts.map +1 -1
  48. package/dist/device/lightstrip.js +287 -367
  49. package/dist/device/lightstrip.js.map +1 -1
  50. package/dist/device/lock.d.ts +10 -5
  51. package/dist/device/lock.d.ts.map +1 -1
  52. package/dist/device/lock.js +171 -216
  53. package/dist/device/lock.js.map +1 -1
  54. package/dist/device/meter.d.ts +9 -4
  55. package/dist/device/meter.d.ts.map +1 -1
  56. package/dist/device/meter.js +93 -158
  57. package/dist/device/meter.js.map +1 -1
  58. package/dist/device/meterplus.d.ts +9 -4
  59. package/dist/device/meterplus.d.ts.map +1 -1
  60. package/dist/device/meterplus.js +94 -155
  61. package/dist/device/meterplus.js.map +1 -1
  62. package/dist/device/motion.d.ts +9 -4
  63. package/dist/device/motion.d.ts.map +1 -1
  64. package/dist/device/motion.js +84 -142
  65. package/dist/device/motion.js.map +1 -1
  66. package/dist/device/plug.d.ts +9 -4
  67. package/dist/device/plug.d.ts.map +1 -1
  68. package/dist/device/plug.js +99 -124
  69. package/dist/device/plug.js.map +1 -1
  70. package/dist/device/robotvacuumcleaner.d.ts +9 -6
  71. package/dist/device/robotvacuumcleaner.d.ts.map +1 -1
  72. package/dist/device/robotvacuumcleaner.js +170 -253
  73. package/dist/device/robotvacuumcleaner.js.map +1 -1
  74. package/dist/device/waterdetector.d.ts +12 -4
  75. package/dist/device/waterdetector.d.ts.map +1 -1
  76. package/dist/device/waterdetector.js +105 -129
  77. package/dist/device/waterdetector.js.map +1 -1
  78. package/dist/irdevice/airconditioner.d.ts +2 -1
  79. package/dist/irdevice/airconditioner.d.ts.map +1 -1
  80. package/dist/irdevice/airconditioner.js.map +1 -1
  81. package/dist/irdevice/airpurifier.d.ts +2 -1
  82. package/dist/irdevice/airpurifier.d.ts.map +1 -1
  83. package/dist/irdevice/airpurifier.js.map +1 -1
  84. package/dist/irdevice/camera.d.ts +2 -1
  85. package/dist/irdevice/camera.d.ts.map +1 -1
  86. package/dist/irdevice/camera.js.map +1 -1
  87. package/dist/irdevice/fan.d.ts +2 -1
  88. package/dist/irdevice/fan.d.ts.map +1 -1
  89. package/dist/irdevice/fan.js.map +1 -1
  90. package/dist/irdevice/irdevice.d.ts +2 -1
  91. package/dist/irdevice/irdevice.d.ts.map +1 -1
  92. package/dist/irdevice/irdevice.js +1 -1
  93. package/dist/irdevice/irdevice.js.map +1 -1
  94. package/dist/irdevice/light.d.ts +2 -1
  95. package/dist/irdevice/light.d.ts.map +1 -1
  96. package/dist/irdevice/light.js.map +1 -1
  97. package/dist/irdevice/other.d.ts +2 -1
  98. package/dist/irdevice/other.d.ts.map +1 -1
  99. package/dist/irdevice/other.js.map +1 -1
  100. package/dist/irdevice/tv.d.ts +2 -1
  101. package/dist/irdevice/tv.d.ts.map +1 -1
  102. package/dist/irdevice/tv.js.map +1 -1
  103. package/dist/irdevice/vacuumcleaner.d.ts +2 -1
  104. package/dist/irdevice/vacuumcleaner.d.ts.map +1 -1
  105. package/dist/irdevice/vacuumcleaner.js.map +1 -1
  106. package/dist/irdevice/waterheater.d.ts +2 -1
  107. package/dist/irdevice/waterheater.d.ts.map +1 -1
  108. package/dist/irdevice/waterheater.js.map +1 -1
  109. package/dist/platform.d.ts +14 -14
  110. package/dist/platform.d.ts.map +1 -1
  111. package/dist/platform.js +102 -86
  112. package/dist/platform.js.map +1 -1
  113. package/dist/settings.d.ts +49 -191
  114. package/dist/settings.d.ts.map +1 -1
  115. package/dist/settings.js +19 -0
  116. package/dist/settings.js.map +1 -1
  117. package/dist/types/bledevicestatus.d.ts +279 -0
  118. package/dist/types/bledevicestatus.d.ts.map +1 -0
  119. package/dist/types/bledevicestatus.js +2 -0
  120. package/dist/types/bledevicestatus.js.map +1 -0
  121. package/dist/types/devicelist.d.ts +89 -0
  122. package/dist/types/devicelist.d.ts.map +1 -0
  123. package/dist/types/devicelist.js +6 -0
  124. package/dist/types/devicelist.js.map +1 -0
  125. package/dist/types/deviceresponse.d.ts +13 -0
  126. package/dist/types/deviceresponse.d.ts.map +1 -0
  127. package/dist/types/deviceresponse.js +2 -0
  128. package/dist/types/deviceresponse.js.map +1 -0
  129. package/dist/types/devicestatus.d.ts +149 -0
  130. package/dist/types/devicestatus.d.ts.map +1 -0
  131. package/dist/types/devicestatus.js +3 -0
  132. package/dist/types/devicestatus.js.map +1 -0
  133. package/dist/types/devicewebhookstatus.d.ts +156 -0
  134. package/dist/types/devicewebhookstatus.d.ts.map +1 -0
  135. package/dist/types/devicewebhookstatus.js +2 -0
  136. package/dist/types/devicewebhookstatus.js.map +1 -0
  137. package/dist/types/irdevicelist.d.ts +10 -0
  138. package/dist/types/irdevicelist.d.ts.map +1 -0
  139. package/dist/types/irdevicelist.js +2 -0
  140. package/dist/types/irdevicelist.js.map +1 -0
  141. package/dist/types/pushbody.d.ts +6 -0
  142. package/dist/types/pushbody.d.ts.map +1 -0
  143. package/dist/types/pushbody.js +2 -0
  144. package/dist/types/pushbody.js.map +1 -0
  145. package/dist/utils.d.ts +25 -0
  146. package/dist/utils.d.ts.map +1 -1
  147. package/dist/utils.js +28 -0
  148. package/dist/utils.js.map +1 -1
  149. package/package.json +10 -10
  150. package/src/device/blindtilt.ts +224 -264
  151. package/src/device/bot.ts +208 -221
  152. package/src/device/ceilinglight.ts +210 -257
  153. package/src/device/colorbulb.ts +334 -397
  154. package/src/device/contact.ts +111 -146
  155. package/src/device/curtain.ts +220 -283
  156. package/src/device/device.ts +194 -245
  157. package/src/device/fan.ts +214 -230
  158. package/src/device/hub.ts +126 -246
  159. package/src/device/humidifier.ts +216 -243
  160. package/src/device/iosensor.ts +114 -166
  161. package/src/device/lightstrip.ts +302 -377
  162. package/src/device/lock.ts +187 -221
  163. package/src/device/meter.ts +116 -177
  164. package/src/device/meterplus.ts +117 -174
  165. package/src/device/motion.ts +99 -144
  166. package/src/device/plug.ts +110 -128
  167. package/src/device/robotvacuumcleaner.ts +189 -252
  168. package/src/device/waterdetector.ts +123 -139
  169. package/src/irdevice/airconditioner.ts +2 -1
  170. package/src/irdevice/airpurifier.ts +2 -1
  171. package/src/irdevice/camera.ts +2 -1
  172. package/src/irdevice/fan.ts +2 -1
  173. package/src/irdevice/irdevice.ts +3 -2
  174. package/src/irdevice/light.ts +2 -1
  175. package/src/irdevice/other.ts +2 -1
  176. package/src/irdevice/tv.ts +2 -1
  177. package/src/irdevice/vacuumcleaner.ts +2 -1
  178. package/src/irdevice/waterheater.ts +2 -1
  179. package/src/platform.ts +104 -87
  180. package/src/settings.ts +30 -239
  181. package/src/types/bledevicestatus.ts +305 -0
  182. package/src/types/devicelist.ts +124 -0
  183. package/src/types/deviceresponse.ts +15 -0
  184. package/src/types/devicestatus.ts +178 -0
  185. package/src/types/devicewebhookstatus.ts +196 -0
  186. package/src/types/irdevicelist.ts +15 -0
  187. package/src/types/pushbody.ts +9 -0
  188. package/src/utils.ts +33 -0
@@ -0,0 +1,124 @@
1
+ /* Copyright(C) 2017-2024, donavanbecker (https://github.com/donavanbecker). All rights reserved.
2
+ *
3
+ * devicelist.ts: @switchbot/homebridge-switchbot platform class.
4
+ */
5
+
6
+ export type deviceList = {
7
+ device: device[];
8
+ };
9
+
10
+ export type device = {
11
+ deviceId: string;
12
+ deviceName: string;
13
+ deviceType: string;
14
+ enableCloudService: boolean;
15
+ hubDeviceId: string;
16
+ version?: number;
17
+ };
18
+
19
+ export type bot = device & {};
20
+
21
+ export type curtain = device & {
22
+ curtainDevicesIds: string[];
23
+ calibrate: boolean;
24
+ group: boolean;
25
+ master: boolean;
26
+ openDirection: string;
27
+ };
28
+
29
+ export type curtain3 = device & {
30
+ curtainDevicesIds: string[];
31
+ calibrate: boolean;
32
+ group: boolean;
33
+ master: boolean;
34
+ openDirection?: string;
35
+ };
36
+
37
+ export type hub2 = device & {};
38
+
39
+ export type meter = device & {};
40
+
41
+ export type meterPlus = device & {};
42
+
43
+ export type outdoorMeter = device & {};
44
+
45
+ export type lock = device & {
46
+ group: boolean;
47
+ master: boolean;
48
+ groupName: string;
49
+ lockDevicesIds: string[];
50
+ };
51
+
52
+ export type lockPro = device & {
53
+ group: boolean;
54
+ master: boolean;
55
+ groupName: string;
56
+ lockDevicesIds: string[];
57
+ };
58
+
59
+ export type keypad = device & {
60
+ remoteType: string;
61
+ lockDeviceId: string;
62
+ keyList: keyList
63
+ };
64
+
65
+ export type keypadTouch = device & {
66
+ remoteType: string;
67
+ lockDeviceId: string;
68
+ keyList: keyList
69
+ };
70
+
71
+ type keyList = {
72
+ id: number;
73
+ name: string;
74
+ type: string;
75
+ password: string;
76
+ iv: string;
77
+ status: string;
78
+ createTime: number;
79
+ };
80
+
81
+ export type remote = device & {};
82
+
83
+ export type motionSensor = device & {};
84
+
85
+ export type contactSensor = device & {};
86
+
87
+ export type waterLeakDetector = device & {};
88
+
89
+ export type ceilingLight = device & {};
90
+
91
+ export type ceilingLightPro = device & {};
92
+
93
+ export type plug = device & {};
94
+
95
+ export type plugMini = device & {};
96
+
97
+ export type stripLight = device & {};
98
+
99
+ export type colorBulb = device & {};
100
+
101
+ export type robotVacuumCleanerS1 = device & {};
102
+
103
+ export type robotVacuumCleanerS1Plus = device & {};
104
+
105
+ export type floorCleaningRobotS10 = device & {};
106
+
107
+ export type humidifier = device & {};
108
+
109
+ export type indoorCam = device & {};
110
+
111
+ export type pantiltCam = device & {};
112
+
113
+ export type pantiltCam2k = device & {};
114
+
115
+ export type blindTilt = device & {
116
+ blindTiltDevicesIds: string[];
117
+ calibrate: boolean;
118
+ group: boolean;
119
+ master: boolean;
120
+ direction: string;
121
+ slidePosition: number;
122
+ };
123
+
124
+ export type batteryCirculatorFan = device & {};
@@ -0,0 +1,15 @@
1
+ import type { deviceList } from './devicelist';
2
+ import type { infraredRemoteList } from './irdevicelist';
3
+
4
+
5
+ //json response from SwitchBot API
6
+ export type devices = {
7
+ statusCode: 100 | 190 | 'n/a';
8
+ message: string;
9
+ body: body;
10
+ };
11
+
12
+ type body = {
13
+ deviceList: deviceList;
14
+ infraredRemoteList: infraredRemoteList;
15
+ };
@@ -0,0 +1,178 @@
1
+ import type { device } from './devicelist';
2
+
3
+ /* Copyright(C) 2017-2024, donavanbecker (https://github.com/donavanbecker). All rights reserved.
4
+ *
5
+ * devicestatus.ts: @switchbot/homebridge-switchbot platform class.
6
+ */
7
+ export type deviceStatusRequest = {
8
+ statusCode: number;
9
+ message: string;
10
+ body: deviceStatus;
11
+ };
12
+
13
+ export interface deviceStatus extends device {
14
+ //properties on all devices
15
+ deviceId: string;
16
+ deviceType: string;
17
+ hubDeviceId: string;
18
+ version: number;
19
+ };
20
+
21
+ export type botStatus = deviceStatus & {
22
+ power: string;
23
+ battery: number;
24
+ mode: 'pressMode' | 'switchMode' | 'customizeMode';
25
+ };
26
+
27
+ export type curtainStatus = deviceStatus & {
28
+ calibrate: boolean;
29
+ group: boolean;
30
+ moving: boolean;
31
+ battery: number;
32
+ slidePosition: number;
33
+ lightLevel?: 'bright' | 'dim';
34
+ };
35
+
36
+ export type meterStatus = deviceStatus & {
37
+ temperature: number;
38
+ battery: number;
39
+ humidity: number;
40
+ };
41
+
42
+ export type meterPlusStatus = deviceStatus & {
43
+ temperature: number;
44
+ battery: number;
45
+ humidity: number;
46
+ };
47
+
48
+ export type outdoorMeterStatus = deviceStatus & {
49
+ battery: number;
50
+ temperature: number;
51
+ humidity: number;
52
+ };
53
+
54
+ export type lockStatus = deviceStatus & {
55
+ lockState: string;
56
+ doorState: string;
57
+ moveDetected: boolean;
58
+ battery: number;
59
+ };
60
+
61
+ export type lockProStatus = deviceStatus & {
62
+ lockState: string;
63
+ doorState: string;
64
+ moveDetected: boolean;
65
+ battery: number;
66
+ };
67
+
68
+ export type motionSensorStatus = deviceStatus & {
69
+ battery: number;
70
+ moveDetected: boolean;
71
+ brightness: 'bright' | 'dim';
72
+ };
73
+
74
+ export type contactSensorStatus = deviceStatus & {
75
+ battery: number;
76
+ moveDetected: boolean;
77
+ openState: 'open' | 'close' | 'timeOutNotClose';
78
+ brightness: 'bright' | 'dim';
79
+ };
80
+
81
+ export type waterLeakDetectorStatus = deviceStatus & {
82
+ battery: number;
83
+ status: 0 /*dry*/ | 1 /*leak detected*/;
84
+ };
85
+
86
+ export type ceilingLightStatus = deviceStatus & {
87
+ power: boolean;
88
+ brightness: number;
89
+ colorTemperature: number;
90
+ };
91
+
92
+ export type ceilingLightProStatus = deviceStatus & {
93
+ power: boolean;
94
+ brightness: number;
95
+ colorTemperature: number;
96
+ };
97
+
98
+ export type plugStatus = deviceStatus & {
99
+ power: string;
100
+ version: string;
101
+ };
102
+
103
+ export type plugMiniStatus = deviceStatus & {
104
+ voltage: Float64Array;
105
+ weight: Float64Array;
106
+ electricityOfDay: number;
107
+ electricCurrent: Float64Array;
108
+ power: string;
109
+ };
110
+
111
+ export type stripLightStatus = deviceStatus & {
112
+ power: string;
113
+ brightness: number;
114
+ color: string;
115
+ };
116
+
117
+ export type colorBulbStatus = deviceStatus & {
118
+ power: string;
119
+ brightness: number;
120
+ color: string;
121
+ colorTemperature: number;
122
+ };
123
+
124
+ export type robotVacuumCleanerS1Status = deviceStatus & {
125
+ workingStatus: string;
126
+ onlineStatus: string;
127
+ battery: number;
128
+ };
129
+
130
+ export type robotVacuumCleanerS1PlusStatus = deviceStatus & {
131
+ workingStatus: string;
132
+ onlineStatus: string;
133
+ battery: number;
134
+ };
135
+
136
+ export type floorCleaningRobotS10Status = deviceStatus & {
137
+ workingStatus: string;
138
+ onlineStatus: string;
139
+ battery: number;
140
+ waterBaseBattery: number;
141
+ taskType: string;
142
+ };
143
+
144
+ export type humidifierStatus = deviceStatus & {
145
+ power: string;
146
+ humidity: number;
147
+ temperature: number;
148
+ nebulizationEfficiency: number;
149
+ auto: boolean;
150
+ childLock: boolean;
151
+ sound: boolean;
152
+ lackWater: boolean;
153
+ };
154
+
155
+ export type blindTiltStatus = deviceStatus & {
156
+ calibrate: boolean;
157
+ battery: boolean;
158
+ direction: string;
159
+ slidePosition: string;
160
+ lightLevel?: 'bright' | 'dim';
161
+ };
162
+
163
+ export type hub2Status = deviceStatus & {
164
+ temperature: number;
165
+ lightLevel: number;
166
+ humidity: number;
167
+ };
168
+
169
+ export type batteryCirculatorFanStatus = deviceStatus & {
170
+ mode: 'direct' | 'natural' | 'sleep' | 'baby';
171
+ battery: number;
172
+ power: string;
173
+ nightStatus: number;
174
+ oscillation: string;
175
+ verticalOscillation: string;
176
+ chargingStatus: string;
177
+ fanSpeed: number;
178
+ };
@@ -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
+ export 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
  }