@switchbot/homebridge-switchbot 2.0.0-beta.19 → 2.0.0-beta.20

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 (112) hide show
  1. package/CHANGELOG.md +6 -1
  2. package/README.md +1 -2
  3. package/config.schema.json +51 -32
  4. package/dist/device/bot.d.ts +32 -29
  5. package/dist/device/bot.d.ts.map +1 -1
  6. package/dist/device/bot.js +549 -575
  7. package/dist/device/bot.js.map +1 -1
  8. package/dist/device/colorbulb.d.ts +33 -15
  9. package/dist/device/colorbulb.d.ts.map +1 -1
  10. package/dist/device/colorbulb.js +426 -341
  11. package/dist/device/colorbulb.js.map +1 -1
  12. package/dist/device/contact.d.ts +16 -9
  13. package/dist/device/contact.d.ts.map +1 -1
  14. package/dist/device/contact.js +246 -208
  15. package/dist/device/contact.js.map +1 -1
  16. package/dist/device/curtain.d.ts +21 -18
  17. package/dist/device/curtain.d.ts.map +1 -1
  18. package/dist/device/curtain.js +449 -449
  19. package/dist/device/curtain.js.map +1 -1
  20. package/dist/device/humidifier.d.ts +22 -20
  21. package/dist/device/humidifier.d.ts.map +1 -1
  22. package/dist/device/humidifier.js +346 -324
  23. package/dist/device/humidifier.js.map +1 -1
  24. package/dist/device/lock.d.ts +22 -10
  25. package/dist/device/lock.d.ts.map +1 -1
  26. package/dist/device/lock.js +257 -178
  27. package/dist/device/lock.js.map +1 -1
  28. package/dist/device/meter.d.ts +21 -14
  29. package/dist/device/meter.d.ts.map +1 -1
  30. package/dist/device/meter.js +287 -239
  31. package/dist/device/meter.js.map +1 -1
  32. package/dist/device/meterplus.d.ts +23 -10
  33. package/dist/device/meterplus.d.ts.map +1 -1
  34. package/dist/device/meterplus.js +308 -190
  35. package/dist/device/meterplus.js.map +1 -1
  36. package/dist/device/motion.d.ts +17 -10
  37. package/dist/device/motion.d.ts.map +1 -1
  38. package/dist/device/motion.js +225 -193
  39. package/dist/device/motion.js.map +1 -1
  40. package/dist/device/plug.d.ts +24 -17
  41. package/dist/device/plug.d.ts.map +1 -1
  42. package/dist/device/plug.js +270 -267
  43. package/dist/device/plug.js.map +1 -1
  44. package/dist/device/striplight.d.ts +36 -14
  45. package/dist/device/striplight.d.ts.map +1 -1
  46. package/dist/device/striplight.js +447 -299
  47. package/dist/device/striplight.js.map +1 -1
  48. package/dist/irdevice/airconditioner.d.ts +7 -14
  49. package/dist/irdevice/airconditioner.d.ts.map +1 -1
  50. package/dist/irdevice/airconditioner.js +177 -169
  51. package/dist/irdevice/airconditioner.js.map +1 -1
  52. package/dist/irdevice/airpurifier.d.ts +3 -5
  53. package/dist/irdevice/airpurifier.d.ts.map +1 -1
  54. package/dist/irdevice/airpurifier.js +72 -57
  55. package/dist/irdevice/airpurifier.js.map +1 -1
  56. package/dist/irdevice/camera.d.ts +3 -4
  57. package/dist/irdevice/camera.d.ts.map +1 -1
  58. package/dist/irdevice/camera.js +47 -33
  59. package/dist/irdevice/camera.js.map +1 -1
  60. package/dist/irdevice/fan.d.ts +3 -4
  61. package/dist/irdevice/fan.d.ts.map +1 -1
  62. package/dist/irdevice/fan.js +66 -48
  63. package/dist/irdevice/fan.js.map +1 -1
  64. package/dist/irdevice/light.d.ts +3 -4
  65. package/dist/irdevice/light.d.ts.map +1 -1
  66. package/dist/irdevice/light.js +48 -47
  67. package/dist/irdevice/light.js.map +1 -1
  68. package/dist/irdevice/other.d.ts +3 -4
  69. package/dist/irdevice/other.d.ts.map +1 -1
  70. package/dist/irdevice/other.js +47 -33
  71. package/dist/irdevice/other.js.map +1 -1
  72. package/dist/irdevice/tv.d.ts +10 -11
  73. package/dist/irdevice/tv.d.ts.map +1 -1
  74. package/dist/irdevice/tv.js +64 -48
  75. package/dist/irdevice/tv.js.map +1 -1
  76. package/dist/irdevice/vacuumcleaner.d.ts +7 -12
  77. package/dist/irdevice/vacuumcleaner.d.ts.map +1 -1
  78. package/dist/irdevice/vacuumcleaner.js +52 -41
  79. package/dist/irdevice/vacuumcleaner.js.map +1 -1
  80. package/dist/irdevice/waterheater.d.ts +6 -11
  81. package/dist/irdevice/waterheater.d.ts.map +1 -1
  82. package/dist/irdevice/waterheater.js +52 -42
  83. package/dist/irdevice/waterheater.js.map +1 -1
  84. package/dist/platform.d.ts +0 -4
  85. package/dist/platform.d.ts.map +1 -1
  86. package/dist/platform.js +44 -66
  87. package/dist/platform.js.map +1 -1
  88. package/dist/settings.d.ts +3 -3
  89. package/dist/settings.d.ts.map +1 -1
  90. package/package.json +7 -6
  91. package/src/device/bot.ts +551 -589
  92. package/src/device/colorbulb.ts +441 -375
  93. package/src/device/contact.ts +249 -213
  94. package/src/device/curtain.ts +452 -461
  95. package/src/device/humidifier.ts +358 -365
  96. package/src/device/lock.ts +263 -179
  97. package/src/device/meter.ts +302 -253
  98. package/src/device/meterplus.ts +319 -194
  99. package/src/device/motion.ts +230 -199
  100. package/src/device/plug.ts +273 -274
  101. package/src/device/striplight.ts +460 -316
  102. package/src/irdevice/airconditioner.ts +181 -183
  103. package/src/irdevice/airpurifier.ts +70 -60
  104. package/src/irdevice/camera.ts +46 -36
  105. package/src/irdevice/fan.ts +64 -49
  106. package/src/irdevice/light.ts +47 -51
  107. package/src/irdevice/other.ts +46 -36
  108. package/src/irdevice/tv.ts +64 -51
  109. package/src/irdevice/vacuumcleaner.ts +52 -45
  110. package/src/irdevice/waterheater.ts +50 -45
  111. package/src/platform.ts +44 -68
  112. package/src/settings.ts +3 -3
