@switchbot/homebridge-switchbot 3.5.1-beta.0 → 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 (197) 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 +224 -370
  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 +197 -221
  9. package/dist/device/bot.js.map +1 -1
  10. package/dist/device/ceilinglight.d.ts +10 -5
  11. package/dist/device/ceilinglight.d.ts.map +1 -1
  12. package/dist/device/ceilinglight.js +214 -292
  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 +335 -421
  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 +121 -200
  21. package/dist/device/contact.js.map +1 -1
  22. package/dist/device/curtain.d.ts +20 -7
  23. package/dist/device/curtain.d.ts.map +1 -1
  24. package/dist/device/curtain.js +229 -403
  25. package/dist/device/curtain.js.map +1 -1
  26. package/dist/device/device.d.ts +41 -22
  27. package/dist/device/device.d.ts.map +1 -1
  28. package/dist/device/device.js +212 -181
  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 +204 -249
  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 +107 -233
  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 +193 -235
  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 +92 -159
  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 +288 -370
  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 +172 -219
  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 +94 -160
  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 +95 -157
  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 +85 -144
  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 +100 -127
  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 +172 -259
  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 +106 -131
  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 +2 -3
  81. package/dist/irdevice/airconditioner.js.map +1 -1
  82. package/dist/irdevice/airpurifier.d.ts +2 -1
  83. package/dist/irdevice/airpurifier.d.ts.map +1 -1
  84. package/dist/irdevice/airpurifier.js +2 -3
  85. package/dist/irdevice/airpurifier.js.map +1 -1
  86. package/dist/irdevice/camera.d.ts +2 -1
  87. package/dist/irdevice/camera.d.ts.map +1 -1
  88. package/dist/irdevice/camera.js +2 -3
  89. package/dist/irdevice/camera.js.map +1 -1
  90. package/dist/irdevice/fan.d.ts +2 -1
  91. package/dist/irdevice/fan.d.ts.map +1 -1
  92. package/dist/irdevice/fan.js +2 -3
  93. package/dist/irdevice/fan.js.map +1 -1
  94. package/dist/irdevice/irdevice.d.ts +3 -1
  95. package/dist/irdevice/irdevice.d.ts.map +1 -1
  96. package/dist/irdevice/irdevice.js +5 -1
  97. package/dist/irdevice/irdevice.js.map +1 -1
  98. package/dist/irdevice/light.d.ts +2 -1
  99. package/dist/irdevice/light.d.ts.map +1 -1
  100. package/dist/irdevice/light.js +2 -3
  101. package/dist/irdevice/light.js.map +1 -1
  102. package/dist/irdevice/other.d.ts +2 -1
  103. package/dist/irdevice/other.d.ts.map +1 -1
  104. package/dist/irdevice/other.js +2 -3
  105. package/dist/irdevice/other.js.map +1 -1
  106. package/dist/irdevice/tv.d.ts +2 -1
  107. package/dist/irdevice/tv.d.ts.map +1 -1
  108. package/dist/irdevice/tv.js +2 -3
  109. package/dist/irdevice/tv.js.map +1 -1
  110. package/dist/irdevice/vacuumcleaner.d.ts +2 -1
  111. package/dist/irdevice/vacuumcleaner.d.ts.map +1 -1
  112. package/dist/irdevice/vacuumcleaner.js +2 -3
  113. package/dist/irdevice/vacuumcleaner.js.map +1 -1
  114. package/dist/irdevice/waterheater.d.ts +2 -1
  115. package/dist/irdevice/waterheater.d.ts.map +1 -1
  116. package/dist/irdevice/waterheater.js +2 -3
  117. package/dist/irdevice/waterheater.js.map +1 -1
  118. package/dist/platform.d.ts +14 -14
  119. package/dist/platform.d.ts.map +1 -1
  120. package/dist/platform.js +102 -86
  121. package/dist/platform.js.map +1 -1
  122. package/dist/settings.d.ts +49 -190
  123. package/dist/settings.d.ts.map +1 -1
  124. package/dist/settings.js +19 -0
  125. package/dist/settings.js.map +1 -1
  126. package/dist/types/bledevicestatus.d.ts +279 -0
  127. package/dist/types/bledevicestatus.d.ts.map +1 -0
  128. package/dist/types/bledevicestatus.js +2 -0
  129. package/dist/types/bledevicestatus.js.map +1 -0
  130. package/dist/types/devicelist.d.ts +89 -0
  131. package/dist/types/devicelist.d.ts.map +1 -0
  132. package/dist/types/devicelist.js +6 -0
  133. package/dist/types/devicelist.js.map +1 -0
  134. package/dist/types/deviceresponse.d.ts +13 -0
  135. package/dist/types/deviceresponse.d.ts.map +1 -0
  136. package/dist/types/deviceresponse.js +2 -0
  137. package/dist/types/deviceresponse.js.map +1 -0
  138. package/dist/types/devicestatus.d.ts +149 -0
  139. package/dist/types/devicestatus.d.ts.map +1 -0
  140. package/dist/types/devicestatus.js +3 -0
  141. package/dist/types/devicestatus.js.map +1 -0
  142. package/dist/types/devicewebhookstatus.d.ts +156 -0
  143. package/dist/types/devicewebhookstatus.d.ts.map +1 -0
  144. package/dist/types/devicewebhookstatus.js +2 -0
  145. package/dist/types/devicewebhookstatus.js.map +1 -0
  146. package/dist/types/irdevicelist.d.ts +10 -0
  147. package/dist/types/irdevicelist.d.ts.map +1 -0
  148. package/dist/types/irdevicelist.js +2 -0
  149. package/dist/types/irdevicelist.js.map +1 -0
  150. package/dist/types/pushbody.d.ts +6 -0
  151. package/dist/types/pushbody.d.ts.map +1 -0
  152. package/dist/types/pushbody.js +2 -0
  153. package/dist/types/pushbody.js.map +1 -0
  154. package/dist/utils.d.ts +25 -0
  155. package/dist/utils.d.ts.map +1 -1
  156. package/dist/utils.js +28 -0
  157. package/dist/utils.js.map +1 -1
  158. package/package.json +11 -11
  159. package/src/device/blindtilt.ts +254 -376
  160. package/src/device/bot.ts +209 -224
  161. package/src/device/ceilinglight.ts +227 -297
  162. package/src/device/colorbulb.ts +345 -435
  163. package/src/device/contact.ts +139 -200
  164. package/src/device/curtain.ts +254 -414
  165. package/src/device/device.ts +221 -190
  166. package/src/device/fan.ts +222 -253
  167. package/src/device/hub.ts +127 -248
  168. package/src/device/humidifier.ts +217 -246
  169. package/src/device/iosensor.ts +115 -168
  170. package/src/device/lightstrip.ts +303 -380
  171. package/src/device/lock.ts +188 -224
  172. package/src/device/meter.ts +117 -179
  173. package/src/device/meterplus.ts +118 -176
  174. package/src/device/motion.ts +100 -146
  175. package/src/device/plug.ts +111 -131
  176. package/src/device/robotvacuumcleaner.ts +191 -258
  177. package/src/device/waterdetector.ts +124 -141
  178. package/src/irdevice/airconditioner.ts +4 -4
  179. package/src/irdevice/airpurifier.ts +4 -4
  180. package/src/irdevice/camera.ts +4 -4
  181. package/src/irdevice/fan.ts +4 -4
  182. package/src/irdevice/irdevice.ts +8 -2
  183. package/src/irdevice/light.ts +4 -4
  184. package/src/irdevice/other.ts +4 -4
  185. package/src/irdevice/tv.ts +4 -4
  186. package/src/irdevice/vacuumcleaner.ts +4 -4
  187. package/src/irdevice/waterheater.ts +4 -4
  188. package/src/platform.ts +104 -87
  189. package/src/settings.ts +30 -238
  190. package/src/types/bledevicestatus.ts +305 -0
  191. package/src/types/devicelist.ts +124 -0
  192. package/src/types/deviceresponse.ts +15 -0
  193. package/src/types/devicestatus.ts +178 -0
  194. package/src/types/devicewebhookstatus.ts +196 -0
  195. package/src/types/irdevicelist.ts +15 -0
  196. package/src/types/pushbody.ts +9 -0
  197. 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
  }