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

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 (136) hide show
  1. package/CHANGELOG.md +11 -0
  2. package/dist/device/blindtilt.d.ts.map +1 -1
  3. package/dist/device/blindtilt.js +44 -17
  4. package/dist/device/blindtilt.js.map +1 -1
  5. package/dist/device/bot.d.ts +1 -2
  6. package/dist/device/bot.d.ts.map +1 -1
  7. package/dist/device/bot.js +220 -397
  8. package/dist/device/bot.js.map +1 -1
  9. package/dist/device/ceilinglight.d.ts +3 -2
  10. package/dist/device/ceilinglight.d.ts.map +1 -1
  11. package/dist/device/ceilinglight.js +59 -31
  12. package/dist/device/ceilinglight.js.map +1 -1
  13. package/dist/device/colorbulb.d.ts +3 -2
  14. package/dist/device/colorbulb.d.ts.map +1 -1
  15. package/dist/device/colorbulb.js +57 -29
  16. package/dist/device/colorbulb.js.map +1 -1
  17. package/dist/device/contact.d.ts.map +1 -1
  18. package/dist/device/contact.js +47 -18
  19. package/dist/device/contact.js.map +1 -1
  20. package/dist/device/curtain.d.ts.map +1 -1
  21. package/dist/device/curtain.js +16 -5
  22. package/dist/device/curtain.js.map +1 -1
  23. package/dist/device/device.d.ts +9 -0
  24. package/dist/device/device.d.ts.map +1 -1
  25. package/dist/device/device.js +30 -3
  26. package/dist/device/device.js.map +1 -1
  27. package/dist/device/fan.d.ts.map +1 -1
  28. package/dist/device/fan.js +44 -18
  29. package/dist/device/fan.js.map +1 -1
  30. package/dist/device/hub.d.ts.map +1 -1
  31. package/dist/device/hub.js +46 -18
  32. package/dist/device/hub.js.map +1 -1
  33. package/dist/device/humidifier.d.ts.map +1 -1
  34. package/dist/device/humidifier.js +45 -20
  35. package/dist/device/humidifier.js.map +1 -1
  36. package/dist/device/iosensor.d.ts.map +1 -1
  37. package/dist/device/iosensor.js +46 -18
  38. package/dist/device/iosensor.js.map +1 -1
  39. package/dist/device/lightstrip.d.ts +4 -3
  40. package/dist/device/lightstrip.d.ts.map +1 -1
  41. package/dist/device/lightstrip.js +60 -31
  42. package/dist/device/lightstrip.js.map +1 -1
  43. package/dist/device/lock.d.ts.map +1 -1
  44. package/dist/device/lock.js +48 -17
  45. package/dist/device/lock.js.map +1 -1
  46. package/dist/device/meter.d.ts.map +1 -1
  47. package/dist/device/meter.js +46 -18
  48. package/dist/device/meter.js.map +1 -1
  49. package/dist/device/meterplus.d.ts.map +1 -1
  50. package/dist/device/meterplus.js +46 -18
  51. package/dist/device/meterplus.js.map +1 -1
  52. package/dist/device/motion.d.ts.map +1 -1
  53. package/dist/device/motion.js +45 -17
  54. package/dist/device/motion.js.map +1 -1
  55. package/dist/device/plug.d.ts.map +1 -1
  56. package/dist/device/plug.js +40 -18
  57. package/dist/device/plug.js.map +1 -1
  58. package/dist/device/robotvacuumcleaner.d.ts.map +1 -1
  59. package/dist/device/robotvacuumcleaner.js +42 -17
  60. package/dist/device/robotvacuumcleaner.js.map +1 -1
  61. package/dist/device/waterdetector.d.ts.map +1 -1
  62. package/dist/device/waterdetector.js +41 -16
  63. package/dist/device/waterdetector.js.map +1 -1
  64. package/dist/irdevice/airconditioner.d.ts.map +1 -1
  65. package/dist/irdevice/airconditioner.js +8 -1
  66. package/dist/irdevice/airconditioner.js.map +1 -1
  67. package/dist/irdevice/airpurifier.d.ts.map +1 -1
  68. package/dist/irdevice/airpurifier.js +6 -0
  69. package/dist/irdevice/airpurifier.js.map +1 -1
  70. package/dist/irdevice/camera.d.ts.map +1 -1
  71. package/dist/irdevice/camera.js +3 -0
  72. package/dist/irdevice/camera.js.map +1 -1
  73. package/dist/irdevice/fan.d.ts.map +1 -1
  74. package/dist/irdevice/fan.js +3 -0
  75. package/dist/irdevice/fan.js.map +1 -1
  76. package/dist/irdevice/irdevice.d.ts +9 -0
  77. package/dist/irdevice/irdevice.d.ts.map +1 -1
  78. package/dist/irdevice/irdevice.js +29 -2
  79. package/dist/irdevice/irdevice.js.map +1 -1
  80. package/dist/irdevice/light.d.ts.map +1 -1
  81. package/dist/irdevice/light.js +9 -0
  82. package/dist/irdevice/light.js.map +1 -1
  83. package/dist/irdevice/other.d.ts +1 -0
  84. package/dist/irdevice/other.d.ts.map +1 -1
  85. package/dist/irdevice/other.js +216 -228
  86. package/dist/irdevice/other.js.map +1 -1
  87. package/dist/irdevice/tv.d.ts.map +1 -1
  88. package/dist/irdevice/tv.js +9 -0
  89. package/dist/irdevice/tv.js.map +1 -1
  90. package/dist/irdevice/vacuumcleaner.d.ts.map +1 -1
  91. package/dist/irdevice/vacuumcleaner.js +3 -0
  92. package/dist/irdevice/vacuumcleaner.js.map +1 -1
  93. package/dist/irdevice/waterheater.js +1 -1
  94. package/dist/irdevice/waterheater.js.map +1 -1
  95. package/dist/platform.d.ts.map +1 -1
  96. package/dist/platform.js +11 -2
  97. package/dist/platform.js.map +1 -1
  98. package/dist/types/bledevicestatus.d.ts +1 -0
  99. package/dist/types/bledevicestatus.d.ts.map +1 -1
  100. package/dist/utils.d.ts +8 -0
  101. package/dist/utils.d.ts.map +1 -1
  102. package/dist/utils.js +16 -0
  103. package/dist/utils.js.map +1 -1
  104. package/package.json +6 -6
  105. package/src/device/blindtilt.ts +44 -17
  106. package/src/device/bot.ts +224 -407
  107. package/src/device/ceilinglight.ts +57 -33
  108. package/src/device/colorbulb.ts +55 -31
  109. package/src/device/contact.ts +48 -19
  110. package/src/device/curtain.ts +19 -6
  111. package/src/device/device.ts +36 -3
  112. package/src/device/fan.ts +44 -19
  113. package/src/device/hub.ts +46 -18
  114. package/src/device/humidifier.ts +44 -20
  115. package/src/device/iosensor.ts +46 -18
  116. package/src/device/lightstrip.ts +60 -33
  117. package/src/device/lock.ts +49 -17
  118. package/src/device/meter.ts +46 -18
  119. package/src/device/meterplus.ts +46 -18
  120. package/src/device/motion.ts +46 -18
  121. package/src/device/plug.ts +38 -18
  122. package/src/device/robotvacuumcleaner.ts +41 -17
  123. package/src/device/waterdetector.ts +40 -16
  124. package/src/irdevice/airconditioner.ts +11 -2
  125. package/src/irdevice/airpurifier.ts +8 -0
  126. package/src/irdevice/camera.ts +4 -0
  127. package/src/irdevice/fan.ts +4 -0
  128. package/src/irdevice/irdevice.ts +35 -2
  129. package/src/irdevice/light.ts +12 -0
  130. package/src/irdevice/other.ts +254 -283
  131. package/src/irdevice/tv.ts +12 -0
  132. package/src/irdevice/vacuumcleaner.ts +4 -0
  133. package/src/irdevice/waterheater.ts +1 -1
  134. package/src/platform.ts +11 -2
  135. package/src/types/bledevicestatus.ts +1 -0
  136. package/src/utils.ts +15 -0
