@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.
- package/CHANGELOG.md +6 -1
- package/README.md +1 -2
- package/config.schema.json +51 -32
- package/dist/device/bot.d.ts +32 -29
- package/dist/device/bot.d.ts.map +1 -1
- package/dist/device/bot.js +549 -575
- package/dist/device/bot.js.map +1 -1
- package/dist/device/colorbulb.d.ts +33 -15
- package/dist/device/colorbulb.d.ts.map +1 -1
- package/dist/device/colorbulb.js +426 -341
- package/dist/device/colorbulb.js.map +1 -1
- package/dist/device/contact.d.ts +16 -9
- package/dist/device/contact.d.ts.map +1 -1
- package/dist/device/contact.js +246 -208
- package/dist/device/contact.js.map +1 -1
- package/dist/device/curtain.d.ts +21 -18
- package/dist/device/curtain.d.ts.map +1 -1
- package/dist/device/curtain.js +449 -449
- package/dist/device/curtain.js.map +1 -1
- package/dist/device/humidifier.d.ts +22 -20
- package/dist/device/humidifier.d.ts.map +1 -1
- package/dist/device/humidifier.js +346 -324
- package/dist/device/humidifier.js.map +1 -1
- package/dist/device/lock.d.ts +22 -10
- package/dist/device/lock.d.ts.map +1 -1
- package/dist/device/lock.js +257 -178
- package/dist/device/lock.js.map +1 -1
- package/dist/device/meter.d.ts +21 -14
- package/dist/device/meter.d.ts.map +1 -1
- package/dist/device/meter.js +287 -239
- package/dist/device/meter.js.map +1 -1
- package/dist/device/meterplus.d.ts +23 -10
- package/dist/device/meterplus.d.ts.map +1 -1
- package/dist/device/meterplus.js +308 -190
- package/dist/device/meterplus.js.map +1 -1
- package/dist/device/motion.d.ts +17 -10
- package/dist/device/motion.d.ts.map +1 -1
- package/dist/device/motion.js +225 -193
- package/dist/device/motion.js.map +1 -1
- package/dist/device/plug.d.ts +24 -17
- package/dist/device/plug.d.ts.map +1 -1
- package/dist/device/plug.js +270 -267
- package/dist/device/plug.js.map +1 -1
- package/dist/device/striplight.d.ts +36 -14
- package/dist/device/striplight.d.ts.map +1 -1
- package/dist/device/striplight.js +447 -299
- package/dist/device/striplight.js.map +1 -1
- package/dist/irdevice/airconditioner.d.ts +7 -14
- package/dist/irdevice/airconditioner.d.ts.map +1 -1
- package/dist/irdevice/airconditioner.js +177 -169
- package/dist/irdevice/airconditioner.js.map +1 -1
- package/dist/irdevice/airpurifier.d.ts +3 -5
- package/dist/irdevice/airpurifier.d.ts.map +1 -1
- package/dist/irdevice/airpurifier.js +72 -57
- package/dist/irdevice/airpurifier.js.map +1 -1
- package/dist/irdevice/camera.d.ts +3 -4
- package/dist/irdevice/camera.d.ts.map +1 -1
- package/dist/irdevice/camera.js +47 -33
- package/dist/irdevice/camera.js.map +1 -1
- package/dist/irdevice/fan.d.ts +3 -4
- package/dist/irdevice/fan.d.ts.map +1 -1
- package/dist/irdevice/fan.js +66 -48
- package/dist/irdevice/fan.js.map +1 -1
- package/dist/irdevice/light.d.ts +3 -4
- package/dist/irdevice/light.d.ts.map +1 -1
- package/dist/irdevice/light.js +48 -47
- package/dist/irdevice/light.js.map +1 -1
- package/dist/irdevice/other.d.ts +3 -4
- package/dist/irdevice/other.d.ts.map +1 -1
- package/dist/irdevice/other.js +47 -33
- package/dist/irdevice/other.js.map +1 -1
- package/dist/irdevice/tv.d.ts +10 -11
- package/dist/irdevice/tv.d.ts.map +1 -1
- package/dist/irdevice/tv.js +64 -48
- package/dist/irdevice/tv.js.map +1 -1
- package/dist/irdevice/vacuumcleaner.d.ts +7 -12
- package/dist/irdevice/vacuumcleaner.d.ts.map +1 -1
- package/dist/irdevice/vacuumcleaner.js +52 -41
- package/dist/irdevice/vacuumcleaner.js.map +1 -1
- package/dist/irdevice/waterheater.d.ts +6 -11
- package/dist/irdevice/waterheater.d.ts.map +1 -1
- package/dist/irdevice/waterheater.js +52 -42
- package/dist/irdevice/waterheater.js.map +1 -1
- package/dist/platform.d.ts +0 -4
- package/dist/platform.d.ts.map +1 -1
- package/dist/platform.js +44 -66
- package/dist/platform.js.map +1 -1
- package/dist/settings.d.ts +3 -3
- package/dist/settings.d.ts.map +1 -1
- package/package.json +7 -6
- package/src/device/bot.ts +551 -589
- package/src/device/colorbulb.ts +441 -375
- package/src/device/contact.ts +249 -213
- package/src/device/curtain.ts +452 -461
- package/src/device/humidifier.ts +358 -365
- package/src/device/lock.ts +263 -179
- package/src/device/meter.ts +302 -253
- package/src/device/meterplus.ts +319 -194
- package/src/device/motion.ts +230 -199
- package/src/device/plug.ts +273 -274
- package/src/device/striplight.ts +460 -316
- package/src/irdevice/airconditioner.ts +181 -183
- package/src/irdevice/airpurifier.ts +70 -60
- package/src/irdevice/camera.ts +46 -36
- package/src/irdevice/fan.ts +64 -49
- package/src/irdevice/light.ts +47 -51
- package/src/irdevice/other.ts +46 -36
- package/src/irdevice/tv.ts +64 -51
- package/src/irdevice/vacuumcleaner.ts +52 -45
- package/src/irdevice/waterheater.ts +50 -45
- package/src/platform.ts +44 -68
- 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
|
-
|
|
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}
|
|
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
|
|
82
|
-
* Vacuum Cleaner
|
|
83
|
-
* Vacuum Cleaner
|
|
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.
|
|
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
|
-
|
|
204
|
-
|
|
205
|
-
|
|
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.
|
|
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.
|
|
221
|
-
config['
|
|
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
|
-
|
|
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}
|
|
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
|
|
89
|
-
* WaterHeater
|
|
90
|
-
* WaterHeater
|
|
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
|
-
|
|
209
|
-
|
|
210
|
-
|
|
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.
|
|
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.
|
|
226
|
-
config['
|
|
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)}`);
|