@switchbot/homebridge-switchbot 2.0.0-beta.3 → 2.0.0-beta.30

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 (113) hide show
  1. package/CHANGELOG.md +10 -1
  2. package/README.md +1 -2
  3. package/config.schema.json +102 -20
  4. package/dist/device/bot.d.ts +34 -28
  5. package/dist/device/bot.d.ts.map +1 -1
  6. package/dist/device/bot.js +655 -649
  7. package/dist/device/bot.js.map +1 -1
  8. package/dist/device/colorbulb.d.ts +36 -19
  9. package/dist/device/colorbulb.d.ts.map +1 -1
  10. package/dist/device/colorbulb.js +483 -309
  11. package/dist/device/colorbulb.js.map +1 -1
  12. package/dist/device/contact.d.ts +18 -8
  13. package/dist/device/contact.d.ts.map +1 -1
  14. package/dist/device/contact.js +303 -237
  15. package/dist/device/contact.js.map +1 -1
  16. package/dist/device/curtain.d.ts +23 -16
  17. package/dist/device/curtain.d.ts.map +1 -1
  18. package/dist/device/curtain.js +541 -498
  19. package/dist/device/curtain.js.map +1 -1
  20. package/dist/device/humidifier.d.ts +24 -18
  21. package/dist/device/humidifier.d.ts.map +1 -1
  22. package/dist/device/humidifier.js +450 -369
  23. package/dist/device/humidifier.js.map +1 -1
  24. package/dist/device/lock.d.ts +27 -8
  25. package/dist/device/lock.d.ts.map +1 -1
  26. package/dist/device/lock.js +302 -148
  27. package/dist/device/lock.js.map +1 -1
  28. package/dist/device/meter.d.ts +22 -16
  29. package/dist/device/meter.d.ts.map +1 -1
  30. package/dist/device/meter.js +340 -262
  31. package/dist/device/meter.js.map +1 -1
  32. package/dist/device/meterplus.d.ts +24 -12
  33. package/dist/device/meterplus.d.ts.map +1 -1
  34. package/dist/device/meterplus.js +359 -213
  35. package/dist/device/meterplus.js.map +1 -1
  36. package/dist/device/motion.d.ts +18 -8
  37. package/dist/device/motion.d.ts.map +1 -1
  38. package/dist/device/motion.js +276 -216
  39. package/dist/device/motion.js.map +1 -1
  40. package/dist/device/plug.d.ts +27 -17
  41. package/dist/device/plug.d.ts.map +1 -1
  42. package/dist/device/plug.js +292 -251
  43. package/dist/device/plug.js.map +1 -1
  44. package/dist/device/striplight.d.ts +43 -19
  45. package/dist/device/striplight.d.ts.map +1 -1
  46. package/dist/device/striplight.js +503 -262
  47. package/dist/device/striplight.js.map +1 -1
  48. package/dist/irdevice/airconditioner.d.ts +9 -12
  49. package/dist/irdevice/airconditioner.d.ts.map +1 -1
  50. package/dist/irdevice/airconditioner.js +275 -230
  51. package/dist/irdevice/airconditioner.js.map +1 -1
  52. package/dist/irdevice/airpurifier.d.ts +5 -3
  53. package/dist/irdevice/airpurifier.d.ts.map +1 -1
  54. package/dist/irdevice/airpurifier.js +151 -104
  55. package/dist/irdevice/airpurifier.js.map +1 -1
  56. package/dist/irdevice/camera.d.ts +11 -8
  57. package/dist/irdevice/camera.d.ts.map +1 -1
  58. package/dist/irdevice/camera.js +130 -86
  59. package/dist/irdevice/camera.js.map +1 -1
  60. package/dist/irdevice/fan.d.ts +10 -7
  61. package/dist/irdevice/fan.d.ts.map +1 -1
  62. package/dist/irdevice/fan.js +157 -109
  63. package/dist/irdevice/fan.js.map +1 -1
  64. package/dist/irdevice/light.d.ts +11 -8
  65. package/dist/irdevice/light.d.ts.map +1 -1
  66. package/dist/irdevice/light.js +134 -103
  67. package/dist/irdevice/light.js.map +1 -1
  68. package/dist/irdevice/other.d.ts +11 -8
  69. package/dist/irdevice/other.d.ts.map +1 -1
  70. package/dist/irdevice/other.js +142 -98
  71. package/dist/irdevice/other.js.map +1 -1
  72. package/dist/irdevice/tv.d.ts +12 -9
  73. package/dist/irdevice/tv.d.ts.map +1 -1
  74. package/dist/irdevice/tv.js +140 -93
  75. package/dist/irdevice/tv.js.map +1 -1
  76. package/dist/irdevice/vacuumcleaner.d.ts +9 -10
  77. package/dist/irdevice/vacuumcleaner.d.ts.map +1 -1
  78. package/dist/irdevice/vacuumcleaner.js +129 -89
  79. package/dist/irdevice/vacuumcleaner.js.map +1 -1
  80. package/dist/irdevice/waterheater.d.ts +8 -9
  81. package/dist/irdevice/waterheater.d.ts.map +1 -1
  82. package/dist/irdevice/waterheater.js +129 -89
  83. package/dist/irdevice/waterheater.js.map +1 -1
  84. package/dist/platform.d.ts +14 -12
  85. package/dist/platform.d.ts.map +1 -1
  86. package/dist/platform.js +479 -434
  87. package/dist/platform.js.map +1 -1
  88. package/dist/settings.d.ts +18 -11
  89. package/dist/settings.d.ts.map +1 -1
  90. package/dist/settings.js.map +1 -1
  91. package/package.json +12 -10
  92. package/src/device/bot.ts +654 -660
  93. package/src/device/colorbulb.ts +487 -344
  94. package/src/device/contact.ts +306 -241
  95. package/src/device/curtain.ts +546 -512
  96. package/src/device/humidifier.ts +453 -403
  97. package/src/device/lock.ts +311 -149
  98. package/src/device/meter.ts +351 -275
  99. package/src/device/meterplus.ts +369 -219
  100. package/src/device/motion.ts +282 -222
  101. package/src/device/plug.ts +296 -260
  102. package/src/device/striplight.ts +519 -289
  103. package/src/irdevice/airconditioner.ts +279 -241
  104. package/src/irdevice/airpurifier.ts +148 -103
  105. package/src/irdevice/camera.ts +128 -85
  106. package/src/irdevice/fan.ts +154 -106
  107. package/src/irdevice/light.ts +132 -103
  108. package/src/irdevice/other.ts +140 -97
  109. package/src/irdevice/tv.ts +139 -93
  110. package/src/irdevice/vacuumcleaner.ts +128 -89
  111. package/src/irdevice/waterheater.ts +127 -89
  112. package/src/platform.ts +469 -456
  113. package/src/settings.ts +18 -11