@@ -21,32 +21,33 @@ export class Others extends irdeviceBase {
21
21
  Fan;
22
22
  StatefulProgrammableSwitch;
23
23
  Outlet;
24
+ On;
24
25
  // Config
25
26
  otherDeviceType;
26
27
  constructor(platform, accessory, device) {
27
28
  super(platform, accessory, device);
28
29
  this.platform = platform;
29
- // Set category
30
- accessory.category = 1 /* this.hap.Categories.OTHER */;
31
30
  // default placeholders
32
31
  this.getOtherConfigSettings(device);
33
32
  // deviceType
34
33
  if (this.otherDeviceType === 'switch') {
34
+ // Set category
35
+ accessory.category = 8 /* this.hap.Categories.SWITCH */;
35
36
  // Initialize Switch Service
36
37
  accessory.context.Switch = accessory.context.Switch ?? {};
38
+ if (accessory.context.Switch.Name) {
39
+ accessory.context.Switch.Name = this.validateAndCleanString(accessory.context.Switch.Name, 'Switch Name', accessory.context.Switch.Name);
40
+ }
37
41
  this.Switch = {
38
- Name: accessory.context.Switch.Name ?? `${accessory.displayName} Switch`,
42
+ Name: accessory.context.Switch.Name ?? accessory.displayName,
39
43
  Service: accessory.getService(this.hap.Service.Switch) ?? accessory.addService(this.hap.Service.Switch),
40
- On: accessory.context.On ?? false,
41
44
  };
42
45
  accessory.context.Switch = this.Switch;
43
- this.debugWarnLog('Displaying as Switch');
46
+ this.debugLog('Displaying as Switch');
47
+ // Initialize Switch Characteristics
44
48
  this.Switch.Service
45
- .setCharacteristic(this.hap.Characteristic.Name, accessory.displayName)
49
+ .setCharacteristic(this.hap.Characteristic.Name, this.Switch.Name)
46
50
  .getCharacteristic(this.hap.Characteristic.On)
47
- .onGet(() => {
48
- return this.Switch.On;
49
- })
50
51
  .onSet(this.OnSet.bind(this));
51
52
  // Remove other services
52
53
  this.removeFanService(accessory);
@@ -60,21 +61,29 @@ export class Others extends irdeviceBase {
60
61
  this.removeStatefulProgrammableSwitchService(accessory);
61
62
  }
62
63
  else if (this.otherDeviceType === 'garagedoor') {
63
- // Initialize Garage Door Service
64
+ // Set category
65
+ accessory.category = 4 /* this.hap.Categories.GARAGE_DOOR_OPENER */;
66
+ // Initialize GarageDoor Service
64
67
  accessory.context.GarageDoor = accessory.context.GarageDoor ?? {};
68
+ if (accessory.context.GarageDoor.Name) {
69
+ accessory.context.GarageDoor.Name = this.validateAndCleanString(accessory.context.GarageDoor.Name, 'GarageDoor Name', accessory.context.GarageDoor.Name);
70
+ }
65
71
  this.GarageDoor = {
66
- Name: accessory.context.GarageDoor.Name ?? `${accessory.displayName} Garage Door`,
72
+ Name: accessory.context.GarageDoor.Name ?? accessory.displayName,
67
73
  Service: accessory.getService(this.hap.Service.GarageDoorOpener) ?? accessory.addService(this.hap.Service.GarageDoorOpener),
68
- On: accessory.context.On ?? false,
69
74
  };
70
75
  accessory.context.GarageDoor = this.GarageDoor;
71
- this.debugWarnLog('Displaying as Garage Door Opener');
76
+ this.debugLog('Displaying as Garage Door Opener');
77
+ // Initialize GarageDoor Characteristics
72
78
  this.GarageDoor.Service
73
- .setCharacteristic(this.hap.Characteristic.Name, accessory.displayName)
79
+ .setCharacteristic(this.hap.Characteristic.Name, this.GarageDoor.Name)
74
80
  .setCharacteristic(this.hap.Characteristic.ObstructionDetected, false)
75
81
  .getCharacteristic(this.hap.Characteristic.TargetDoorState)
76
- .onGet(() => {
77
- return this.GarageDoor.On;
82
+ .setProps({
83
+ validValues: [0, 100],
84
+ minValue: 0,
85
+ maxValue: 100,
86
+ minStep: 100,
78
87
  })
79
88
  .onSet(this.OnSet.bind(this));
80
89
  // Remove other services
@@ -89,27 +98,28 @@ export class Others extends irdeviceBase {
89
98
  this.removeStatefulProgrammableSwitchService(accessory);
90
99
  }
91
100
  else if (this.otherDeviceType === 'door') {
101
+ // Set category
102
+ accessory.category = 12 /* this.hap.Categories.DOOR */;
92
103
  // Initialize Door Service
93
104
  accessory.context.Door = accessory.context.Door ?? {};
105
+ if (accessory.context.Door.Name) {
106
+ accessory.context.Door.Name = this.validateAndCleanString(accessory.context.Door.Name, 'Door Name', accessory.context.Door.Name);
107
+ }
94
108
  this.Door = {
95
- Name: accessory.context.Door.Name ?? `${accessory.displayName} Door`,
109
+ Name: accessory.context.Door.Name ?? accessory.displayName,
96
110
  Service: accessory.getService(this.hap.Service.Door) ?? accessory.addService(this.hap.Service.Door),
97
- On: accessory.context.On ?? false,
98
111
  };
99
112
  accessory.context.Door = this.Door;
100
- this.debugWarnLog('Displaying as Door');
113
+ this.debugLog('Displaying as Door');
114
+ // Initialize Door Characteristics
101
115
  this.Door.Service
102
- .setCharacteristic(this.hap.Characteristic.Name, accessory.displayName)
116
+ .setCharacteristic(this.hap.Characteristic.Name, this.Door.Name)
103
117
  .setCharacteristic(this.hap.Characteristic.PositionState, this.hap.Characteristic.PositionState.STOPPED)
104
- .getCharacteristic(this.hap.Characteristic.TargetPosition)
105
- .setProps({
118
+ .getCharacteristic(this.hap.Characteristic.TargetPosition).setProps({
106
119
  validValues: [0, 100],
107
120
  minValue: 0,
108
121
  maxValue: 100,
109
122
  minStep: 100,
110
- })
111
- .onGet(() => {
112
- return this.GarageDoor.On;
113
123
  })
114
124
  .onSet(this.OnSet.bind(this));
115
125
  // Remove other services
@@ -124,26 +134,28 @@ export class Others extends irdeviceBase {
124
134
  this.removeStatefulProgrammableSwitchService(accessory);
125
135
  }
126
136
  else if (this.otherDeviceType === 'window') {
137
+ // Set category
138
+ accessory.category = 13 /* this.hap.Categories.WINDOW */;
127
139
  // Initialize Window Service
128
140
  accessory.context.Window = accessory.context.Window ?? {};
141
+ if (accessory.context.Window.Name) {
142
+ accessory.context.Window.Name = this.validateAndCleanString(accessory.context.Window.Name, 'Window Name', accessory.context.Window.Name);
143
+ }
129
144
  this.Window = {
130
- Name: accessory.context.Window.Name ?? `${accessory.displayName} Window`,
145
+ Name: accessory.context.Window.Name ?? accessory.displayName,
131
146
  Service: accessory.getService(this.hap.Service.Window) ?? accessory.addService(this.hap.Service.Window),
132
- On: accessory.context.On ?? false,
133
147
  };
134
148
  accessory.context.Window = this.Window;
135
- this.debugWarnLog('Displaying as Window');
136
- this.Window.Service.setCharacteristic(this.hap.Characteristic.Name, accessory.displayName)
149
+ this.debugLog('Displaying as Window');
150
+ // Initialize Window Characteristics
151
+ this.Window.Service
152
+ .setCharacteristic(this.hap.Characteristic.Name, this.Window.Name)
137
153
  .setCharacteristic(this.hap.Characteristic.PositionState, this.hap.Characteristic.PositionState.STOPPED)
138
- .getCharacteristic(this.hap.Characteristic.TargetPosition)
139
- .setProps({
154
+ .getCharacteristic(this.hap.Characteristic.TargetPosition).setProps({
140
155
  validValues: [0, 100],
141
156
  minValue: 0,
142
157
  maxValue: 100,
143
158
  minStep: 100,
144
- })
145
- .onGet(() => {
146
- return this.GarageDoor.On;
147
159
  })
148
160
  .onSet(this.OnSet.bind(this));
149
161
  // Remove other services
@@ -158,17 +170,22 @@ export class Others extends irdeviceBase {
158
170
  this.removeStatefulProgrammableSwitchService(accessory);
159
171
  }
160
172
  else if (this.otherDeviceType === 'windowcovering') {
173
+ // Set category
174
+ accessory.category = 14 /* this.hap.Categories.WINDOW_COVERING */;
161
175
  // Initialize WindowCovering Service
162
176
  accessory.context.WindowCovering = accessory.context.WindowCovering ?? {};
177
+ if (accessory.context.WindowCovering.Name) {
178
+ accessory.context.WindowCovering.Name = this.validateAndCleanString(accessory.context.WindowCovering.Name, 'WindowCovering Name', accessory.context.WindowCovering.Name);
179
+ }
163
180
  this.WindowCovering = {
164
- Name: accessory.context.WindowCovering.Name ?? `${accessory.displayName} Window Covering`,
181
+ Name: accessory.context.WindowCovering.Name ?? accessory.displayName,
165
182
  Service: accessory.getService(this.hap.Service.WindowCovering) ?? accessory.addService(this.hap.Service.WindowCovering),
166
- On: accessory.context.On ?? false,
167
183
  };
168
184
  accessory.context.WindowCovering = this.WindowCovering;
169
- this.debugWarnLog('Displaying as Window Covering');
185
+ this.debugLog('Displaying as Window Covering');
186
+ // Initialize WindowCovering Characteristics
170
187
  this.WindowCovering.Service
171
- .setCharacteristic(this.hap.Characteristic.Name, accessory.displayName)
188
+ .setCharacteristic(this.hap.Characteristic.Name, this.WindowCovering.Name)
172
189
  .setCharacteristic(this.hap.Characteristic.PositionState, this.hap.Characteristic.PositionState.STOPPED)
173
190
  .getCharacteristic(this.hap.Characteristic.TargetPosition)
174
191
  .setProps({
@@ -176,9 +193,6 @@ export class Others extends irdeviceBase {
176
193
  minValue: 0,
177
194
  maxValue: 100,
178
195
  minStep: 100,
179
- })
180
- .onGet(() => {
181
- return this.WindowCovering.On;
182
196
  })
183
197
  .onSet(this.OnSet.bind(this));
184
198
  // Remove other services
@@ -193,21 +207,24 @@ export class Others extends irdeviceBase {
193
207
  this.removeStatefulProgrammableSwitchService(accessory);
194
208
  }
195
209
  else if (this.otherDeviceType === 'lock') {
196
- // Initialize LockMechanism Service
210
+ // Set category
211
+ accessory.category = 6 /* this.hap.Categories.DOOR_LOCK */;
212
+ // Initialize Lock Service
197
213
  accessory.context.LockMechanism = accessory.context.LockMechanism ?? {};
214
+ if (accessory.context.LockMechanism.Name) {
215
+ accessory.context.LockMechanism.Name = this.validateAndCleanString(accessory.context.LockMechanism.Name, 'LockMechanism Name', accessory.context.LockMechanism.Name);
216
+ }
198
217
  this.LockMechanism = {
199
- Name: accessory.context.LockMechanism.Name ?? `${accessory.displayName} Lock`,
218
+ Name: accessory.context.LockMechanism.Name ?? accessory.displayName,
200
219
  Service: accessory.getService(this.hap.Service.LockMechanism) ?? accessory.addService(this.hap.Service.LockMechanism),
201
- On: accessory.context.On ?? false,
202
220
  };
203
221
  accessory.context.LockMechanism = this.LockMechanism;
204
- this.debugWarnLog('Displaying as Lock');
222
+ this.debugLog('Displaying as Lock');
223
+ // Initialize Lock Characteristics
205
224
  this.LockMechanism.Service
206
- .setCharacteristic(this.hap.Characteristic.Name, accessory.displayName)
225
+ .setCharacteristic(this.hap.Characteristic.Name, this.LockMechanism.Name)
226
+ .setCharacteristic(this.hap.Characteristic.PositionState, this.hap.Characteristic.PositionState.STOPPED)
207
227
  .getCharacteristic(this.hap.Characteristic.LockTargetState)
208
- .onGet(() => {
209
- return this.LockMechanism.On;
210
- })
211
228
  .onSet(this.OnSet.bind(this));
212
229
  // Remove other services
213
230
  this.removeFanService(accessory);
@@ -221,21 +238,23 @@ export class Others extends irdeviceBase {
221
238
  this.removeStatefulProgrammableSwitchService(accessory);
222
239
  }
223
240
  else if (this.otherDeviceType === 'faucet') {
241
+ // Set category
242
+ accessory.category = 29 /* this.hap.Categories.FAUCET */;
224
243
  // Initialize Faucet Service
225
244
  accessory.context.Faucet = accessory.context.Faucet ?? {};
245
+ if (accessory.context.Faucet.Name) {
246
+ accessory.context.Faucet.Name = this.validateAndCleanString(accessory.context.Faucet.Name, 'Faucet Name', accessory.context.Faucet.Name);
247
+ }
226
248
  this.Faucet = {
227
- Name: accessory.context.Faucet.Name ?? `${accessory.displayName} Faucet`,
249
+ Name: accessory.context.Faucet.Name ?? accessory.displayName,
228
250
  Service: accessory.getService(this.hap.Service.Faucet) ?? accessory.addService(this.hap.Service.Faucet),
229
- On: accessory.context.On ?? false,
230
251
  };
231
252
  accessory.context.Faucet = this.Faucet;
232
- this.debugWarnLog('Displaying as Faucet');
253
+ this.debugLog('Displaying as Faucet');
254
+ // Initialize Faucet Characteristics
233
255
  this.Faucet.Service
234
- .setCharacteristic(this.hap.Characteristic.Name, accessory.displayName)
256
+ .setCharacteristic(this.hap.Characteristic.Name, this.Faucet.Name)
235
257
  .getCharacteristic(this.hap.Characteristic.Active)
236
- .onGet(() => {
237
- return this.Faucet.On;
238
- })
239
258
  .onSet(this.OnSet.bind(this));
240
259
  // Remove other services
241
260
  this.removeFanService(accessory);
@@ -249,21 +268,23 @@ export class Others extends irdeviceBase {
249
268
  this.removeStatefulProgrammableSwitchService(accessory);
250
269
  }
251
270
  else if (this.otherDeviceType === 'fan') {
271
+ // Set category
272
+ accessory.category = 3 /* this.hap.Categories.FAN */;
252
273
  // Initialize Fan Service
253
274
  accessory.context.Fan = accessory.context.Fan ?? {};
275
+ if (accessory.context.Fan.Name) {
276
+ accessory.context.Fan.Name = this.validateAndCleanString(accessory.context.Fan.Name, 'Fan Name', accessory.context.Fan.Name);
277
+ }
254
278
  this.Fan = {
255
- Name: accessory.context.Fan.Name ?? `${accessory.displayName} Fan`,
279
+ Name: accessory.context.Fan.Name ?? accessory.displayName,
256
280
  Service: accessory.getService(this.hap.Service.Fanv2) ?? accessory.addService(this.hap.Service.Fanv2),
257
- On: accessory.context.On ?? false,
258
281
  };
259
282
  accessory.context.Fan = this.Fan;
260
- this.debugWarnLog('Displaying as Fan');
283
+ this.debugLog('Displaying as Fan');
284
+ // Initialize Fan Characteristics
261
285
  this.Fan.Service
262
- .setCharacteristic(this.hap.Characteristic.Name, accessory.displayName)
263
- .getCharacteristic(this.hap.Characteristic.On)
264
- .onGet(() => {
265
- return this.Fan.On;
266
- })
286
+ .setCharacteristic(this.hap.Characteristic.Name, this.Fan.Name)
287
+ .getCharacteristic(this.hap.Characteristic.Active)
267
288
  .onSet(this.OnSet.bind(this));
268
289
  // Remove other services
269
290
  this.removeLockService(accessory);
@@ -277,22 +298,24 @@ export class Others extends irdeviceBase {
277
298
  this.removeStatefulProgrammableSwitchService(accessory);
278
299
  }
279
300
  else if (this.otherDeviceType === 'stateful') {
301
+ // Set category
302
+ accessory.category = 15 /* this.hap.Categories.PROGRAMMABLE_SWITCH */;
280
303
  // Initialize StatefulProgrammableSwitch Service
281
304
  accessory.context.StatefulProgrammableSwitch = accessory.context.StatefulProgrammableSwitch ?? {};
305
+ if (accessory.context.StatefulProgrammableSwitch.Name) {
306
+ accessory.context.StatefulProgrammableSwitch.Name = this.validateAndCleanString(accessory.context.StatefulProgrammableSwitch.Name, 'StatefulProgrammableSwitch Name', accessory.context.StatefulProgrammableSwitch.Name);
307
+ }
282
308
  this.StatefulProgrammableSwitch = {
283
- Name: accessory.context.StatefulProgrammableSwitch.Name ?? `${accessory.displayName} Stateful Programmable Switch`,
309
+ Name: accessory.context.StatefulProgrammableSwitch.Name ?? accessory.displayName,
284
310
  Service: accessory.getService(this.hap.Service.StatefulProgrammableSwitch)
285
311
  ?? accessory.addService(this.hap.Service.StatefulProgrammableSwitch),
286
- On: accessory.context.On ?? false,
287
312
  };
288
313
  accessory.context.StatefulProgrammableSwitch = this.StatefulProgrammableSwitch;
289
- this.debugWarnLog('Displaying as Stateful Programmable Switch');
314
+ this.debugLog('Displaying as Stateful Programmable Switch');
315
+ // Initialize StatefulProgrammableSwitch Characteristics
290
316
  this.StatefulProgrammableSwitch.Service
291
- .setCharacteristic(this.hap.Characteristic.Name, accessory.displayName)
317
+ .setCharacteristic(this.hap.Characteristic.Name, this.StatefulProgrammableSwitch.Name)
292
318
  .getCharacteristic(this.hap.Characteristic.ProgrammableSwitchOutputState)
293
- .onGet(() => {
294
- return this.StatefulProgrammableSwitch.On;
295
- })
296
319
  .onSet(this.OnSet.bind(this));
297
320
  // Remove other services
298
321
  this.removeFanService(accessory);
@@ -305,22 +328,24 @@ export class Others extends irdeviceBase {
305
328
  this.removeGarageDoorService(accessory);
306
329
  this.removeWindowCoveringService(accessory);
307
330
  }
308
- else {
309
- // Initialize Outlet Service
331
+ else if (this.otherDeviceType === 'outlet') {
332
+ // Set category
333
+ accessory.category = 7 /* this.hap.Categories.OUTLET */;
334
+ // Initialize Switch property
310
335
  accessory.context.Outlet = accessory.context.Outlet ?? {};
336
+ if (accessory.context.Outlet.Name) {
337
+ accessory.context.Outlet.Name = this.validateAndCleanString(accessory.context.Outlet.Name, 'Outlet Name', accessory.context.Outlet.Name);
338
+ }
311
339
  this.Outlet = {
312
- Name: accessory.context.Outlet.Name ?? `${accessory.displayName} Outlet`,
340
+ Name: accessory.context.Outlet.Name ?? accessory.displayName,
313
341
  Service: accessory.getService(this.hap.Service.Outlet) ?? accessory.addService(this.hap.Service.Outlet),
314
- On: accessory.context.On ?? false,
315
342
  };
316
343
  accessory.context.Outlet = this.Outlet;
317
- this.debugWarnLog('Displaying as Outlet');
344
+ this.debugLog('Displaying as Outlet');
345
+ // Initialize Outlet Characteristics
318
346
  this.Outlet.Service
319
- .setCharacteristic(this.hap.Characteristic.Name, accessory.displayName)
347
+ .setCharacteristic(this.hap.Characteristic.Name, this.Outlet.Name)
320
348
  .getCharacteristic(this.hap.Characteristic.On)
321
- .onGet(() => {
322
- return this.Outlet.On;
323
- })
324
349
  .onSet(this.OnSet.bind(this));
325
350
  // Remove other services
326
351
  this.removeFanService(accessory);
@@ -333,93 +358,74 @@ export class Others extends irdeviceBase {
333
358
  this.removeWindowCoveringService(accessory);
334
359
  this.removeStatefulProgrammableSwitchService(accessory);
335
360
  }
361
+ else {
362
+ this.errorLog('Device Type not set');
363
+ }
336
364
  }
337
365
  /**
338
366
  * Handle requests to set the "On" characteristic
339
367
  */
340
368
  async OnSet(value) {
341
- let On;
342
- if (this.otherDeviceType === 'garagedoor') {
343
- this.infoLog(`Set TargetDoorState: ${value}`);
344
- if (value === this.hap.Characteristic.TargetDoorState.CLOSED) {
345
- this.GarageDoor.On = false;
369
+ if (this.otherDeviceType === 'switch') {
370
+ if (this.Switch) {
371
+ await this.debugLog(`Set On: ${value}`);
372
+ this.On = value === false ? false : true;
346
373
  }
347
- else {
348
- this.GarageDoor.On = true;
374
+ }
375
+ else if (this.otherDeviceType === 'garagedoor') {
376
+ if (this.GarageDoor) {
377
+ await this.debugLog(`Set TargetDoorState: ${value}`);
378
+ this.On = value === this.hap.Characteristic.TargetDoorState.CLOSED ? false : true;
349
379
  }
350
- On = this.GarageDoor.On;
351
380
  }
352
381
  else if (this.otherDeviceType === 'door') {
353
- this.infoLog(`Set TargetPosition: ${value}`);
354
- if (value === 0) {
355
- this.Door.On = false;
356
- }
357
- else {
358
- this.Door.On = true;
382
+ if (this.Door) {
383
+ await this.debugLog(`Set TargetPosition: ${value}`);
384
+ this.On = value === 0 ? false : true;
359
385
  }
360
- On = this.Door.On;
361
386
  }
362
387
  else if (this.otherDeviceType === 'window') {
363
- this.infoLog(`Set TargetPosition: ${value}`);
364
- if (value === 0) {
365
- this.Window.On = false;
366
- }
367
- else {
368
- this.Window.On = true;
388
+ if (this.Window) {
389
+ await this.debugLog(`Set TargetPosition: ${value}`);
390
+ this.On = value === 0 ? false : true;
369
391
  }
370
- On = this.Window.On;
371
392
  }
372
393
  else if (this.otherDeviceType === 'windowcovering') {
373
- this.infoLog(`Set TargetPosition: ${value}`);
374
- if (value === 0) {
375
- this.WindowCovering.On = false;
376
- }
377
- else {
378
- this.WindowCovering.On = true;
394
+ if (this.WindowCovering) {
395
+ await this.debugLog(`Set TargetPosition: ${value}`);
396
+ this.On = value === 0 ? false : true;
379
397
  }
380
- On = this.WindowCovering.On;
381
398
  }
382
399
  else if (this.otherDeviceType === 'lock') {
383
- this.infoLog(`Set LockTargetState: ${value}`);
384
- if (value === this.hap.Characteristic.LockTargetState.SECURED) {
385
- this.LockMechanism.On = false;
386
- }
387
- else {
388
- this.LockMechanism.On = true;
400
+ if (this.LockMechanism) {
401
+ await this.debugLog(`Set LockTargetState: ${value}`);
402
+ this.On = value === this.hap.Characteristic.LockTargetState.SECURED ? false : true;
389
403
  }
390
- On = this.LockMechanism.On;
391
404
  }
392
405
  else if (this.otherDeviceType === 'faucet') {
393
- this.infoLog(`Set Active: ${value}`);
394
- if (value === this.hap.Characteristic.Active.INACTIVE) {
395
- this.Faucet.On = false;
396
- }
397
- else {
398
- this.Faucet.On = true;
406
+ if (this.Faucet) {
407
+ await this.debugLog(`Set Active: ${value}`);
408
+ this.On = value === this.hap.Characteristic.Active.INACTIVE ? false : true;
399
409
  }
400
- On = this.Faucet.On;
401
410
  }
402
411
  else if (this.otherDeviceType === 'stateful') {
403
- this.infoLog(`Set ProgrammableSwitchOutputState: ${value}`);
404
- if (value === 0) {
405
- this.StatefulProgrammableSwitch.On = false;
406
- }
407
- else {
408
- this.StatefulProgrammableSwitch.On = true;
412
+ if (this.StatefulProgrammableSwitch) {
413
+ await this.debugLog(`Set ProgrammableSwitchOutputState: ${value}`);
414
+ this.On = value === 0 ? false : true;
409
415
  }
410
- On = this.StatefulProgrammableSwitch.On;
411
416
  }
412
417
  else {
413
- this.infoLog(`Set On: ${value}`);
414
- this.Outlet.On = value;
415
- On = this.Outlet.On ? true : false;
418
+ if (this.Outlet) {
419
+ await this.debugLog(`Set On: ${value}`);
420
+ this.On = value === false ? false : true;
421
+ }
416
422
  }
417
423
  //pushChanges
418
- if (On === true) {
419
- await this.pushOnChanges(On);
424
+ if (this.On === true) {
425
+ await this.pushOnChanges(this.On);
420
426
  }
421
427
  else {
422
- await this.pushOffChanges(On);
428
+ await this.pushOffChanges(this.On);
423
429
  }
424
430
  }
425
431
  /**
@@ -498,181 +504,173 @@ export class Others extends irdeviceBase {
498
504
  }
499
505
  async updateHomeKitCharacteristics() {
500
506
  await this.debugLog('updateHomeKitCharacteristics');
501
- if (this.otherDeviceType === 'garagedoor') {
502
- if (this.GarageDoor.On === undefined) {
503
- await this.debugLog(`On: ${this.GarageDoor.On}`);
507
+ // State
508
+ if (this.otherDeviceType === 'switch' && this.Switch) {
509
+ if (this.On === undefined) {
510
+ await this.debugLog(`On: ${this.On}`);
511
+ }
512
+ else {
513
+ this.Switch.Service.updateCharacteristic(this.hap.Characteristic.On, this.On);
514
+ await this.debugLog(`updateCharacteristic On: ${this.On}`);
515
+ }
516
+ }
517
+ else if (this.otherDeviceType === 'garagedoor' && this.GarageDoor) {
518
+ if (this.On === undefined) {
519
+ await this.debugLog(`On: ${this.On}`);
504
520
  }
505
521
  else {
506
- if (this.GarageDoor.On) {
522
+ if (this.On) {
507
523
  this.GarageDoor.Service.updateCharacteristic(this.hap.Characteristic.TargetDoorState, this.hap.Characteristic.TargetDoorState.OPEN);
508
524
  this.GarageDoor.Service.updateCharacteristic(this.hap.Characteristic.CurrentDoorState, this.hap.Characteristic.CurrentDoorState.OPEN);
509
- await this.debugLog('updateCharacteristic'
510
- + ` TargetDoorState: Open, CurrentDoorState: Open (${this.GarageDoor.On})`);
525
+ await this.debugLog(`updateCharacteristic TargetDoorState: Open, CurrentDoorState: Open (${this.On})`);
511
526
  }
512
527
  else {
513
528
  this.GarageDoor.Service.updateCharacteristic(this.hap.Characteristic.TargetDoorState, this.hap.Characteristic.TargetDoorState.CLOSED);
514
529
  this.GarageDoor.Service.updateCharacteristic(this.hap.Characteristic.CurrentDoorState, this.hap.Characteristic.CurrentDoorState.CLOSED);
515
- await this.debugLog('updateCharacteristic'
516
- + ` TargetDoorState: Closed, CurrentDoorState: Closed (${this.GarageDoor.On})`);
530
+ await this.debugLog(`updateCharacteristicc TargetDoorState: Closed, CurrentDoorState: Closed (${this.On})`);
517
531
  }
518
532
  }
519
- await this.debugLog(`Garage Door On: ${this.GarageDoor.On}`);
533
+ await this.debugLog(`Garage Door On: ${this.On}`);
520
534
  }
521
- else if (this.otherDeviceType === 'door') {
522
- if (this.Door.On === undefined) {
523
- await this.debugLog(`On: ${this.Door.On}`);
535
+ else if (this.otherDeviceType === 'door' && this.Door) {
536
+ if (this.On === undefined) {
537
+ await this.debugLog(`On: ${this.On}`);
524
538
  }
525
539
  else {
526
- if (this.Door.On) {
540
+ if (this.On) {
527
541
  this.Door.Service.updateCharacteristic(this.hap.Characteristic.TargetPosition, 100);
528
542
  this.Door.Service.updateCharacteristic(this.hap.Characteristic.CurrentPosition, 100);
529
543
  this.Door.Service.updateCharacteristic(this.hap.Characteristic.PositionState, this.hap.Characteristic.PositionState.STOPPED);
530
- await this.debugLog('updateCharacteristic'
531
- + ` TargetPosition: 100, CurrentPosition: 100 (${this.Door.On})`);
544
+ await this.debugLog(`updateCharacteristicc TargetPosition: 100, CurrentPosition: 100 (${this.On})`);
532
545
  }
533
546
  else {
534
547
  this.Door.Service.updateCharacteristic(this.hap.Characteristic.TargetPosition, 0);
535
548
  this.Door.Service.updateCharacteristic(this.hap.Characteristic.CurrentPosition, 0);
536
549
  this.Door.Service.updateCharacteristic(this.hap.Characteristic.PositionState, this.hap.Characteristic.PositionState.STOPPED);
537
- await this.debugLog('updateCharacteristic'
538
- + ` TargetPosition: 0, CurrentPosition: 0 (${this.Door.On})`);
550
+ await this.debugLog(`updateCharacteristicc TargetPosition: 0, CurrentPosition: 0 (${this.On})`);
539
551
  }
540
552
  }
541
- await this.debugLog(`Door On: ${this.Door.On}`);
553
+ await this.debugLog(`Door On: ${this.On}`);
542
554
  }
543
- else if (this.otherDeviceType === 'window') {
544
- if (this.Window.On === undefined) {
545
- await this.debugLog(`On: ${this.Window.On}`);
555
+ else if (this.otherDeviceType === 'window' && this.Window) {
556
+ if (this.On === undefined) {
557
+ await this.debugLog(`On: ${this.On}`);
546
558
  }
547
559
  else {
548
- if (this.Window.On) {
560
+ if (this.On) {
549
561
  this.Window.Service.updateCharacteristic(this.hap.Characteristic.TargetPosition, 100);
550
562
  this.Window.Service.updateCharacteristic(this.hap.Characteristic.CurrentPosition, 100);
551
563
  this.Window.Service.updateCharacteristic(this.hap.Characteristic.PositionState, this.hap.Characteristic.PositionState.STOPPED);
552
- await this.debugLog('updateCharacteristic'
553
- + ` TargetPosition: 100, CurrentPosition: 100 (${this.Window.On})`);
564
+ await this.debugLog(`updateCharacteristicc TargetPosition: 100, CurrentPosition: 100 (${this.On})`);
554
565
  }
555
566
  else {
556
567
  this.Window.Service.updateCharacteristic(this.hap.Characteristic.TargetPosition, 0);
557
568
  this.Window.Service.updateCharacteristic(this.hap.Characteristic.CurrentPosition, 0);
558
569
  this.Window.Service.updateCharacteristic(this.hap.Characteristic.PositionState, this.hap.Characteristic.PositionState.STOPPED);
559
- await this.debugLog('updateCharacteristic'
560
- + ` TargetPosition: 0, CurrentPosition: 0 (${this.Window.On})`);
570
+ await this.debugLog(`updateCharacteristicc TargetPosition: 0, CurrentPosition: 0 (${this.On})`);
561
571
  }
562
572
  }
563
- await this.debugLog(`Window On: ${this.Window.On}`);
573
+ await this.debugLog(`Window On: ${this.On}`);
564
574
  }
565
- else if (this.otherDeviceType === 'windowcovering') {
566
- if (this.WindowCovering.On === undefined) {
567
- await this.debugLog(`On: ${this.WindowCovering.On}`);
575
+ else if (this.otherDeviceType === 'windowcovering' && this.WindowCovering) {
576
+ if (this.On === undefined) {
577
+ await this.debugLog(`On: ${this.On}`);
568
578
  }
569
579
  else {
570
- if (this.WindowCovering.On) {
580
+ if (this.On) {
571
581
  this.WindowCovering.Service.updateCharacteristic(this.hap.Characteristic.TargetPosition, 100);
572
582
  this.WindowCovering.Service.updateCharacteristic(this.hap.Characteristic.CurrentPosition, 100);
573
583
  this.WindowCovering.Service.updateCharacteristic(this.hap.Characteristic.PositionState, this.hap.Characteristic.PositionState.STOPPED);
574
- await this.debugLog('updateCharacteristic'
575
- + ` TargetPosition: 100, CurrentPosition: 100 (${this.WindowCovering.On})`);
584
+ await this.debugLog(`updateCharacteristicc TargetPosition: 100, CurrentPosition: 100 (${this.On})`);
576
585
  }
577
586
  else {
578
587
  this.WindowCovering.Service.updateCharacteristic(this.hap.Characteristic.TargetPosition, 0);
579
588
  this.WindowCovering.Service.updateCharacteristic(this.hap.Characteristic.CurrentPosition, 0);
580
589
  this.WindowCovering.Service.updateCharacteristic(this.hap.Characteristic.PositionState, this.hap.Characteristic.PositionState.STOPPED);
581
- await this.debugLog('updateCharacteristic'
582
- + ` TargetPosition: 0, CurrentPosition: 0 (${this.WindowCovering.On})`);
590
+ await this.debugLog(`updateCharacteristicc TargetPosition: 0, CurrentPosition: 0 (${this.On})`);
583
591
  }
584
592
  }
585
- await this.debugLog(`Window Covering On: ${this.WindowCovering.On}`);
593
+ await this.debugLog(`Window Covering On: ${this.On}`);
586
594
  }
587
- else if (this.otherDeviceType === 'lock') {
588
- if (this.LockMechanism?.On === undefined) {
589
- await this.debugLog(`On: ${this.LockMechanism?.On}`);
595
+ else if (this.otherDeviceType === 'lock' && this.LockMechanism) {
596
+ if (this.On === undefined) {
597
+ await this.debugLog(`On: ${this.On}`);
590
598
  }
591
599
  else {
592
- if (this.LockMechanism.On) {
600
+ if (this.On) {
593
601
  this.LockMechanism.Service.updateCharacteristic(this.hap.Characteristic.LockTargetState, this.hap.Characteristic.LockTargetState.UNSECURED);
594
602
  this.LockMechanism.Service.updateCharacteristic(this.hap.Characteristic.LockCurrentState, this.hap.Characteristic.LockCurrentState.UNSECURED);
595
- await this.debugLog('updateCharacteristic'
596
- + ` LockTargetState: UNSECURED, LockCurrentState: UNSECURE (${this.LockMechanism.On})`);
603
+ await this.debugLog(`updateCharacteristicc LockTargetState: UNSECURED, LockCurrentState: UNSECURED (${this.On})`);
597
604
  }
598
605
  else {
599
606
  this.LockMechanism.Service.updateCharacteristic(this.hap.Characteristic.LockTargetState, this.hap.Characteristic.LockTargetState.SECURED);
600
607
  this.LockMechanism.Service.updateCharacteristic(this.hap.Characteristic.LockCurrentState, this.hap.Characteristic.LockCurrentState.SECURED);
601
- await this.debugLog('updateCharacteristic'
602
- + ` LockTargetState: SECURED, LockCurrentState: SECURED (${this.LockMechanism.On})`);
608
+ await this.debugLog(`updateCharacteristic LockTargetState: SECURED, LockCurrentState: SECURED (${this.On})`);
603
609
  }
604
610
  }
605
- await this.debugLog(`Lock On: ${this.LockMechanism?.On}`);
611
+ await this.debugLog(`Lock On: ${this.On}`);
606
612
  }
607
- else if (this.otherDeviceType === 'faucet') {
608
- if (this.Faucet.On === undefined) {
609
- await this.debugLog(`On: ${this.Faucet.On}`);
613
+ else if (this.otherDeviceType === 'faucet' && this.Faucet) {
614
+ if (this.On === undefined) {
615
+ await this.debugLog(`On: ${this.On}`);
610
616
  }
611
617
  else {
612
- if (this.Faucet.On) {
618
+ if (this.On) {
613
619
  this.Faucet.Service.updateCharacteristic(this.hap.Characteristic.Active, this.hap.Characteristic.Active.ACTIVE);
614
- await this.debugLog(`updateCharacteristic Active: ${this.Faucet.On}`);
620
+ await this.debugLog(`updateCharacteristic Active: ${this.On}`);
615
621
  }
616
622
  else {
617
623
  this.Faucet.Service.updateCharacteristic(this.hap.Characteristic.Active, this.hap.Characteristic.Active.INACTIVE);
618
- await this.debugLog(`updateCharacteristic Active: ${this.Faucet.On}`);
624
+ await this.debugLog(`updateCharacteristic Active: ${this.On}`);
619
625
  }
620
626
  }
621
- await this.debugLog(`Faucet On: ${this.Faucet.On}`);
627
+ await this.debugLog(`Faucet On: ${this.On}`);
622
628
  }
623
- else if (this.otherDeviceType === 'fan') {
624
- if (this.Fan.On === undefined) {
625
- await this.debugLog(`On: ${this.Fan.On}`);
629
+ else if (this.otherDeviceType === 'fan' && this.Fan) {
630
+ if (this.On === undefined) {
631
+ await this.debugLog(`On: ${this.On}`);
626
632
  }
627
633
  else {
628
- if (this.Fan.On) {
629
- this.Fan.Service.updateCharacteristic(this.hap.Characteristic.On, this.Fan.On);
630
- await this.debugLog(`updateCharacteristic On: ${this.Fan.On}`);
634
+ if (this.On) {
635
+ this.Fan.Service.updateCharacteristic(this.hap.Characteristic.Active, this.hap.Characteristic.Active.ACTIVE);
636
+ await this.debugLog(`updateCharacteristic Active: ${this.On}`);
631
637
  }
632
638
  else {
633
- this.Fan.Service.updateCharacteristic(this.hap.Characteristic.On, this.Fan.On);
634
- await this.debugLog(`updateCharacteristic On: ${this.Fan.On}`);
639
+ this.Fan.Service.updateCharacteristic(this.hap.Characteristic.Active, this.hap.Characteristic.Active.INACTIVE);
640
+ await this.debugLog(`updateCharacteristic Active: ${this.On}`);
635
641
  }
636
642
  }
637
- await this.debugLog(`Fan On: ${this.Fan.On}`);
643
+ await this.debugLog(`Fan On: ${this.On}`);
638
644
  }
639
- else if (this.otherDeviceType === 'stateful') {
640
- if (this.StatefulProgrammableSwitch.On === undefined) {
641
- await this.debugLog(`On: ${this.StatefulProgrammableSwitch.On}`);
645
+ else if (this.otherDeviceType === 'stateful' && this.StatefulProgrammableSwitch) {
646
+ if (this.On === undefined) {
647
+ await this.debugLog(`On: ${this.On}`);
642
648
  }
643
649
  else {
644
- if (this.StatefulProgrammableSwitch.On) {
650
+ if (this.On) {
645
651
  this.StatefulProgrammableSwitch.Service.updateCharacteristic(this.hap.Characteristic.ProgrammableSwitchEvent, this.hap.Characteristic.ProgrammableSwitchEvent.SINGLE_PRESS);
646
652
  this.StatefulProgrammableSwitch.Service.updateCharacteristic(this.hap.Characteristic.ProgrammableSwitchOutputState, 1);
647
- await this.debugLog('updateCharacteristic'
648
- + ` ProgrammableSwitchEvent: SINGLE, ProgrammableSwitchOutputState: 1 (${this.StatefulProgrammableSwitch.On})`);
653
+ await this.debugLog(`updateCharacteristic ProgrammableSwitchEvent: ProgrammableSwitchOutputState: (${this.On})`);
649
654
  }
650
655
  else {
651
656
  this.StatefulProgrammableSwitch.Service.updateCharacteristic(this.hap.Characteristic.ProgrammableSwitchEvent, this.hap.Characteristic.ProgrammableSwitchEvent.SINGLE_PRESS);
652
657
  this.StatefulProgrammableSwitch.Service.updateCharacteristic(this.hap.Characteristic.ProgrammableSwitchOutputState, 0);
653
- await this.debugLog('updateCharacteristic'
654
- + ` ProgrammableSwitchEvent: SINGLE, ProgrammableSwitchOutputState: 0 (${this.StatefulProgrammableSwitch.On})`);
658
+ await this.debugLog(`updateCharacteristic ProgrammableSwitchEvent: ProgrammableSwitchOutputState: (${this.On})`);
655
659
  }
656
660
  }
657
- await this.debugLog(`StatefulProgrammableSwitch On: ${this.StatefulProgrammableSwitch.On}`);
661
+ await this.debugLog(`StatefulProgrammableSwitch On: ${this.On}`);
658
662
  }
659
- else if (this.otherDeviceType === 'switch') {
660
- if (this.Switch.On === undefined) {
661
- await this.debugLog(`On: ${this.Switch.On}`);
663
+ else if (this.otherDeviceType === 'outlet' && this.Outlet) {
664
+ if (this.On === undefined) {
665
+ await this.debugLog(`On: ${this.On}`);
662
666
  }
663
667
  else {
664
- this.Switch.Service.updateCharacteristic(this.hap.Characteristic.On, this.Switch.On);
665
- await this.debugLog(`updateCharacteristic On: ${this.Switch.On}`);
668
+ this.Outlet.Service.updateCharacteristic(this.hap.Characteristic.On, this.On);
669
+ await this.debugLog(`updateCharacteristic On: ${this.On}`);
666
670
  }
667
671
  }
668
672
  else {
669
- if (this.Outlet.On === undefined) {
670
- await this.debugLog(`On: ${this.Outlet.On}`);
671
- }
672
- else {
673
- this.Outlet.Service.updateCharacteristic(this.hap.Characteristic.On, this.Outlet.On);
674
- await this.debugLog(`updateCharacteristic On: ${this.Outlet.On}`);
675
- }
673
+ await this.errorLog(`otherDeviceType: ${this.otherDeviceType}, On: ${this.On}`);
676
674
  }
677
675
  }
678
676
  async apiError(e) {
@@ -743,7 +741,6 @@ export class Others extends irdeviceBase {
743
741
  this.Outlet = {
744
742
  Name: accessory.context.Outlet.Name ?? `${accessory.displayName} Outlet`,
745
743
  Service: accessory.getService(this.hap.Service.Outlet),
746
- On: accessory.context.On ?? false,
747
744
  };
748
745
  accessory.context.Outlet = this.Outlet;
749
746
  this.warnLog('Removing any leftover Outlet Service');
@@ -755,7 +752,6 @@ export class Others extends irdeviceBase {
755
752
  this.GarageDoor = {
756
753
  Name: accessory.context.GarageDoor.Name ?? `${accessory.displayName} Garage Door`,
757
754
  Service: accessory.getService(this.hap.Service.GarageDoorOpener),
758
- On: accessory.context.On ?? false,
759
755
  };
760
756
  accessory.context.GarageDoor = this.GarageDoor;
761
757
  this.warnLog('Removing any leftover Garage Door Service');
@@ -767,7 +763,6 @@ export class Others extends irdeviceBase {
767
763
  this.Door = {
768
764
  Name: accessory.context.Door.Name ?? `${accessory.displayName} Door`,
769
765
  Service: accessory.getService(this.hap.Service.Door),
770
- On: accessory.context.On ?? false,
771
766
  };
772
767
  accessory.context.Door = this.Door;
773
768
  this.warnLog('Removing any leftover Door Service');
@@ -779,7 +774,6 @@ export class Others extends irdeviceBase {
779
774
  this.LockMechanism = {
780
775
  Name: accessory.context.LockMechanism.Name ?? `${accessory.displayName} Lock`,
781
776
  Service: accessory.getService(this.hap.Service.LockMechanism),
782
- On: accessory.context.On ?? false,
783
777
  };
784
778
  accessory.context.LockMechanism = this.LockMechanism;
785
779
  this.warnLog('Removing any leftover Lock Service');
@@ -791,7 +785,6 @@ export class Others extends irdeviceBase {
791
785
  this.Faucet = {
792
786
  Name: accessory.context.Faucet.Name ?? `${accessory.displayName} Faucet`,
793
787
  Service: accessory.getService(this.hap.Service.Faucet),
794
- On: accessory.context.On ?? false,
795
788
  };
796
789
  accessory.context.Faucet = this.Faucet;
797
790
  this.warnLog('Removing any leftover Faucet Service');
@@ -803,7 +796,6 @@ export class Others extends irdeviceBase {
803
796
  this.Fan = {
804
797
  Name: accessory.context.Fan.Name ?? `${accessory.displayName} Fan`,
805
798
  Service: accessory.getService(this.hap.Service.Fanv2),
806
- On: accessory.context.On ?? false,
807
799
  };
808
800
  accessory.context.Fan = this.Fan;
809
801
  this.warnLog('Removing any leftover Fan Service');
@@ -815,7 +807,6 @@ export class Others extends irdeviceBase {
815
807
  this.Window = {
816
808
  Name: accessory.context.Window.Name ?? `${accessory.displayName} Window`,
817
809
  Service: accessory.getService(this.hap.Service.Window),
818
- On: accessory.context.On ?? false,
819
810
  };
820
811
  accessory.context.Window = this.Window;
821
812
  this.warnLog('Removing any leftover Window Service');
@@ -827,7 +818,6 @@ export class Others extends irdeviceBase {
827
818
  this.WindowCovering = {
828
819
  Name: accessory.context.WindowCovering.Name ?? `${accessory.displayName} Window Covering`,
829
820
  Service: accessory.getService(this.hap.Service.WindowCovering),
830
- On: accessory.context.On ?? false,
831
821
  };
832
822
  accessory.context.WindowCovering = this.WindowCovering;
833
823
  this.warnLog('Removing any leftover Window Covering Service');
@@ -839,7 +829,6 @@ export class Others extends irdeviceBase {
839
829
  this.StatefulProgrammableSwitch = {
840
830
  Name: accessory.context.StatefulProgrammableSwitch.Name ?? `${accessory.displayName} Stateful Programmable Switch`,
841
831
  Service: accessory.getService(this.hap.Service.StatefulProgrammableSwitch),
842
- On: accessory.context.On ?? false,
843
832
  };
844
833
  accessory.context.StatefulProgrammableSwitch = this.StatefulProgrammableSwitch;
845
834
  this.warnLog('Removing any leftover Stateful Programmable Switch Service');
@@ -851,7 +840,6 @@ export class Others extends irdeviceBase {
851
840
  this.Switch = {
852
841
  Name: accessory.context.Switch.Name ?? `${accessory.displayName} Switch`,
853
842
  Service: accessory.getService(this.hap.Service.Switch),
854
- On: accessory.context.On ?? false,
855
843
  };
856
844
  accessory.context.Switch = this.Switch;
857
845
  this.warnLog('Removing any leftover Switch Service');