@@ -17,33 +17,30 @@ export class VacuumCleaner {
17
17
 
18
18
  // Characteristic Values
19
19
  On!: CharacteristicValue;
20
- OnCached!: CharacteristicValue;
21
20
 
22
21
  // Config
23
22
  deviceLogging!: string;
24
- OpenAPI?: boolean;
25
23
 
26
24
  constructor(private readonly platform: SwitchBotPlatform, private accessory: PlatformAccessory, public device: irdevice & irDevicesConfig) {
27
25
  // default placeholders
28
26
  this.logs(device);
29
27
  this.config(device);
30
- if (this.On === undefined) {
31
- this.On = false;
32
- } else {
33
- this.On = this.accessory.context.On;
34
- }
28
+ this.context();
35
29
 
36
30
  // set accessory information
37
31
  accessory
38
32
  .getService(this.platform.Service.AccessoryInformation)!
39
33
  .setCharacteristic(this.platform.Characteristic.Manufacturer, 'SwitchBot')
40
34
  .setCharacteristic(this.platform.Characteristic.Model, device.remoteType)
41
- .setCharacteristic(this.platform.Characteristic.SerialNumber, device.deviceId!);
35
+ .setCharacteristic(this.platform.Characteristic.SerialNumber, device.deviceId!)
36
+ .setCharacteristic(this.platform.Characteristic.FirmwareRevision, this.FirmwareRevision(accessory, device))
37
+ .getCharacteristic(this.platform.Characteristic.FirmwareRevision)
38
+ .updateValue(this.FirmwareRevision(accessory, device));
42
39
 
43
40
  // get the Television service if it exists, otherwise create a new Television service
44
41
  // you can create multiple services for each accessory
45
42
  (this.switchService = accessory.getService(this.platform.Service.Switch) || accessory.addService(this.platform.Service.Switch)),
46
- `${accessory.displayName} Vacuum`;
43
+ `${accessory.displayName} ${device.remoteType}`;
47
44
 
48
45
  // To avoid "Cannot add a Service with the same UUID another Service without also defining a unique 'subtype' property." error,
49
46
  // when creating multiple services of the same type, you need to use the following syntax to specify a name and subtype id:
@@ -60,6 +57,7 @@ export class VacuumCleaner {
60
57
  async OnSet(value: CharacteristicValue): Promise<void> {
61
58
  this.debugLog(`${this.device.remoteType}: ${this.accessory.displayName} On: ${value}`);
62
59
  this.On = value;
60
+ this.accessory.context.On = this.On;
63
61
  if (this.On) {
64
62
  await this.pushOnChanges();
65
63
  } else {
@@ -67,24 +65,11 @@ export class VacuumCleaner {
67
65
  }
68
66
  }
69
67
 
70
- async updateHomeKitCharacteristics(): Promise<void> {
71
- if (this.On === undefined) {
72
- this.debugLog(`${this.device.remoteType}: ${this.accessory.displayName} On: ${this.On}`);
73
- } else {
74
- this.switchService?.updateCharacteristic(this.platform.Characteristic.On, this.On);
75
- this.debugLog(`${this.device.remoteType}: ${this.accessory.displayName} updateCharacteristic On: ${this.On}`);
76
- }
77
- }
78
-
79
68
  /**
80
69
  * Pushes the requested changes to the SwitchBot API
81
- * deviceType commandType Command command parameter Description
82
- * Vacuum Cleaner - "command" "turnOff" "default" = set to OFF state
83
- * Vacuum Cleaner - "command" "turnOn" "default" = set to ON state
84
- * Vacuum Cleaner - "command" "volumeAdd" "default" = volume up
85
- * Vacuum Cleaner - "command" "volumeSub" "default" = volume down
86
- * Vacuum Cleaner - "command" "channelAdd" "default" = next channel
87
- * Vacuum Cleaner - "command" "channelSub" "default" = previous channel
70
+ * deviceType CommandType Command Parameter Description
71
+ * Vacuum Cleaner "command" "turnOff" "default" set to OFF state
72
+ * Vacuum Cleaner "command" "turnOn" "default" set to ON state
88
73
  */
89
74
  async pushOnChanges(): Promise<void> {
90
75
  if (this.On) {
@@ -108,8 +93,8 @@ export class VacuumCleaner {
108
93
  }
109
94
  }
110
95
 
111
- async pushChanges(body): Promise<void> {
112
- if (this.OpenAPI) {
96
+ async pushChanges(body: any[]): Promise<void> {
97
+ if (this.device.connectionType === 'OpenAPI') {
113
98
  try {
114
99
  // Make Push On request to the API
115
100
  const t = Date.now();
@@ -136,7 +121,7 @@ export class VacuumCleaner {
136
121
  },
137
122
  };
138
123
  const req = https.request(options, res => {
139
- this.debugLog(`${this.device.remoteType}: ${this.accessory.displayName} statusCode: ${res.statusCode}`);
124
+ this.debugLog(`${this.device.remoteType}: ${this.accessory.displayName} pushchanges statusCode: ${res.statusCode}`);
140
125
  this.statusCode({ res });
141
126
  res.on('data', d => {
142
127
  this.debugLog(`${this.device.remoteType}: ${this.accessory.displayName} d: ${d}`);
@@ -148,19 +133,27 @@ export class VacuumCleaner {
148
133
  req.write(body);
149
134
  req.end();
150
135
  this.debugLog(`${this.device.remoteType}: ${this.accessory.displayName} pushchanges: ${superStringify(req)}`);
151
- this.OnCached = this.On;
152
- this.accessory.context.On = this.OnCached;
136
+ this.accessory.context.On = this.On;
153
137
  this.updateHomeKitCharacteristics();
154
138
  } catch (e: any) {
155
- this.errorLog(`${this.device.remoteType}: ${this.accessory.displayName} failed pushChanges with OpenAPI Connection`);
156
- if (this.deviceLogging.includes('debug')) {
157
- this.errorLog(
158
- `${this.device.remoteType}: ${this.accessory.displayName} failed pushChanges with OpenAPI Connection,` +
159
- ` Error Message: ${superStringify(e.message)}`,
160
- );
161
- }
162
139
  this.apiError(e);
140
+ this.errorLog(`${this.device.remoteType}: ${this.accessory.displayName} failed pushChanges with ${this.device.connectionType} Connection,`
141
+ + ` Error Message: ${superStringify(e.message)}`,
142
+ );
163
143
  }
144
+ } else {
145
+ this.warnLog(`${this.device.remoteType}: ${this.accessory.displayName}`
146
+ + ` Connection Type: ${this.device.connectionType}, commands will not be sent to OpenAPI`);
147
+ }
148
+ }
149
+
150
+ async updateHomeKitCharacteristics(): Promise<void> {
151
+ if (this.On === undefined) {
152
+ this.debugLog(`${this.device.remoteType}: ${this.accessory.displayName} On: ${this.On}`);
153
+ } else {
154
+ this.accessory.context.On = this.On;
155
+ this.switchService?.updateCharacteristic(this.platform.Characteristic.On, this.On);
156
+ this.debugLog(`${this.device.remoteType}: ${this.accessory.displayName} updateCharacteristic On: ${this.On}`);
164
157
  }
165
158
  }
166
159
 
@@ -197,16 +190,30 @@ export class VacuumCleaner {
197
190
 
198
191
  async apiError(e: any): Promise<void> {
199
192
  this.switchService.updateCharacteristic(this.platform.Characteristic.On, e);
200
- //throw new this.platform.api.hap.HapStatusError(HAPStatus.SERVICE_COMMUNICATION_FAILURE);
201
193
  }
202
194
 
203
- async openAPI() {
204
- if (!this.device.openAPI) {
205
- this.OpenAPI = true;
195
+ FirmwareRevision(accessory: PlatformAccessory, device: irdevice & irDevicesConfig): string {
196
+ let FirmwareRevision: string;
197
+ this.debugLog(`${this.device.remoteType}: ${this.accessory.displayName}`
198
+ + ` accessory.context.FirmwareRevision: ${accessory.context.FirmwareRevision}`);
199
+ this.debugLog(`${this.device.remoteType}: ${this.accessory.displayName} device.firmware: ${device.firmware}`);
200
+ this.debugLog(`${this.device.remoteType}: ${this.accessory.displayName} this.platform.version: ${this.platform.version}`);
201
+ if (accessory.context.FirmwareRevision) {
202
+ FirmwareRevision = accessory.context.FirmwareRevision;
203
+ } else if (device.firmware) {
204
+ FirmwareRevision = device.firmware;
205
+ } else {
206
+ FirmwareRevision = this.platform.version;
207
+ }
208
+ return FirmwareRevision;
209
+ }
210
+
211
+ async context() {
212
+ if (this.On === undefined) {
213
+ this.On = false;
206
214
  } else {
207
- this.OpenAPI = this.device.openAPI;
215
+ this.On = this.accessory.context.On;
208
216
  }
209
- this.debugLog(`${this.device.remoteType}: ${this.accessory.displayName} Using OpenAPI: ${this.OpenAPI}`);
210
217
  }
211
218
 
212
219
  async config(device: irdevice & irDevicesConfig): Promise<void> {
@@ -217,8 +224,8 @@ export class VacuumCleaner {
217
224
  if (device.logging !== undefined) {
218
225
  config['logging'] = device.logging;
219
226
  }
220
- if (device.openAPI !== undefined) {
221
- config['openAPI'] = device.openAPI;
227
+ if (device.connectionType !== undefined) {
228
+ config['connectionType'] = device.connectionType;
222
229
  }
223
230
  if (Object.entries(config).length !== 0) {
224
231
  this.infoLog(`${this.device.remoteType}: ${this.accessory.displayName} Config: ${superStringify(config)}`);
@@ -17,33 +17,30 @@ export class WaterHeater {
17
17
 
18
18
  // Characteristic Values
19
19
  Active!: CharacteristicValue;
20
- ActiveCached!: CharacteristicValue;
21
20
 
22
21
  // Config
23
22
  deviceLogging!: string;
24
- OpenAPI?: boolean;
25
23
 
26
24
  constructor(private readonly platform: SwitchBotPlatform, private accessory: PlatformAccessory, public device: irdevice & irDevicesConfig) {
27
25
  // default placeholders
28
26
  this.logs(device);
29
27
  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
- }
28
+ this.context();
35
29
 
36
30
  // set accessory information
37
31
  accessory
38
32
  .getService(this.platform.Service.AccessoryInformation)!
39
33
  .setCharacteristic(this.platform.Characteristic.Manufacturer, 'SwitchBot')
40
34
  .setCharacteristic(this.platform.Characteristic.Model, device.remoteType)
41
- .setCharacteristic(this.platform.Characteristic.SerialNumber, device.deviceId!);
35
+ .setCharacteristic(this.platform.Characteristic.SerialNumber, device.deviceId!)
36
+ .setCharacteristic(this.platform.Characteristic.FirmwareRevision, this.FirmwareRevision(accessory, device))
37
+ .getCharacteristic(this.platform.Characteristic.FirmwareRevision)
38
+ .updateValue(this.FirmwareRevision(accessory, device));
42
39
 
43
40
  // get the Television service if it exists, otherwise create a new Television service
44
41
  // you can create multiple services for each accessory
45
42
  (this.valveService = accessory.getService(this.platform.Service.Valve) || accessory.addService(this.platform.Service.Valve)),
46
- `${accessory.displayName} Water Heater`;
43
+ `${accessory.displayName} ${device.remoteType}`;
47
44
 
48
45
  // To avoid "Cannot add a Service with the same UUID another Service without also defining a unique 'subtype' property." error,
49
46
  // when creating multiple services of the same type, you need to use the following syntax to specify a name and subtype id:
@@ -62,6 +59,8 @@ export class WaterHeater {
62
59
 
63
60
  async ActiveSet(value: CharacteristicValue): Promise<void> {
64
61
  this.debugLog(`${this.device.remoteType}: ${this.accessory.displayName} Active: ${value}`);
62
+ this.Active = value;
63
+ this.accessory.context.Active = this.Active;
65
64
  if (value === this.platform.Characteristic.Active.INACTIVE) {
66
65
  await this.pushWaterHeaterOffChanges();
67
66
  this.valveService.setCharacteristic(this.platform.Characteristic.InUse, this.platform.Characteristic.InUse.NOT_IN_USE);
@@ -69,29 +68,13 @@ export class WaterHeater {
69
68
  await this.pushWaterHeaterOnChanges();
70
69
  this.valveService.setCharacteristic(this.platform.Characteristic.InUse, this.platform.Characteristic.InUse.IN_USE);
71
70
  }
72
- this.Active = value;
73
- this.ActiveCached = this.Active;
74
- this.accessory.context.Active = this.ActiveCached;
75
- }
76
-
77
- async updateHomeKitCharacteristics(): Promise<void> {
78
- if (this.Active === undefined) {
79
- this.debugLog(`${this.device.remoteType}: ${this.accessory.displayName} Active: ${this.Active}`);
80
- } else {
81
- this.valveService?.updateCharacteristic(this.platform.Characteristic.Active, this.Active);
82
- this.debugLog(`${this.device.remoteType}: ${this.accessory.displayName} updateCharacteristic Active: ${this.Active}`);
83
- }
84
71
  }
85
72
 
86
73
  /**
87
74
  * Pushes the requested changes to the SwitchBot API
88
- * deviceType commandType Command command parameter Description
89
- * WaterHeater: "command" "turnOff" "default" = set to OFF state
90
- * WaterHeater: "command" "turnOn" "default" = set to ON state
91
- * WaterHeater: "command" "volumeAdd" "default" = volume up
92
- * WaterHeater: "command" "volumeSub" "default" = volume down
93
- * WaterHeater: "command" "channelAdd" "default" = next channel
94
- * WaterHeater: "command" "channelSub" "default" = previous channel
75
+ * deviceType Command Type Command Parameter Description
76
+ * WaterHeater "command" "turnOff" "default" set to OFF state
77
+ * WaterHeater "command" "turnOn" "default" set to ON state
95
78
  */
96
79
  async pushWaterHeaterOnChanges(): Promise<void> {
97
80
  if (this.Active !== 1) {
@@ -116,7 +99,7 @@ export class WaterHeater {
116
99
  }
117
100
 
118
101
  async pushChanges(body): Promise<void> {
119
- if (this.OpenAPI) {
102
+ if (this.device.connectionType === 'OpenAPI') {
120
103
  try {
121
104
  // Make Push On request to the API
122
105
  const t = Date.now();
@@ -143,7 +126,7 @@ export class WaterHeater {
143
126
  },
144
127
  };
145
128
  const req = https.request(options, res => {
146
- this.debugLog(`${this.device.remoteType}: ${this.accessory.displayName} statusCode: ${res.statusCode}`);
129
+ this.debugLog(`${this.device.remoteType}: ${this.accessory.displayName} pushchanges statusCode: ${res.statusCode}`);
147
130
  this.statusCode({ res });
148
131
  res.on('data', d => {
149
132
  this.debugLog(`${this.device.remoteType}: ${this.accessory.displayName} d: ${d}`);
@@ -157,15 +140,23 @@ export class WaterHeater {
157
140
  this.debugLog(`${this.device.remoteType}: ${this.accessory.displayName} pushchanges: ${superStringify(req)}`);
158
141
  this.updateHomeKitCharacteristics();
159
142
  } catch (e: any) {
160
- this.errorLog(`${this.device.remoteType}: ${this.accessory.displayName} failed pushChanges with OpenAPI Connection`);
161
- if (this.deviceLogging.includes('debug')) {
162
- this.errorLog(
163
- `${this.device.remoteType}: ${this.accessory.displayName} failed pushChanges with OpenAPI Connection,`
164
- + ` Error Message: ${superStringify(e.message)}`,
165
- );
166
- }
167
143
  this.apiError(e);
144
+ this.errorLog(`${this.device.remoteType}: ${this.accessory.displayName} failed pushChanges with ${this.device.connectionType} Connection,`
145
+ + ` Error Message: ${superStringify(e.message)}`);
168
146
  }
147
+ } else {
148
+ this.warnLog(`${this.device.remoteType}: ${this.accessory.displayName}`
149
+ + ` Connection Type: ${this.device.connectionType}, commands will not be sent to OpenAPI`);
150
+ }
151
+ }
152
+
153
+ async updateHomeKitCharacteristics(): Promise<void> {
154
+ if (this.Active === undefined) {
155
+ this.debugLog(`${this.device.remoteType}: ${this.accessory.displayName} Active: ${this.Active}`);
156
+ } else {
157
+ this.accessory.context.Active = this.Active;
158
+ this.valveService?.updateCharacteristic(this.platform.Characteristic.Active, this.Active);
159
+ this.debugLog(`${this.device.remoteType}: ${this.accessory.displayName} updateCharacteristic Active: ${this.Active}`);
169
160
  }
170
161
  }
171
162
 
@@ -202,16 +193,30 @@ export class WaterHeater {
202
193
 
203
194
  async apiError(e: any): Promise<void> {
204
195
  this.valveService.updateCharacteristic(this.platform.Characteristic.Active, e);
205
- //throw new this.platform.api.hap.HapStatusError(HAPStatus.SERVICE_COMMUNICATION_FAILURE);
206
196
  }
207
197
 
208
- async openAPI() {
209
- if (!this.device.openAPI) {
210
- this.OpenAPI = true;
198
+ FirmwareRevision(accessory: PlatformAccessory, device: irdevice & irDevicesConfig): string {
199
+ let FirmwareRevision: string;
200
+ this.debugLog(`${this.device.remoteType}: ${this.accessory.displayName}`
201
+ + ` accessory.context.FirmwareRevision: ${accessory.context.FirmwareRevision}`);
202
+ this.debugLog(`${this.device.remoteType}: ${this.accessory.displayName} device.firmware: ${device.firmware}`);
203
+ this.debugLog(`${this.device.remoteType}: ${this.accessory.displayName} this.platform.version: ${this.platform.version}`);
204
+ if (accessory.context.FirmwareRevision) {
205
+ FirmwareRevision = accessory.context.FirmwareRevision;
206
+ } else if (device.firmware) {
207
+ FirmwareRevision = device.firmware;
208
+ } else {
209
+ FirmwareRevision = this.platform.version;
210
+ }
211
+ return FirmwareRevision;
212
+ }
213
+
214
+ async context() {
215
+ if (this.Active === undefined) {
216
+ this.Active = this.platform.Characteristic.Active.INACTIVE;
211
217
  } else {
212
- this.OpenAPI = this.device.openAPI;
218
+ this.Active = this.accessory.context.Active;
213
219
  }
214
- this.debugLog(`${this.device.remoteType}: ${this.accessory.displayName} Using OpenAPI: ${this.OpenAPI}`);
215
220
  }
216
221
 
217
222
  async config(device: irdevice & irDevicesConfig): Promise<void> {
@@ -222,8 +227,8 @@ export class WaterHeater {
222
227
  if (device.logging !== undefined) {
223
228
  config['logging'] = device.logging;
224
229
  }
225
- if (device.openAPI !== undefined) {
226
- config['openAPI'] = device.openAPI;
230
+ if (device.connectionType !== undefined) {
231
+ config['connectionType'] = device.connectionType;
227
232
  }
228
233
  if (Object.entries(config).length !== 0) {
229
234
  this.infoLog(`${this.device.remoteType}: ${this.accessory.displayName} Config: ${superStringify(config)}`);