@@ -1,6 +1,7 @@
1
1
  import https from 'https';
2
2
  import crypto from 'crypto';
3
3
  import { IncomingMessage } from 'http';
4
+ import superStringify from 'super-stringify';
4
5
  import { SwitchBotPlatform } from '../platform';
5
6
  import { irDevicesConfig, irdevice, HostDomain, DevicePath } from '../settings';
6
7
  import { CharacteristicValue, PlatformAccessory, Service } from 'homebridge';
@@ -16,7 +17,6 @@ export class Others {
16
17
 
17
18
  // Characteristic Values
18
19
  Active!: CharacteristicValue;
19
- ActiveCached!: CharacteristicValue;
20
20
 
21
21
  // Config
22
22
  deviceLogging!: string;
@@ -27,31 +27,30 @@ export class Others {
27
27
  this.logs(device);
28
28
  this.deviceType(device);
29
29
  this.config(device);
30
- if (this.Active === undefined) {
31
- this.Active = this.platform.Characteristic.Active.INACTIVE;
32
- } else {
33
- this.Active = this.accessory.context.Active;
34
- }
30
+ this.context();
35
31
 
36
32
  // set accessory information
37
33
  accessory
38
34
  .getService(this.platform.Service.AccessoryInformation)!
39
35
  .setCharacteristic(this.platform.Characteristic.Manufacturer, 'SwitchBot')
40
36
  .setCharacteristic(this.platform.Characteristic.Model, device.remoteType)
41
- .setCharacteristic(this.platform.Characteristic.SerialNumber, device.deviceId!);
37
+ .setCharacteristic(this.platform.Characteristic.SerialNumber, device.deviceId!)
38
+ .setCharacteristic(this.platform.Characteristic.FirmwareRevision, this.FirmwareRevision(accessory, device))
39
+ .getCharacteristic(this.platform.Characteristic.FirmwareRevision)
40
+ .updateValue(this.FirmwareRevision(accessory, device));
42
41
 
43
42
  // get the Television service if it exists, otherwise create a new Television service
44
43
  // you can create multiple services for each accessory
45
44
  if (this.otherDeviceType !== 'Fan') {
46
- this.debugLog(`Other: ${accessory.displayName} Removing Fanv2 Service`);
45
+ this.debugLog(`${this.device.remoteType}: ${accessory.displayName} Removing Fanv2 Service`);
47
46
 
48
47
  if (this.otherDeviceType === undefined) {
49
- this.errorLog(`Other: ${this.accessory.displayName} No Device Type Set, deviceType: ${device.other?.deviceType}`);
48
+ this.errorLog(`${this.device.remoteType}: ${this.accessory.displayName} No Device Type Set, deviceType: ${device.other?.deviceType}`);
50
49
  }
51
50
  this.fanService = this.accessory.getService(this.platform.Service.Fanv2);
52
51
  accessory.removeService(this.fanService!);
53
52
  } else if (!this.fanService && this.otherDeviceType === 'Fan') {
54
- this.debugLog(`Other: ${accessory.displayName} Add Fanv2 Service`);
53
+ this.debugLog(`${this.device.remoteType}: ${accessory.displayName} Add Fanv2 Service`);
55
54
  (this.fanService = this.accessory.getService(this.platform.Service.Fanv2) || this.accessory.addService(this.platform.Service.Fanv2)),
56
55
  `${accessory.displayName} Fan`;
57
56
 
@@ -59,47 +58,37 @@ export class Others {
59
58
 
60
59
  this.fanService.getCharacteristic(this.platform.Characteristic.Active).onSet(this.ActiveSet.bind(this));
61
60
  } else {
62
- this.debugLog(`Other: ${accessory.displayName} Fanv2 Service Not Added, deviceType: ${device.other?.deviceType}`);
61
+ this.debugLog(`${this.device.remoteType}: ${accessory.displayName} Fanv2 Service Not Added, deviceType: ${device.other?.deviceType}`);
63
62
  }
64
63
  }
65
64
 
66
65
  async ActiveSet(value: CharacteristicValue): Promise<void> {
67
- this.debugLog(`Other: ${this.accessory.displayName} On: ${value}`);
66
+ this.debugLog(`${this.device.remoteType}: ${this.accessory.displayName} On: ${value}`);
67
+ this.Active = value;
68
+ this.accessory.context.Active = this.Active;
68
69
  if (value) {
69
70
  await this.pushOnChanges();
70
71
  } else {
71
72
  await this.pushOffChanges();
72
73
  }
73
- this.Active = value;
74
- this.ActiveCached = this.Active;
75
- this.accessory.context.Active = this.ActiveCached;
76
- }
77
-
78
- async updateHomeKitCharacteristics(): Promise<void> {
79
- if (this.Active === undefined) {
80
- this.debugLog(`Other: ${this.accessory.displayName} Active: ${this.Active}`);
81
- } else {
82
- this.fanService?.updateCharacteristic(this.platform.Characteristic.Active, this.Active);
83
- this.debugLog(`Other: ${this.accessory.displayName} updateCharacteristic Active: ${this.Active}`);
84
- }
85
74
  }
86
75
 
87
76
  /**
88
77
  * Pushes the requested changes to the SwitchBot API
89
78
  * deviceType commandType Command command parameter Description
90
- * Light: "command" "turnOff" "default" = set to OFF state
91
- * Light: "command" "turnOn" "default" = set to ON state
92
- * Light: "command" "volumeAdd" "default" = volume up
93
- * Light: "command" "volumeSub" "default" = volume down
94
- * Light: "command" "channelAdd" "default" = next channel
95
- * Light: "command" "channelSub" "default" = previous channel
79
+ * Other - "command" "turnOff" "default" = set to OFF state
80
+ * Other - "command" "turnOn" "default" = set to ON state
81
+ * Other - "command" "volumeAdd" "default" = volume up
82
+ * Other - "command" "volumeSub" "default" = volume down
83
+ * Other - "command" "channelAdd" "default" = next channel
84
+ * Other - "command" "channelSub" "default" = previous channel
96
85
  */
97
86
  async pushOnChanges(): Promise<void> {
98
87
  if (this.platform.config.options) {
99
88
  if (this.device.other) {
100
89
  if (this.device.other.commandOn) {
101
90
  if (!this.Active) {
102
- const body = JSON.stringify({
91
+ const body = superStringify({
103
92
  'command': `${this.device.other.commandOn}`,
104
93
  'parameter': 'default',
105
94
  'commandType': 'customize',
@@ -107,13 +96,13 @@ export class Others {
107
96
  await this.pushChanges(body);
108
97
  }
109
98
  } else {
110
- this.errorLog(`Other: ${this.accessory.displayName} On Command not set, commandOn: ${this.device.other.commandOn}`);
99
+ this.errorLog(`${this.device.remoteType}: ${this.accessory.displayName} On Command not set, commandOn: ${this.device.other.commandOn}`);
111
100
  }
112
101
  } else {
113
- this.errorLog(`Other: ${this.accessory.displayName} On Command not set, other: ${this.device.other}`);
102
+ this.errorLog(`${this.device.remoteType}: ${this.accessory.displayName} On Command not set, other: ${this.device.other}`);
114
103
  }
115
104
  } else {
116
- this.errorLog(`Other: ${this.accessory.displayName} On Command not set`);
105
+ this.errorLog(`${this.device.remoteType}: ${this.accessory.displayName} On Command not set`);
117
106
  }
118
107
  }
119
108
 
@@ -122,7 +111,7 @@ export class Others {
122
111
  if (this.device.other) {
123
112
  if (this.device.other.commandOff) {
124
113
  if (this.Active) {
125
- const body = JSON.stringify({
114
+ const body = superStringify({
126
115
  'command': `${this.device.other.commandOff}`,
127
116
  'parameter': 'default',
128
117
  'commandType': 'customize',
@@ -130,95 +119,106 @@ export class Others {
130
119
  await this.pushChanges(body);
131
120
  }
132
121
  } else {
133
- this.errorLog(`Other: ${this.accessory.displayName} Off Command not set, commandOff: ${this.device.other.commandOff}`);
122
+ this.errorLog(`${this.device.remoteType}: ${this.accessory.displayName} Off Command not set, commandOff: ${this.device.other.commandOff}`);
134
123
  }
135
124
  } else {
136
- this.errorLog(`Other: ${this.accessory.displayName} Off Command not set, other: ${this.device.other}`);
125
+ this.errorLog(`${this.device.remoteType}: ${this.accessory.displayName} Off Command not set, other: ${this.device.other}`);
137
126
  }
138
127
  } else {
139
- this.errorLog(`Other: ${this.accessory.displayName} Off Command not set.`);
128
+ this.errorLog(`${this.device.remoteType}: ${this.accessory.displayName} Off Command not set.`);
140
129
  }
141
130
  }
142
131
 
143
132
  async pushChanges(body): Promise<void> {
144
- try {
133
+ if (this.device.connectionType === 'OpenAPI') {
134
+ try {
145
135
  // Make Push On request to the API
146
- const t = Date.now();
147
- const nonce = 'requestID';
148
- const data = this.platform.config.credentials?.token + t + nonce;
149
- const signTerm = crypto.createHmac('sha256', this.platform.config.credentials?.secret)
150
- .update(Buffer.from(data, 'utf-8'))
151
- .digest();
152
- const sign = signTerm.toString('base64');
153
- this.debugLog(`Other: ${this.accessory.displayName} sign: ${sign}`);
154
- this.infoLog(`Other: ${this.accessory.displayName} Sending request to SwitchBot API. body: ${body},`);
155
- const options = {
156
- hostname: HostDomain,
157
- port: 443,
158
- path: `${DevicePath}/${this.device.deviceId}/commands`,
159
- method: 'POST',
160
- headers: {
161
- 'Authorization': this.platform.config.credentials?.token,
162
- 'sign': sign,
163
- 'nonce': nonce,
164
- 't': t,
165
- 'Content-Type': 'application/json',
166
- 'Content-Length': body.length,
167
- },
168
- };
169
- const req = https.request(options, res => {
170
- this.debugLog(`Other: ${this.accessory.displayName} statusCode: ${res.statusCode}`);
171
- this.statusCode({ res });
172
- res.on('data', d => {
173
- this.debugLog(`Other: ${this.accessory.displayName} d: ${d}`);
136
+ const t = Date.now();
137
+ const nonce = 'requestID';
138
+ const data = this.platform.config.credentials?.token + t + nonce;
139
+ const signTerm = crypto.createHmac('sha256', this.platform.config.credentials?.secret)
140
+ .update(Buffer.from(data, 'utf-8'))
141
+ .digest();
142
+ const sign = signTerm.toString('base64');
143
+ this.debugLog(`${this.device.remoteType}: ${this.accessory.displayName} sign: ${sign}`);
144
+ this.infoLog(`${this.device.remoteType}: ${this.accessory.displayName} Sending request to SwitchBot API. body: ${body},`);
145
+ const options = {
146
+ hostname: HostDomain,
147
+ port: 443,
148
+ path: `${DevicePath}/${this.device.deviceId}/commands`,
149
+ method: 'POST',
150
+ headers: {
151
+ 'Authorization': this.platform.config.credentials?.token,
152
+ 'sign': sign,
153
+ 'nonce': nonce,
154
+ 't': t,
155
+ 'Content-Type': 'application/json',
156
+ 'Content-Length': body.length,
157
+ },
158
+ };
159
+ const req = https.request(options, res => {
160
+ this.debugLog(`${this.device.remoteType}: ${this.accessory.displayName} pushchanges statusCode: ${res.statusCode}`);
161
+ this.statusCode({ res });
162
+ res.on('data', d => {
163
+ this.debugLog(`${this.device.remoteType}: ${this.accessory.displayName} d: ${d}`);
164
+ });
174
165
  });
175
- });
176
- req.on('error', (e: any) => {
177
- this.errorLog(`Other: ${this.accessory.displayName} error message: ${e.message}`);
178
- });
179
- req.write(body);
180
- req.end();
181
- this.debugLog(`Other: ${this.accessory.displayName} pushchanges: ${JSON.stringify(req)}`);
182
- this.updateHomeKitCharacteristics();
183
- } catch (e: any) {
184
- this.errorLog(`Other: ${this.accessory.displayName} failed pushChanges with OpenAPI Connection`);
185
- if (this.deviceLogging.includes('debug')) {
186
- this.errorLog(
187
- `Other: ${this.accessory.displayName} failed pushChanges with OpenAPI Connection,` + ` Error Message: ${JSON.stringify(e.message)}`,
166
+ req.on('error', (e: any) => {
167
+ this.errorLog(`${this.device.remoteType}: ${this.accessory.displayName} error message: ${e.message}`);
168
+ });
169
+ req.write(body);
170
+ req.end();
171
+ this.debugLog(`${this.device.remoteType}: ${this.accessory.displayName} pushchanges: ${superStringify(req)}`);
172
+ this.updateHomeKitCharacteristics();
173
+ } catch (e: any) {
174
+ this.apiError(e);
175
+ this.errorLog(`${this.device.remoteType}: ${this.accessory.displayName} failed pushChanges with ${this.device.connectionType} Connection,`
176
+ + ` Error Message: ${superStringify(e.message)}`,
188
177
  );
189
178
  }
190
- this.apiError(e);
179
+ } else {
180
+ this.warnLog(`${this.device.remoteType}: ${this.accessory.displayName}`
181
+ + ` Connection Type: ${this.device.connectionType}, commands will not be sent to OpenAPI`);
182
+ }
183
+ }
184
+
185
+ async updateHomeKitCharacteristics(): Promise<void> {
186
+ if (this.Active === undefined) {
187
+ this.debugLog(`${this.device.remoteType}: ${this.accessory.displayName} Active: ${this.Active}`);
188
+ } else {
189
+ this.fanService?.updateCharacteristic(this.platform.Characteristic.Active, this.Active);
190
+ this.debugLog(`${this.device.remoteType}: ${this.accessory.displayName} updateCharacteristic Active: ${this.Active}`);
191
191
  }
192
192
  }
193
193
 
194
194
  async statusCode({ res }: { res: IncomingMessage }): Promise<void> {
195
195
  switch (res.statusCode) {
196
196
  case 151:
197
- this.errorLog(`Other: ${this.accessory.displayName} Command not supported by this device type.`);
197
+ this.errorLog(`${this.device.remoteType}: ${this.accessory.displayName} Command not supported by this device type.`);
198
198
  break;
199
199
  case 152:
200
- this.errorLog(`Other: ${this.accessory.displayName} Device not found.`);
200
+ this.errorLog(`${this.device.remoteType}: ${this.accessory.displayName} Device not found.`);
201
201
  break;
202
202
  case 160:
203
- this.errorLog(`Other: ${this.accessory.displayName} Command is not supported.`);
203
+ this.errorLog(`${this.device.remoteType}: ${this.accessory.displayName} Command is not supported.`);
204
204
  break;
205
205
  case 161:
206
- this.errorLog(`Other: ${this.accessory.displayName} Device is offline.`);
206
+ this.errorLog(`${this.device.remoteType}: ${this.accessory.displayName} Device is offline.`);
207
207
  break;
208
208
  case 171:
209
- this.errorLog(`Other: ${this.accessory.displayName} Hub Device is offline. Hub: ${this.device.hubDeviceId}`);
209
+ this.errorLog(`${this.device.remoteType}: ${this.accessory.displayName} Hub Device is offline. Hub: ${this.device.hubDeviceId}`);
210
210
  break;
211
211
  case 190:
212
212
  this.errorLog(
213
- `Other: ${this.accessory.displayName} Device internal error due to device states not synchronized` +
214
- ` with server, Or command: ${JSON.stringify(res)} format is invalid`,
213
+ `${this.device.remoteType}: ${this.accessory.displayName} Device internal error due to device states not synchronized` +
214
+ ` with server, Or command: ${superStringify(res)} format is invalid`,
215
215
  );
216
216
  break;
217
217
  case 100:
218
- this.debugLog(`Other: ${this.accessory.displayName} Command successfully sent.`);
218
+ this.debugLog(`${this.device.remoteType}: ${this.accessory.displayName} Command successfully sent.`);
219
219
  break;
220
220
  default:
221
- this.debugLog(`Other: ${this.accessory.displayName} Unknown statusCode.`);
221
+ this.debugLog(`${this.device.remoteType}: ${this.accessory.displayName} Unknown statusCode.`);
222
222
  }
223
223
  }
224
224
 
@@ -231,10 +231,34 @@ export class Others {
231
231
  if (device.other?.deviceType) {
232
232
  this.otherDeviceType = this.accessory.context.deviceType = device.other.deviceType;
233
233
  if (this.deviceLogging.includes('debug') || this.deviceLogging === 'standard') {
234
- this.warnLog(`Other: ${this.accessory.displayName} Using Device Type: ${this.otherDeviceType}`);
234
+ this.warnLog(`${this.device.remoteType}: ${this.accessory.displayName} Using Device Type: ${this.otherDeviceType}`);
235
235
  }
236
236
  } else {
237
- this.errorLog(`Other: ${this.accessory.displayName} No Device Type Set, deviceType: ${this.device.other?.deviceType}`);
237
+ this.errorLog(`${this.device.remoteType}: ${this.accessory.displayName} No Device Type Set, deviceType: ${this.device.other?.deviceType}`);
238
+ }
239
+ }
240
+
241
+ FirmwareRevision(accessory: PlatformAccessory, device: irdevice & irDevicesConfig): string {
242
+ let FirmwareRevision: string;
243
+ this.debugLog(`${this.device.remoteType}: ${this.accessory.displayName}`
244
+ + ` accessory.context.FirmwareRevision: ${accessory.context.FirmwareRevision}`);
245
+ this.debugLog(`${this.device.remoteType}: ${this.accessory.displayName} device.firmware: ${device.firmware}`);
246
+ this.debugLog(`${this.device.remoteType}: ${this.accessory.displayName} this.platform.version: ${this.platform.version}`);
247
+ if (accessory.context.FirmwareRevision) {
248
+ FirmwareRevision = accessory.context.FirmwareRevision;
249
+ } else if (device.firmware) {
250
+ FirmwareRevision = device.firmware;
251
+ } else {
252
+ FirmwareRevision = this.platform.version;
253
+ }
254
+ return FirmwareRevision;
255
+ }
256
+
257
+ async context() {
258
+ if (this.Active === undefined) {
259
+ this.Active = this.platform.Characteristic.Active.INACTIVE;
260
+ } else {
261
+ this.Active = this.accessory.context.Active;
238
262
  }
239
263
  }
240
264
 
@@ -246,24 +270,27 @@ export class Others {
246
270
  if (device.logging !== undefined) {
247
271
  config['logging'] = device.logging;
248
272
  }
273
+ if (device.connectionType !== undefined) {
274
+ config['connectionType'] = device.connectionType;
275
+ }
249
276
  if (Object.entries(config).length !== 0) {
250
- this.infoLog(`Other: ${this.accessory.displayName} Config: ${JSON.stringify(config)}`);
277
+ this.infoLog(`${this.device.remoteType}: ${this.accessory.displayName} Config: ${superStringify(config)}`);
251
278
  }
252
279
  }
253
280
 
254
281
  async logs(device: irdevice & irDevicesConfig): Promise<void> {
255
282
  if (this.platform.debugMode) {
256
283
  this.deviceLogging = this.accessory.context.logging = 'debugMode';
257
- this.debugLog(`Other: ${this.accessory.displayName} Using Debug Mode Logging: ${this.deviceLogging}`);
284
+ this.debugLog(`${this.device.remoteType}: ${this.accessory.displayName} Using Debug Mode Logging: ${this.deviceLogging}`);
258
285
  } else if (device.logging) {
259
286
  this.deviceLogging = this.accessory.context.logging = device.logging;
260
- this.debugLog(`Other: ${this.accessory.displayName} Using Device Config Logging: ${this.deviceLogging}`);
287
+ this.debugLog(`${this.device.remoteType}: ${this.accessory.displayName} Using Device Config Logging: ${this.deviceLogging}`);
261
288
  } else if (this.platform.config.options?.logging) {
262
289
  this.deviceLogging = this.accessory.context.logging = this.platform.config.options?.logging;
263
- this.debugLog(`Other: ${this.accessory.displayName} Using Platform Config Logging: ${this.deviceLogging}`);
290
+ this.debugLog(`${this.device.remoteType}: ${this.accessory.displayName} Using Platform Config Logging: ${this.deviceLogging}`);
264
291
  } else {
265
292
  this.deviceLogging = this.accessory.context.logging = 'standard';
266
- this.debugLog(`Other: ${this.accessory.displayName} Logging Not Set, Using: ${this.deviceLogging}`);
293
+ this.debugLog(`${this.device.remoteType}: ${this.accessory.displayName} Logging Not Set, Using: ${this.deviceLogging}`);
267
294
  }
268
295
  }
269
296
 
@@ -282,12 +309,28 @@ export class Others {
282
309
  }
283
310
  }
284
311
 
312
+ debugWarnLog(...log: any[]): void {
313
+ if (this.enablingDeviceLogging()) {
314
+ if (this.deviceLogging?.includes('debug')) {
315
+ this.platform.log.warn('[DEBUG]', String(...log));
316
+ }
317
+ }
318
+ }
319
+
285
320
  errorLog(...log: any[]): void {
286
321
  if (this.enablingDeviceLogging()) {
287
322
  this.platform.log.error(String(...log));
288
323
  }
289
324
  }
290
325
 
326
+ debugErrorLog(...log: any[]): void {
327
+ if (this.enablingDeviceLogging()) {
328
+ if (this.deviceLogging?.includes('debug')) {
329
+ this.platform.log.error('[DEBUG]', String(...log));
330
+ }
331
+ }
332
+ }
333
+
291
334
  debugLog(...log: any[]): void {
292
335
  if (this.enablingDeviceLogging()) {
293
336
  if (this.deviceLogging === 'debug') {