@switchbot/homebridge-switchbot 1.6.4-beta.5 → 1.7.1-beta.2

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.
@@ -52,10 +52,15 @@ class Bot {
52
52
  // get the LightBulb service if it exists, otherwise create a new LightBulb service
53
53
  // you can create multiple services for each accessory
54
54
  if (device.bot?.deviceType === 'switch') {
55
+ this.removeFanService(accessory);
55
56
  this.removeLockService(accessory);
56
57
  this.removeDoorService(accessory);
58
+ this.removeFaucetService(accessory);
57
59
  this.removeOutletService(accessory);
60
+ this.removeWindowService(accessory);
58
61
  this.removeGarageDoorService(accessory);
62
+ this.removeWindowCoveringService(accessory);
63
+ this.removeStatefulProgrammableSwitchService(accessory);
59
64
  // Add switchService
60
65
  (this.switchService =
61
66
  accessory.getService(this.platform.Service.Switch) ||
@@ -65,10 +70,15 @@ class Bot {
65
70
  this.switchService.getCharacteristic(this.platform.Characteristic.On).onSet(this.handleOnSet.bind(this));
66
71
  }
67
72
  else if (device.bot?.deviceType === 'garagedoor') {
73
+ this.removeFanService(accessory);
68
74
  this.removeLockService(accessory);
69
75
  this.removeDoorService(accessory);
76
+ this.removeFaucetService(accessory);
70
77
  this.removeOutletService(accessory);
71
78
  this.removeSwitchService(accessory);
79
+ this.removeWindowService(accessory);
80
+ this.removeWindowCoveringService(accessory);
81
+ this.removeStatefulProgrammableSwitchService(accessory);
72
82
  // Add switchService
73
83
  (this.garageDoorService =
74
84
  accessory.getService(this.platform.Service.GarageDoorOpener) ||
@@ -79,10 +89,15 @@ class Bot {
79
89
  this.garageDoorService.setCharacteristic(this.platform.Characteristic.ObstructionDetected, false);
80
90
  }
81
91
  else if (device.bot?.deviceType === 'door') {
92
+ this.removeFanService(accessory);
82
93
  this.removeLockService(accessory);
83
94
  this.removeOutletService(accessory);
95
+ this.removeFaucetService(accessory);
84
96
  this.removeSwitchService(accessory);
97
+ this.removeWindowService(accessory);
85
98
  this.removeGarageDoorService(accessory);
99
+ this.removeWindowCoveringService(accessory);
100
+ this.removeStatefulProgrammableSwitchService(accessory);
86
101
  // Add switchService
87
102
  (this.doorService =
88
103
  accessory.getService(this.platform.Service.Door) ||
@@ -98,11 +113,66 @@ class Bot {
98
113
  }).onSet(this.handleOnSet.bind(this));
99
114
  this.doorService.setCharacteristic(this.platform.Characteristic.PositionState, this.platform.Characteristic.PositionState.STOPPED);
100
115
  }
116
+ else if (device.bot?.deviceType === 'window') {
117
+ this.removeFanService(accessory);
118
+ this.removeLockService(accessory);
119
+ this.removeDoorService(accessory);
120
+ this.removeOutletService(accessory);
121
+ this.removeFaucetService(accessory);
122
+ this.removeSwitchService(accessory);
123
+ this.removeGarageDoorService(accessory);
124
+ this.removeWindowCoveringService(accessory);
125
+ this.removeStatefulProgrammableSwitchService(accessory);
126
+ // Add switchService
127
+ (this.windowService =
128
+ accessory.getService(this.platform.Service.Window) ||
129
+ accessory.addService(this.platform.Service.Window)), `${accessory.displayName} Window`;
130
+ this.infoLog(`Bot: ${accessory.displayName} Displaying as Window`);
131
+ this.windowService.setCharacteristic(this.platform.Characteristic.Name, accessory.displayName);
132
+ this.windowService.getCharacteristic(this.platform.Characteristic.TargetPosition)
133
+ .setProps({
134
+ validValues: [0, 100],
135
+ minValue: 0,
136
+ maxValue: 100,
137
+ minStep: 100,
138
+ }).onSet(this.handleOnSet.bind(this));
139
+ this.windowService.setCharacteristic(this.platform.Characteristic.PositionState, this.platform.Characteristic.PositionState.STOPPED);
140
+ }
141
+ else if (device.bot?.deviceType === 'windowcovering') {
142
+ this.removeFanService(accessory);
143
+ this.removeLockService(accessory);
144
+ this.removeDoorService(accessory);
145
+ this.removeOutletService(accessory);
146
+ this.removeFaucetService(accessory);
147
+ this.removeSwitchService(accessory);
148
+ this.removeWindowService(accessory);
149
+ this.removeGarageDoorService(accessory);
150
+ this.removeStatefulProgrammableSwitchService(accessory);
151
+ // Add switchService
152
+ (this.windowCoveringService =
153
+ accessory.getService(this.platform.Service.WindowCovering) ||
154
+ accessory.addService(this.platform.Service.WindowCovering)), `${accessory.displayName} Window Covering`;
155
+ this.infoLog(`Bot: ${accessory.displayName} Displaying as Window Covering`);
156
+ this.windowCoveringService.setCharacteristic(this.platform.Characteristic.Name, accessory.displayName);
157
+ this.windowCoveringService.getCharacteristic(this.platform.Characteristic.TargetPosition)
158
+ .setProps({
159
+ validValues: [0, 100],
160
+ minValue: 0,
161
+ maxValue: 100,
162
+ minStep: 100,
163
+ }).onSet(this.handleOnSet.bind(this));
164
+ this.windowCoveringService.setCharacteristic(this.platform.Characteristic.PositionState, this.platform.Characteristic.PositionState.STOPPED);
165
+ }
101
166
  else if (device.bot?.deviceType === 'lock') {
167
+ this.removeFanService(accessory);
102
168
  this.removeDoorService(accessory);
103
169
  this.removeOutletService(accessory);
104
170
  this.removeSwitchService(accessory);
171
+ this.removeFaucetService(accessory);
172
+ this.removeWindowService(accessory);
105
173
  this.removeGarageDoorService(accessory);
174
+ this.removeWindowCoveringService(accessory);
175
+ this.removeStatefulProgrammableSwitchService(accessory);
106
176
  // Add switchService
107
177
  (this.lockService =
108
178
  accessory.getService(this.platform.Service.LockMechanism) ||
@@ -111,11 +181,71 @@ class Bot {
111
181
  this.lockService.setCharacteristic(this.platform.Characteristic.Name, accessory.displayName);
112
182
  this.lockService.getCharacteristic(this.platform.Characteristic.LockTargetState).onSet(this.handleOnSet.bind(this));
113
183
  }
184
+ else if (device.bot?.deviceType === 'faucet') {
185
+ this.removeFanService(accessory);
186
+ this.removeLockService(accessory);
187
+ this.removeDoorService(accessory);
188
+ this.removeOutletService(accessory);
189
+ this.removeSwitchService(accessory);
190
+ this.removeWindowService(accessory);
191
+ this.removeGarageDoorService(accessory);
192
+ this.removeWindowCoveringService(accessory);
193
+ this.removeStatefulProgrammableSwitchService(accessory);
194
+ // Add switchService
195
+ (this.faucetService =
196
+ accessory.getService(this.platform.Service.Faucet) ||
197
+ accessory.addService(this.platform.Service.Faucet)), `${accessory.displayName} Faucet`;
198
+ this.infoLog(`Bot: ${accessory.displayName} Displaying as Faucet`);
199
+ this.faucetService.setCharacteristic(this.platform.Characteristic.Name, accessory.displayName);
200
+ this.faucetService.getCharacteristic(this.platform.Characteristic.Active).onSet(this.handleOnSet.bind(this));
201
+ }
202
+ else if (device.bot?.deviceType === 'fan') {
203
+ this.removeLockService(accessory);
204
+ this.removeDoorService(accessory);
205
+ this.removeFaucetService(accessory);
206
+ this.removeOutletService(accessory);
207
+ this.removeSwitchService(accessory);
208
+ this.removeWindowService(accessory);
209
+ this.removeGarageDoorService(accessory);
210
+ this.removeWindowCoveringService(accessory);
211
+ this.removeStatefulProgrammableSwitchService(accessory);
212
+ // Add switchService
213
+ (this.fanService =
214
+ accessory.getService(this.platform.Service.Fan) ||
215
+ accessory.addService(this.platform.Service.Fan)), `${accessory.displayName} Fan`;
216
+ this.infoLog(`Bot: ${accessory.displayName} Displaying as Fan`);
217
+ this.fanService.setCharacteristic(this.platform.Characteristic.Name, accessory.displayName);
218
+ this.fanService.getCharacteristic(this.platform.Characteristic.On).onSet(this.handleOnSet.bind(this));
219
+ }
220
+ else if (device.bot?.deviceType === 'stateful') {
221
+ this.removeFanService(accessory);
222
+ this.removeLockService(accessory);
223
+ this.removeDoorService(accessory);
224
+ this.removeFaucetService(accessory);
225
+ this.removeOutletService(accessory);
226
+ this.removeSwitchService(accessory);
227
+ this.removeWindowService(accessory);
228
+ this.removeGarageDoorService(accessory);
229
+ this.removeWindowCoveringService(accessory);
230
+ // Add switchService
231
+ (this.statefulProgrammableSwitchService =
232
+ accessory.getService(this.platform.Service.StatefulProgrammableSwitch) ||
233
+ accessory.addService(this.platform.Service.StatefulProgrammableSwitch)), `${accessory.displayName} Stateful Programmable Switch`;
234
+ this.infoLog(`Bot: ${accessory.displayName} Displaying as Stateful Programmable Switch`);
235
+ this.statefulProgrammableSwitchService.setCharacteristic(this.platform.Characteristic.Name, accessory.displayName);
236
+ this.statefulProgrammableSwitchService.getCharacteristic(this.platform.Characteristic.ProgrammableSwitchOutputState)
237
+ .onSet(this.handleOnSet.bind(this));
238
+ }
114
239
  else {
240
+ this.removeFanService(accessory);
115
241
  this.removeLockService(accessory);
116
242
  this.removeDoorService(accessory);
243
+ this.removeFaucetService(accessory);
117
244
  this.removeSwitchService(accessory);
245
+ this.removeWindowService(accessory);
118
246
  this.removeGarageDoorService(accessory);
247
+ this.removeWindowCoveringService(accessory);
248
+ this.removeStatefulProgrammableSwitchService(accessory);
119
249
  // Add outletService
120
250
  (this.outletService =
121
251
  accessory.getService(this.platform.Service.Outlet) ||
@@ -124,12 +254,22 @@ class Bot {
124
254
  this.outletService.setCharacteristic(this.platform.Characteristic.Name, accessory.displayName);
125
255
  this.outletService.getCharacteristic(this.platform.Characteristic.On).onSet(this.handleOnSet.bind(this));
126
256
  }
127
- if (device.ble) {
257
+ // Battery Service
258
+ if (!device.ble) {
259
+ this.debugLog(`Bot: ${accessory.displayName} Removing Battery Service`);
260
+ this.batteryService = this.accessory.getService(this.platform.Service.Battery);
261
+ accessory.removeService(this.batteryService);
262
+ }
263
+ else if (!this.batteryService) {
264
+ this.debugLog(`Bot: ${accessory.displayName} Add Battery Service`);
128
265
  (this.batteryService =
129
- accessory.getService(this.platform.Service.Battery) ||
130
- accessory.addService(this.platform.Service.Battery)), `${accessory.displayName} Battery`;
266
+ this.accessory.getService(this.platform.Service.Battery) ||
267
+ this.accessory.addService(this.platform.Service.Battery)), `${accessory.displayName} Battery`;
131
268
  this.batteryService.setCharacteristic(this.platform.Characteristic.Name, `${accessory.displayName} Battery`);
132
269
  }
270
+ else {
271
+ this.debugLog(`Bot: ${accessory.displayName} Battery Service Not Added`);
272
+ }
133
273
  // Retrieve initial values and updateHomekit
134
274
  this.updateHomeKitCharacteristics();
135
275
  // Start an update interval
@@ -198,6 +338,46 @@ class Bot {
198
338
  }
199
339
  accessory.removeService(this.lockService);
200
340
  }
341
+ removeFaucetService(accessory) {
342
+ // If faucetService still pressent, then remove first
343
+ this.faucetService = this.accessory.getService(this.platform.Service.Faucet);
344
+ if (this.faucetService) {
345
+ this.warnLog(`Bot: ${accessory.displayName} Removing Leftover Faucet Service`);
346
+ }
347
+ accessory.removeService(this.faucetService);
348
+ }
349
+ removeFanService(accessory) {
350
+ // If fanService still pressent, then remove first
351
+ this.fanService = this.accessory.getService(this.platform.Service.Fan);
352
+ if (this.fanService) {
353
+ this.warnLog(`Bot: ${accessory.displayName} Removing Leftover Fan Service`);
354
+ }
355
+ accessory.removeService(this.fanService);
356
+ }
357
+ removeWindowService(accessory) {
358
+ // If windowService still pressent, then remove first
359
+ this.windowService = this.accessory.getService(this.platform.Service.Window);
360
+ if (this.windowService) {
361
+ this.warnLog(`Bot: ${accessory.displayName} Removing Leftover Window Service`);
362
+ }
363
+ accessory.removeService(this.windowService);
364
+ }
365
+ removeWindowCoveringService(accessory) {
366
+ // If windowCoveringService still pressent, then remove first
367
+ this.windowCoveringService = this.accessory.getService(this.platform.Service.WindowCovering);
368
+ if (this.windowCoveringService) {
369
+ this.warnLog(`Bot: ${accessory.displayName} Removing Leftover Window Covering Service`);
370
+ }
371
+ accessory.removeService(this.windowCoveringService);
372
+ }
373
+ removeStatefulProgrammableSwitchService(accessory) {
374
+ // If statefulProgrammableSwitchService still pressent, then remove first
375
+ this.statefulProgrammableSwitchService = this.accessory.getService(this.platform.Service.StatefulProgrammableSwitch);
376
+ if (this.statefulProgrammableSwitchService) {
377
+ this.warnLog(`Bot: ${accessory.displayName} Removing Leftover Stateful Programmable Switch Service`);
378
+ }
379
+ accessory.removeService(this.statefulProgrammableSwitchService);
380
+ }
201
381
  removeSwitchService(accessory) {
202
382
  // If switchService still pressent, then remove first
203
383
  this.switchService = this.accessory.getService(this.platform.Service.Switch);
@@ -277,11 +457,11 @@ class Bot {
277
457
  * Parse the device status from the SwitchBot api
278
458
  */
279
459
  async parseStatus() {
280
- if (this.device.ble) {
281
- await this.BLEparseStatus();
460
+ if (this.SwitchToOpenAPI || !this.device.ble) {
461
+ await this.openAPIparseStatus();
282
462
  }
283
463
  else {
284
- await this.openAPIparseStatus();
464
+ await this.BLEparseStatus();
285
465
  }
286
466
  }
287
467
  async BLEparseStatus() {
@@ -314,6 +494,9 @@ class Bot {
314
494
  this.debugLog(`Bot: ${this.accessory.displayName} BatteryLevel: ${this.BatteryLevel}`);
315
495
  }
316
496
  async openAPIparseStatus() {
497
+ if (this.device.ble) {
498
+ this.SwitchToOpenAPI = false;
499
+ }
317
500
  if (this.platform.config.credentials?.openToken) {
318
501
  this.debugLog(`Bot: ${this.accessory.displayName} OpenAPI parseStatus`);
319
502
  if (this.botMode === 'press') {
@@ -322,15 +505,19 @@ class Bot {
322
505
  this.accessory.context.On = this.OnCached;
323
506
  }
324
507
  else {
325
- if (this.deviceStatus.body.power === 'on') {
326
- this.On = true;
327
- this.OnCached = this.On;
328
- this.accessory.context.On = this.OnCached;
329
- }
330
- else {
508
+ /*if (this.deviceStatus.body.power === 'on') {
509
+ this.On = true;
510
+ this.OnCached = this.On;
511
+ this.accessory.context.On = this.OnCached;
512
+ } else {
513
+ this.On = false;
514
+ this.OnCached = this.On;
515
+ this.accessory.context.On = this.OnCached;
516
+ }*/
517
+ this.OnCached = this.On;
518
+ this.accessory.context.On = this.OnCached;
519
+ if (this.On === undefined) {
331
520
  this.On = false;
332
- this.OnCached = this.On;
333
- this.accessory.context.On = this.OnCached;
334
521
  }
335
522
  }
336
523
  this.debugLog(`Bot: ${this.accessory.displayName} On: ${this.On}`);
@@ -414,6 +601,7 @@ class Bot {
414
601
  this.errorLog(`Bot: ${this.accessory.displayName} wasn't able to establish BLE Connection`);
415
602
  if (this.platform.config.credentials?.openToken) {
416
603
  this.warnLog(`Bot: ${this.accessory.displayName} Using OpenAPI Connection`);
604
+ this.SwitchToOpenAPI = true;
417
605
  await this.openAPIRefreshStatus();
418
606
  }
419
607
  }
@@ -429,6 +617,7 @@ class Bot {
429
617
  }
430
618
  if (this.platform.config.credentials?.openToken) {
431
619
  this.warnLog(`Bot: ${this.accessory.displayName} Using OpenAPI Connection`);
620
+ this.SwitchToOpenAPI = true;
432
621
  await this.openAPIRefreshStatus();
433
622
  }
434
623
  this.apiError(e);
@@ -662,6 +851,46 @@ class Bot {
662
851
  }
663
852
  this.debugLog(`Bot: ${this.accessory.displayName} Door On: ${this.On}`);
664
853
  }
854
+ else if (this.device.bot?.deviceType === 'window') {
855
+ if (this.On === undefined) {
856
+ this.debugLog(`Bot: ${this.accessory.displayName} On: ${this.On}`);
857
+ }
858
+ else {
859
+ if (this.On) {
860
+ this.windowService?.updateCharacteristic(this.platform.Characteristic.TargetPosition, 100);
861
+ this.windowService?.updateCharacteristic(this.platform.Characteristic.CurrentPosition, 100);
862
+ this.windowService?.updateCharacteristic(this.platform.Characteristic.PositionState, this.platform.Characteristic.PositionState.STOPPED);
863
+ this.debugLog(`Bot: ${this.accessory.displayName} updateCharacteristic TargetPosition: 100, CurrentPosition: 100`);
864
+ }
865
+ else {
866
+ this.windowService?.updateCharacteristic(this.platform.Characteristic.TargetPosition, 0);
867
+ this.windowService?.updateCharacteristic(this.platform.Characteristic.CurrentPosition, 0);
868
+ this.windowService?.updateCharacteristic(this.platform.Characteristic.PositionState, this.platform.Characteristic.PositionState.STOPPED);
869
+ this.debugLog(`Bot: ${this.accessory.displayName} updateCharacteristic TargetPosition: 0, CurrentPosition: 0`);
870
+ }
871
+ }
872
+ this.debugLog(`Bot: ${this.accessory.displayName} Window On: ${this.On}`);
873
+ }
874
+ else if (this.device.bot?.deviceType === 'windowcovering') {
875
+ if (this.On === undefined) {
876
+ this.debugLog(`Bot: ${this.accessory.displayName} On: ${this.On}`);
877
+ }
878
+ else {
879
+ if (this.On) {
880
+ this.windowCoveringService?.updateCharacteristic(this.platform.Characteristic.TargetPosition, 100);
881
+ this.windowCoveringService?.updateCharacteristic(this.platform.Characteristic.CurrentPosition, 100);
882
+ this.windowCoveringService?.updateCharacteristic(this.platform.Characteristic.PositionState, this.platform.Characteristic.PositionState.STOPPED);
883
+ this.debugLog(`Bot: ${this.accessory.displayName} updateCharacteristic TargetPosition: 100, CurrentPosition: 100`);
884
+ }
885
+ else {
886
+ this.windowCoveringService?.updateCharacteristic(this.platform.Characteristic.TargetPosition, 0);
887
+ this.windowCoveringService?.updateCharacteristic(this.platform.Characteristic.CurrentPosition, 0);
888
+ this.windowCoveringService?.updateCharacteristic(this.platform.Characteristic.PositionState, this.platform.Characteristic.PositionState.STOPPED);
889
+ this.debugLog(`Bot: ${this.accessory.displayName} updateCharacteristic TargetPosition: 0, CurrentPosition: 0`);
890
+ }
891
+ }
892
+ this.debugLog(`Bot: ${this.accessory.displayName} Window Covering On: ${this.On}`);
893
+ }
665
894
  else if (this.device.bot?.deviceType === 'lock') {
666
895
  if (this.On === undefined) {
667
896
  this.debugLog(`Bot: ${this.accessory.displayName} On: ${this.On}`);
@@ -680,6 +909,56 @@ class Bot {
680
909
  }
681
910
  this.debugLog(`Bot: ${this.accessory.displayName} Lock On: ${this.On}`);
682
911
  }
912
+ else if (this.device.bot?.deviceType === 'faucet') {
913
+ if (this.On === undefined) {
914
+ this.debugLog(`Bot: ${this.accessory.displayName} On: ${this.On}`);
915
+ }
916
+ else {
917
+ if (this.On) {
918
+ this.faucetService?.updateCharacteristic(this.platform.Characteristic.Active, this.platform.Characteristic.Active.ACTIVE);
919
+ this.debugLog(`Bot: ${this.accessory.displayName} updateCharacteristic Active: ${this.On}`);
920
+ }
921
+ else {
922
+ this.faucetService?.updateCharacteristic(this.platform.Characteristic.Active, this.platform.Characteristic.Active.INACTIVE);
923
+ this.debugLog(`Bot: ${this.accessory.displayName} updateCharacteristic Active: ${this.On}`);
924
+ }
925
+ }
926
+ this.debugLog(`Bot: ${this.accessory.displayName} Faucet On: ${this.On}`);
927
+ }
928
+ else if (this.device.bot?.deviceType === 'fan') {
929
+ if (this.On === undefined) {
930
+ this.debugLog(`Bot: ${this.accessory.displayName} On: ${this.On}`);
931
+ }
932
+ else {
933
+ if (this.On) {
934
+ this.fanService?.updateCharacteristic(this.platform.Characteristic.On, this.On);
935
+ this.debugLog(`Bot: ${this.accessory.displayName} updateCharacteristic On: ${this.On}`);
936
+ }
937
+ else {
938
+ this.fanService?.updateCharacteristic(this.platform.Characteristic.On, this.On);
939
+ this.debugLog(`Bot: ${this.accessory.displayName} updateCharacteristic On: ${this.On}`);
940
+ }
941
+ }
942
+ this.debugLog(`Bot: ${this.accessory.displayName} Fan On: ${this.On}`);
943
+ }
944
+ else if (this.device.bot?.deviceType === 'stateful') {
945
+ if (this.On === undefined) {
946
+ this.debugLog(`Bot: ${this.accessory.displayName} On: ${this.On}`);
947
+ }
948
+ else {
949
+ if (this.On) {
950
+ this.statefulProgrammableSwitchService?.updateCharacteristic(this.platform.Characteristic.ProgrammableSwitchEvent, this.platform.Characteristic.ProgrammableSwitchEvent.SINGLE_PRESS);
951
+ this.statefulProgrammableSwitchService?.updateCharacteristic(this.platform.Characteristic.ProgrammableSwitchOutputState, 1);
952
+ this.debugLog(`Bot: ${this.accessory.displayName} updateCharacteristic ProgrammableSwitchEvent: SINGLE, ProgrammableSwitchOutputState: 1`);
953
+ }
954
+ else {
955
+ this.statefulProgrammableSwitchService?.updateCharacteristic(this.platform.Characteristic.ProgrammableSwitchEvent, this.platform.Characteristic.ProgrammableSwitchEvent.SINGLE_PRESS);
956
+ this.statefulProgrammableSwitchService?.updateCharacteristic(this.platform.Characteristic.ProgrammableSwitchOutputState, 0);
957
+ this.debugLog(`Bot: ${this.accessory.displayName} updateCharacteristic ProgrammableSwitchEvent: SINGLE, ProgrammableSwitchOutputState: 0`);
958
+ }
959
+ }
960
+ this.debugLog(`Bot: ${this.accessory.displayName} StatefulProgrammableSwitch On: ${this.On}`);
961
+ }
683
962
  else if (this.device.bot?.deviceType === 'switch') {
684
963
  if (this.On === undefined) {
685
964
  this.debugLog(`Bot: ${this.accessory.displayName} On: ${this.On}`);
@@ -726,10 +1005,30 @@ class Bot {
726
1005
  this.doorService?.updateCharacteristic(this.platform.Characteristic.CurrentPosition, e);
727
1006
  this.doorService?.updateCharacteristic(this.platform.Characteristic.PositionState, e);
728
1007
  }
1008
+ else if (this.device.bot?.deviceType === 'window') {
1009
+ this.windowService?.updateCharacteristic(this.platform.Characteristic.TargetPosition, e);
1010
+ this.windowService?.updateCharacteristic(this.platform.Characteristic.CurrentPosition, e);
1011
+ this.windowService?.updateCharacteristic(this.platform.Characteristic.PositionState, e);
1012
+ }
1013
+ else if (this.device.bot?.deviceType === 'windowcovering') {
1014
+ this.windowCoveringService?.updateCharacteristic(this.platform.Characteristic.TargetPosition, e);
1015
+ this.windowCoveringService?.updateCharacteristic(this.platform.Characteristic.CurrentPosition, e);
1016
+ this.windowCoveringService?.updateCharacteristic(this.platform.Characteristic.PositionState, e);
1017
+ }
729
1018
  else if (this.device.bot?.deviceType === 'lock') {
730
1019
  this.doorService?.updateCharacteristic(this.platform.Characteristic.LockTargetState, e);
731
1020
  this.doorService?.updateCharacteristic(this.platform.Characteristic.LockCurrentState, e);
732
1021
  }
1022
+ else if (this.device.bot?.deviceType === 'faucet') {
1023
+ this.faucetService?.updateCharacteristic(this.platform.Characteristic.Active, e);
1024
+ }
1025
+ else if (this.device.bot?.deviceType === 'fan') {
1026
+ this.fanService?.updateCharacteristic(this.platform.Characteristic.On, e);
1027
+ }
1028
+ else if (this.device.bot?.deviceType === 'stateful') {
1029
+ this.statefulProgrammableSwitchService?.updateCharacteristic(this.platform.Characteristic.ProgrammableSwitchEvent, e);
1030
+ this.statefulProgrammableSwitchService?.updateCharacteristic(this.platform.Characteristic.ProgrammableSwitchOutputState, e);
1031
+ }
733
1032
  else if (this.device.bot?.deviceType === 'switch') {
734
1033
  this.switchService?.updateCharacteristic(this.platform.Characteristic.On, e);
735
1034
  }
@@ -796,7 +1095,9 @@ class Bot {
796
1095
  this.On = true;
797
1096
  }
798
1097
  }
799
- else if (this.device.bot?.deviceType === 'door') {
1098
+ else if (this.device.bot?.deviceType === 'door'
1099
+ || this.device.bot?.deviceType === 'window'
1100
+ || this.device.bot?.deviceType === 'windowcovering') {
800
1101
  this.debugLog(`Bot: ${this.accessory.displayName} TargetPosition: ${value}`);
801
1102
  if (value === 0) {
802
1103
  this.On = false;
@@ -814,6 +1115,24 @@ class Bot {
814
1115
  this.On = true;
815
1116
  }
816
1117
  }
1118
+ else if (this.device.bot?.deviceType === 'faucet') {
1119
+ this.debugLog(`Bot: ${this.accessory.displayName} Active: ${value}`);
1120
+ if (value === this.platform.Characteristic.Active.INACTIVE) {
1121
+ this.On = false;
1122
+ }
1123
+ else {
1124
+ this.On = true;
1125
+ }
1126
+ }
1127
+ else if (this.device.bot?.deviceType === 'stateful') {
1128
+ this.debugLog(`Bot: ${this.accessory.displayName} ProgrammableSwitchOutputState: ${value}`);
1129
+ if (value === 0) {
1130
+ this.On = false;
1131
+ }
1132
+ else {
1133
+ this.On = true;
1134
+ }
1135
+ }
817
1136
  else {
818
1137
  this.debugLog(`Bot: ${this.accessory.displayName} On: ${value}`);
819
1138
  this.On = value;