@switchbot/homebridge-switchbot 3.5.1-beta.12 → 3.5.1-beta.14
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/config.schema.json +19 -3
- package/dist/device/blindtilt.d.ts +6 -4
- package/dist/device/blindtilt.d.ts.map +1 -1
- package/dist/device/blindtilt.js +56 -44
- package/dist/device/blindtilt.js.map +1 -1
- package/dist/device/bot.d.ts +6 -3
- package/dist/device/bot.d.ts.map +1 -1
- package/dist/device/bot.js +37 -23
- package/dist/device/bot.js.map +1 -1
- package/dist/device/ceilinglight.d.ts +6 -3
- package/dist/device/ceilinglight.d.ts.map +1 -1
- package/dist/device/ceilinglight.js +39 -20
- package/dist/device/ceilinglight.js.map +1 -1
- package/dist/device/colorbulb.d.ts +6 -3
- package/dist/device/colorbulb.d.ts.map +1 -1
- package/dist/device/colorbulb.js +41 -30
- package/dist/device/colorbulb.js.map +1 -1
- package/dist/device/contact.d.ts +6 -3
- package/dist/device/contact.d.ts.map +1 -1
- package/dist/device/contact.js +39 -27
- package/dist/device/contact.js.map +1 -1
- package/dist/device/curtain.d.ts +6 -4
- package/dist/device/curtain.d.ts.map +1 -1
- package/dist/device/curtain.js +34 -21
- package/dist/device/curtain.js.map +1 -1
- package/dist/device/device.d.ts +6 -3
- package/dist/device/device.d.ts.map +1 -1
- package/dist/device/device.js +54 -125
- package/dist/device/device.js.map +1 -1
- package/dist/device/fan.d.ts +6 -3
- package/dist/device/fan.d.ts.map +1 -1
- package/dist/device/fan.js +47 -28
- package/dist/device/fan.js.map +1 -1
- package/dist/device/hub.d.ts +6 -3
- package/dist/device/hub.d.ts.map +1 -1
- package/dist/device/hub.js +42 -25
- package/dist/device/hub.js.map +1 -1
- package/dist/device/humidifier.d.ts +6 -3
- package/dist/device/humidifier.d.ts.map +1 -1
- package/dist/device/humidifier.js +42 -25
- package/dist/device/humidifier.js.map +1 -1
- package/dist/device/iosensor.d.ts +6 -3
- package/dist/device/iosensor.d.ts.map +1 -1
- package/dist/device/iosensor.js +38 -23
- package/dist/device/iosensor.js.map +1 -1
- package/dist/device/lightstrip.d.ts +6 -3
- package/dist/device/lightstrip.d.ts.map +1 -1
- package/dist/device/lightstrip.js +42 -26
- package/dist/device/lightstrip.js.map +1 -1
- package/dist/device/lock.d.ts +6 -3
- package/dist/device/lock.d.ts.map +1 -1
- package/dist/device/lock.js +32 -21
- package/dist/device/lock.js.map +1 -1
- package/dist/device/meter.d.ts +6 -3
- package/dist/device/meter.d.ts.map +1 -1
- package/dist/device/meter.js +37 -23
- package/dist/device/meter.js.map +1 -1
- package/dist/device/meterplus.d.ts +6 -3
- package/dist/device/meterplus.d.ts.map +1 -1
- package/dist/device/meterplus.js +36 -23
- package/dist/device/meterplus.js.map +1 -1
- package/dist/device/motion.d.ts +6 -3
- package/dist/device/motion.d.ts.map +1 -1
- package/dist/device/motion.js +32 -21
- package/dist/device/motion.js.map +1 -1
- package/dist/device/plug.d.ts +6 -3
- package/dist/device/plug.d.ts.map +1 -1
- package/dist/device/plug.js +26 -15
- package/dist/device/plug.js.map +1 -1
- package/dist/device/robotvacuumcleaner.d.ts +6 -3
- package/dist/device/robotvacuumcleaner.d.ts.map +1 -1
- package/dist/device/robotvacuumcleaner.js +33 -20
- package/dist/device/robotvacuumcleaner.js.map +1 -1
- package/dist/device/waterdetector.d.ts +6 -3
- package/dist/device/waterdetector.d.ts.map +1 -1
- package/dist/device/waterdetector.js +37 -22
- package/dist/device/waterdetector.js.map +1 -1
- package/dist/irdevice/airconditioner.d.ts.map +1 -1
- package/dist/irdevice/airconditioner.js +19 -72
- package/dist/irdevice/airconditioner.js.map +1 -1
- package/dist/irdevice/airpurifier.js +4 -4
- package/dist/irdevice/airpurifier.js.map +1 -1
- package/dist/irdevice/camera.d.ts.map +1 -1
- package/dist/irdevice/camera.js +3 -10
- package/dist/irdevice/camera.js.map +1 -1
- package/dist/irdevice/fan.d.ts.map +1 -1
- package/dist/irdevice/fan.js +7 -25
- package/dist/irdevice/fan.js.map +1 -1
- package/dist/irdevice/irdevice.d.ts +1 -1
- package/dist/irdevice/irdevice.js +2 -2
- package/dist/irdevice/irdevice.js.map +1 -1
- package/dist/irdevice/light.d.ts.map +1 -1
- package/dist/irdevice/light.js +9 -27
- package/dist/irdevice/light.js.map +1 -1
- package/dist/irdevice/other.js +1 -1
- package/dist/irdevice/other.js.map +1 -1
- package/dist/irdevice/tv.d.ts.map +1 -1
- package/dist/irdevice/tv.js +3 -18
- package/dist/irdevice/tv.js.map +1 -1
- package/dist/irdevice/vacuumcleaner.d.ts.map +1 -1
- package/dist/irdevice/vacuumcleaner.js +2 -9
- package/dist/irdevice/vacuumcleaner.js.map +1 -1
- package/dist/irdevice/waterheater.d.ts.map +1 -1
- package/dist/irdevice/waterheater.js +2 -9
- package/dist/irdevice/waterheater.js.map +1 -1
- package/dist/platform.d.ts +3 -5
- package/dist/platform.d.ts.map +1 -1
- package/dist/platform.js +13 -13
- package/dist/platform.js.map +1 -1
- package/dist/settings.d.ts +9 -8
- package/dist/settings.d.ts.map +1 -1
- package/dist/settings.js.map +1 -1
- package/dist/types/bledevicestatus.d.ts +2 -1
- package/dist/types/bledevicestatus.d.ts.map +1 -1
- package/dist/types/devicestatus.d.ts +1 -1
- package/dist/types/devicestatus.d.ts.map +1 -1
- package/package.json +9 -9
- package/src/device/blindtilt.ts +59 -46
- package/src/device/bot.ts +46 -24
- package/src/device/ceilinglight.ts +51 -20
- package/src/device/colorbulb.ts +44 -30
- package/src/device/contact.ts +42 -27
- package/src/device/curtain.ts +44 -22
- package/src/device/device.ts +56 -112
- package/src/device/fan.ts +60 -29
- package/src/device/hub.ts +54 -28
- package/src/device/humidifier.ts +54 -30
- package/src/device/iosensor.ts +44 -26
- package/src/device/lightstrip.ts +47 -27
- package/src/device/lock.ts +48 -22
- package/src/device/meter.ts +53 -25
- package/src/device/meterplus.ts +49 -25
- package/src/device/motion.ts +44 -23
- package/src/device/plug.ts +33 -16
- package/src/device/robotvacuumcleaner.ts +48 -22
- package/src/device/waterdetector.ts +55 -24
- package/src/irdevice/airconditioner.ts +19 -65
- package/src/irdevice/airpurifier.ts +4 -4
- package/src/irdevice/camera.ts +4 -9
- package/src/irdevice/fan.ts +10 -22
- package/src/irdevice/irdevice.ts +2 -2
- package/src/irdevice/light.ts +10 -24
- package/src/irdevice/other.ts +1 -1
- package/src/irdevice/tv.ts +5 -16
- package/src/irdevice/vacuumcleaner.ts +3 -8
- package/src/irdevice/waterheater.ts +3 -8
- package/src/platform.ts +14 -14
- package/src/settings.ts +10 -8
- package/src/types/bledevicestatus.ts +4 -2
- package/src/types/devicestatus.ts +1 -1
|
@@ -36,6 +36,15 @@ export class WaterDetector extends deviceBase {
|
|
|
36
36
|
LeakDetected: CharacteristicValue;
|
|
37
37
|
};
|
|
38
38
|
|
|
39
|
+
// OpenAPI
|
|
40
|
+
deviceStatus!: waterLeakDetectorStatus;
|
|
41
|
+
|
|
42
|
+
//Webhook
|
|
43
|
+
webhookContext!: waterLeakDetectorWebhookContext;
|
|
44
|
+
|
|
45
|
+
// BLE
|
|
46
|
+
serviceData!: waterLeakDetectorServiceData;
|
|
47
|
+
|
|
39
48
|
// Updates
|
|
40
49
|
WaterDetectorUpdateInProgress!: boolean;
|
|
41
50
|
doWaterDetectorUpdate: Subject<void>;
|
|
@@ -106,13 +115,11 @@ export class WaterDetector extends deviceBase {
|
|
|
106
115
|
}
|
|
107
116
|
|
|
108
117
|
// Retrieve initial values and updateHomekit
|
|
109
|
-
this.debugLog('
|
|
118
|
+
this.debugLog('Retrieve initial values and update Homekit');
|
|
110
119
|
this.refreshStatus();
|
|
111
120
|
|
|
112
|
-
// Retrieve initial values and updateHomekit
|
|
113
|
-
// this.updateHomeKitCharacteristics();
|
|
114
|
-
|
|
115
121
|
//regisiter webhook event handler
|
|
122
|
+
this.debugLog('Registering Webhook Event Handler');
|
|
116
123
|
this.registerWebhook();
|
|
117
124
|
|
|
118
125
|
// Start an update interval
|
|
@@ -124,18 +131,24 @@ export class WaterDetector extends deviceBase {
|
|
|
124
131
|
});
|
|
125
132
|
}
|
|
126
133
|
|
|
127
|
-
async BLEparseStatus(
|
|
134
|
+
async BLEparseStatus(): Promise<void> {
|
|
128
135
|
await this.debugLog('BLEparseStatus');
|
|
136
|
+
await this.debugLog(`(state, status, battery) = BLE: (${this.serviceData.state}, ${this.serviceData.status}, ${this.serviceData.battery}),`
|
|
137
|
+
+ ` current:(${this.LeakSensor?.LeakDetected}, ${this.Battery.BatteryLevel})`);
|
|
138
|
+
|
|
139
|
+
//LeakSensor
|
|
129
140
|
if (this.device.waterdetector?.hide_leak && this.LeakSensor?.Service) {
|
|
141
|
+
|
|
130
142
|
// StatusActive
|
|
131
|
-
this.LeakSensor.StatusActive = serviceData.state;
|
|
143
|
+
this.LeakSensor.StatusActive = this.serviceData.state;
|
|
132
144
|
await this.debugLog(`StatusActive: ${this.LeakSensor.StatusActive}`);
|
|
145
|
+
|
|
133
146
|
// LeakDetected
|
|
134
|
-
this.LeakSensor.LeakDetected = serviceData.status;
|
|
147
|
+
this.LeakSensor.LeakDetected = this.serviceData.status;
|
|
135
148
|
this.debugLog(`LeakDetected: ${this.LeakSensor.LeakDetected}`);
|
|
136
149
|
}
|
|
137
150
|
// BatteryLevel
|
|
138
|
-
this.Battery.BatteryLevel =
|
|
151
|
+
this.Battery.BatteryLevel = this.serviceData.battery;
|
|
139
152
|
await this.debugLog(`BatteryLevel: ${this.Battery.BatteryLevel}`);
|
|
140
153
|
// StatusLowBattery
|
|
141
154
|
this.Battery.StatusLowBattery = this.Battery.BatteryLevel < 10
|
|
@@ -143,27 +156,36 @@ export class WaterDetector extends deviceBase {
|
|
|
143
156
|
await this.debugLog(`StatusLowBattery: ${this.Battery.StatusLowBattery}`);
|
|
144
157
|
}
|
|
145
158
|
|
|
146
|
-
async openAPIparseStatus(
|
|
159
|
+
async openAPIparseStatus(): Promise<void> {
|
|
147
160
|
await this.debugLog('openAPIparseStatus');
|
|
161
|
+
await this.debugLog(`(status, battery) = OpenAPI: (${this.deviceStatus.status}, ${this.deviceStatus.battery}),`
|
|
162
|
+
+ ` current:(${this.LeakSensor?.LeakDetected}, ${this.Battery.BatteryLevel})`);
|
|
163
|
+
|
|
164
|
+
//LeakSensor
|
|
148
165
|
if (!this.device.waterdetector?.hide_leak && this.LeakSensor?.Service) {
|
|
166
|
+
|
|
149
167
|
// StatusActive
|
|
150
|
-
this.LeakSensor.StatusActive = deviceStatus.battery === 0 ? false : true;
|
|
168
|
+
this.LeakSensor.StatusActive = this.deviceStatus.battery === 0 ? false : true;
|
|
151
169
|
await this.debugLog(`StatusActive: ${this.LeakSensor.StatusActive}`);
|
|
170
|
+
|
|
152
171
|
// LeakDetected
|
|
153
|
-
this.LeakSensor.LeakDetected = deviceStatus.status;
|
|
172
|
+
this.LeakSensor.LeakDetected = this.deviceStatus.status;
|
|
154
173
|
this.debugLog(`LeakDetected: ${this.LeakSensor.LeakDetected}`);
|
|
155
174
|
}
|
|
175
|
+
|
|
156
176
|
// BatteryLevel
|
|
157
|
-
this.Battery.BatteryLevel =
|
|
177
|
+
this.Battery.BatteryLevel = this.deviceStatus.battery;
|
|
158
178
|
await this.debugLog(`BatteryLevel: ${this.Battery.BatteryLevel}`);
|
|
179
|
+
|
|
159
180
|
// StatusLowBattery
|
|
160
181
|
this.Battery.StatusLowBattery = this.Battery.BatteryLevel < 10
|
|
161
182
|
? this.hap.Characteristic.StatusLowBattery.BATTERY_LEVEL_LOW : this.hap.Characteristic.StatusLowBattery.BATTERY_LEVEL_NORMAL;
|
|
162
183
|
await this.debugLog(`StatusLowBattery: ${this.Battery.StatusLowBattery}`);
|
|
184
|
+
|
|
163
185
|
// FirmwareVersion
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
186
|
+
if (this.deviceStatus.version) {
|
|
187
|
+
const version = this.deviceStatus.version.toString();
|
|
188
|
+
await this.debugLog(`FirmwareVersion: ${version.replace(/^V|-.*$/g, '')}`);
|
|
167
189
|
const deviceVersion = version.replace(/^V|-.*$/g, '') ?? '0.0.0';
|
|
168
190
|
this.accessory
|
|
169
191
|
.getService(this.hap.Service.AccessoryInformation)!
|
|
@@ -176,21 +198,27 @@ export class WaterDetector extends deviceBase {
|
|
|
176
198
|
}
|
|
177
199
|
}
|
|
178
200
|
|
|
179
|
-
async parseStatusWebhook(
|
|
201
|
+
async parseStatusWebhook(): Promise<void> {
|
|
180
202
|
await this.debugLog('parseStatusWebhook');
|
|
181
|
-
await this.debugLog(`(detectionState, battery) = Webhook: (${
|
|
203
|
+
await this.debugLog(`(detectionState, battery) = Webhook: (${this.webhookContext.detectionState}, ${this.webhookContext.battery}),`
|
|
182
204
|
+ ` current:(${this.LeakSensor?.LeakDetected}, ${this.Battery.BatteryLevel})`);
|
|
205
|
+
|
|
206
|
+
//LeakSensor
|
|
183
207
|
if (!this.device.waterdetector?.hide_leak && this.LeakSensor?.Service) {
|
|
208
|
+
|
|
184
209
|
// StatusActive
|
|
185
|
-
this.LeakSensor.StatusActive =
|
|
210
|
+
this.LeakSensor.StatusActive = this.webhookContext.detectionState ? true : false;
|
|
186
211
|
await this.debugLog(`StatusActive: ${this.LeakSensor.StatusActive}`);
|
|
212
|
+
|
|
187
213
|
// LeakDetected
|
|
188
|
-
this.LeakSensor.LeakDetected =
|
|
214
|
+
this.LeakSensor.LeakDetected = this.webhookContext.detectionState;
|
|
189
215
|
await this.debugLog(`LeakDetected: ${this.LeakSensor.LeakDetected}`);
|
|
190
216
|
}
|
|
217
|
+
|
|
191
218
|
// BatteryLevel
|
|
192
|
-
this.Battery.BatteryLevel =
|
|
219
|
+
this.Battery.BatteryLevel = this.webhookContext.battery;
|
|
193
220
|
await this.debugLog(`BatteryLevel: ${this.Battery.BatteryLevel}`);
|
|
221
|
+
|
|
194
222
|
// StatusLowBattery
|
|
195
223
|
this.Battery.StatusLowBattery = this.Battery.BatteryLevel < 10
|
|
196
224
|
? this.hap.Characteristic.StatusLowBattery.BATTERY_LEVEL_LOW : this.hap.Characteristic.StatusLowBattery.BATTERY_LEVEL_NORMAL;
|
|
@@ -223,10 +251,11 @@ export class WaterDetector extends deviceBase {
|
|
|
223
251
|
// Start to monitor advertisement packets
|
|
224
252
|
(async () => {
|
|
225
253
|
// Start to monitor advertisement packets
|
|
226
|
-
const serviceData = await this.monitorAdvertisementPackets(switchbot) as
|
|
254
|
+
const serviceData = await this.monitorAdvertisementPackets(switchbot) as waterLeakDetectorServiceData;
|
|
227
255
|
// Update HomeKit
|
|
228
256
|
if (serviceData.model === SwitchBotBLEModel.Unknown && serviceData.modelName === SwitchBotBLEModelName.Unknown) {
|
|
229
|
-
|
|
257
|
+
this.serviceData = serviceData;
|
|
258
|
+
await this.BLEparseStatus();
|
|
230
259
|
await this.updateHomeKitCharacteristics();
|
|
231
260
|
} else {
|
|
232
261
|
await this.errorLog(`failed to get serviceData, serviceData: ${serviceData}`);
|
|
@@ -244,7 +273,8 @@ export class WaterDetector extends deviceBase {
|
|
|
244
273
|
await this.debugLog(`statusCode: ${statusCode}, deviceStatus: ${JSON.stringify(deviceStatus)}`);;
|
|
245
274
|
if (await this.successfulStatusCodes(statusCode, deviceStatus)) {
|
|
246
275
|
await this.debugSuccessLog(`statusCode: ${statusCode}, deviceStatus: ${JSON.stringify(deviceStatus)}`);
|
|
247
|
-
|
|
276
|
+
this.deviceStatus = deviceStatus.body;
|
|
277
|
+
await this.openAPIparseStatus();
|
|
248
278
|
await this.updateHomeKitCharacteristics();
|
|
249
279
|
} else {
|
|
250
280
|
await this.debugWarnLog(`statusCode: ${statusCode}, deviceStatus: ${JSON.stringify(deviceStatus)}`);
|
|
@@ -262,7 +292,8 @@ export class WaterDetector extends deviceBase {
|
|
|
262
292
|
this.platform.webhookEventHandler[this.device.deviceId] = async (context: waterLeakDetectorWebhookContext) => {
|
|
263
293
|
try {
|
|
264
294
|
await this.debugLog(`received Webhook: ${JSON.stringify(context)}`);
|
|
265
|
-
|
|
295
|
+
this.webhookContext = context;
|
|
296
|
+
await this.parseStatusWebhook();
|
|
266
297
|
await this.updateHomeKitCharacteristics();
|
|
267
298
|
} catch (e: any) {
|
|
268
299
|
await this.errorLog(`failed to handle webhook. Received: ${JSON.stringify(context)} Error: ${e}`);
|
|
@@ -352,7 +352,7 @@ export class AirConditioner extends irdeviceBase {
|
|
|
352
352
|
const { body, statusCode } = await this.pushChangeRequest(bodyChange);
|
|
353
353
|
const deviceStatus: any = await body.json();
|
|
354
354
|
await this.pushStatusCodes(statusCode, deviceStatus);
|
|
355
|
-
if (
|
|
355
|
+
if (await this.successfulStatusCodes(statusCode, deviceStatus)) {
|
|
356
356
|
await this.successfulPushChange(statusCode, deviceStatus, bodyChange);
|
|
357
357
|
await this.updateHomeKitCharacteristics();
|
|
358
358
|
} else {
|
|
@@ -501,39 +501,25 @@ export class AirConditioner extends irdeviceBase {
|
|
|
501
501
|
}
|
|
502
502
|
|
|
503
503
|
async ThresholdTemperatureGet(): Promise<CharacteristicValue> {
|
|
504
|
+
this.HeaterCooler.Active = this.HeaterCooler.Active === undefined ? this.hap.Characteristic.Active.INACTIVE
|
|
505
|
+
: this.HeaterCooler.Active ?? this.accessory.context.Active;
|
|
504
506
|
|
|
505
|
-
|
|
506
|
-
this.
|
|
507
|
-
|
|
508
|
-
this.HeaterCooler.Active = this.HeaterCooler.Active ? this.HeaterCooler.Active : this.accessory.context.Active;
|
|
509
|
-
}
|
|
507
|
+
this.HeaterCooler.CurrentTemperature = (this.HeaterCooler.CurrentTemperature === undefined
|
|
508
|
+
&& this.accessory.context.CurrentTemperature === undefined) ? 24 : this.HeaterCooler.CurrentTemperature
|
|
509
|
+
?? this.accessory.context.CurrentTemperature;
|
|
510
510
|
|
|
511
|
-
|
|
512
|
-
|
|
513
|
-
} else {
|
|
514
|
-
this.HeaterCooler.CurrentTemperature = this.HeaterCooler.CurrentTemperature || this.accessory.context.CurrentTemperature;
|
|
515
|
-
}
|
|
511
|
+
this.HeaterCooler.ThresholdTemperature = this.HeaterCooler.ThresholdTemperature === undefined ? 24 : this.HeaterCooler.ThresholdTemperature
|
|
512
|
+
?? this.accessory.context.ThresholdTemperature;
|
|
516
513
|
|
|
517
|
-
|
|
518
|
-
this.HeaterCooler.
|
|
519
|
-
} else {
|
|
520
|
-
this.HeaterCooler.ThresholdTemperature = this.HeaterCooler.ThresholdTemperature || this.accessory.context.ThresholdTemperature;
|
|
521
|
-
}
|
|
522
|
-
|
|
523
|
-
if (this.HeaterCooler.RotationSpeed === undefined && this.accessory.context.RotationSpeed === undefined) {
|
|
524
|
-
this.HeaterCooler.RotationSpeed = 4;
|
|
525
|
-
} else {
|
|
526
|
-
this.HeaterCooler.RotationSpeed = this.HeaterCooler.RotationSpeed || this.accessory.context.RotationSpeed;
|
|
527
|
-
}
|
|
514
|
+
this.HeaterCooler.RotationSpeed = (this.HeaterCooler.RotationSpeed === undefined && this.accessory.context.RotationSpeed === undefined) ? 4
|
|
515
|
+
: this.HeaterCooler.RotationSpeed ?? this.accessory.context.RotationSpeed;
|
|
528
516
|
|
|
529
517
|
await this.getAirConditionerConfigSettings(this.accessory, this.device);
|
|
530
518
|
|
|
531
|
-
if (this.meter) {
|
|
532
|
-
|
|
533
|
-
this.
|
|
534
|
-
|
|
535
|
-
this.HumiditySensor!.CurrentRelativeHumidity = this.HumiditySensor!.CurrentRelativeHumidity || this.accessory.context.CurrentRelativeHumidity;
|
|
536
|
-
}
|
|
519
|
+
if (this.meter && this.HumiditySensor?.Service) {
|
|
520
|
+
this.HumiditySensor.CurrentRelativeHumidity = (this.HumiditySensor.CurrentRelativeHumidity === undefined
|
|
521
|
+
&& this.accessory.context.CurrentRelativeHumidity === undefined) ? 0 : this.HumiditySensor.CurrentRelativeHumidity
|
|
522
|
+
?? this.accessory.context.CurrentRelativeHumidity;
|
|
537
523
|
}
|
|
538
524
|
await this.debugLog(`Get ThresholdTemperature: ${this.HeaterCooler.ThresholdTemperature}`);
|
|
539
525
|
return this.HeaterCooler.ThresholdTemperature;
|
|
@@ -588,42 +574,10 @@ export class AirConditioner extends irdeviceBase {
|
|
|
588
574
|
}
|
|
589
575
|
|
|
590
576
|
async getAirConditionerConfigSettings(accessory: PlatformAccessory, device: irdevice & irDevicesConfig): Promise<void> {
|
|
591
|
-
|
|
592
|
-
|
|
593
|
-
|
|
594
|
-
|
|
595
|
-
|
|
596
|
-
accessory.context.hide_automode = this.hide_automode;
|
|
597
|
-
}
|
|
598
|
-
|
|
599
|
-
if (this.device.irair?.set_max_heat) {
|
|
600
|
-
this.set_max_heat = device.irair?.set_max_heat;
|
|
601
|
-
accessory.context.set_max_heat = this.set_max_heat;
|
|
602
|
-
} else {
|
|
603
|
-
this.set_max_heat = 35;
|
|
604
|
-
accessory.context.set_max_heat = this.set_max_heat;
|
|
605
|
-
}
|
|
606
|
-
if (this.device.irair?.set_min_heat) {
|
|
607
|
-
this.set_min_heat = device.irair?.set_min_heat;
|
|
608
|
-
accessory.context.set_min_heat = this.set_min_heat;
|
|
609
|
-
} else {
|
|
610
|
-
this.set_min_heat = 0;
|
|
611
|
-
accessory.context.set_min_heat = this.set_min_heat;
|
|
612
|
-
}
|
|
613
|
-
|
|
614
|
-
if (this.device.irair?.set_max_cool) {
|
|
615
|
-
this.set_max_cool = device.irair?.set_max_cool;
|
|
616
|
-
accessory.context.set_max_cool = this.set_max_cool;
|
|
617
|
-
} else {
|
|
618
|
-
this.set_max_cool = 35;
|
|
619
|
-
accessory.context.set_max_cool = this.set_max_cool;
|
|
620
|
-
}
|
|
621
|
-
if (this.device.irair?.set_min_cool) {
|
|
622
|
-
this.set_min_cool = device.irair?.set_min_cool;
|
|
623
|
-
accessory.context.set_min_cool = this.set_min_cool;
|
|
624
|
-
} else {
|
|
625
|
-
this.set_min_cool = 0;
|
|
626
|
-
accessory.context.set_min_cool = this.set_min_cool;
|
|
627
|
-
}
|
|
577
|
+
accessory.context.hide_automode = this.hide_automode = device.irair?.hide_automode;
|
|
578
|
+
accessory.context.set_max_heat = this.set_max_heat = device.irair?.set_max_heat ?? 35;
|
|
579
|
+
accessory.context.set_min_heat = this.set_min_heat = device.irair?.set_min_heat ?? 0;
|
|
580
|
+
accessory.context.set_max_cool = this.set_max_cool = device.irair?.set_max_cool ?? 35;
|
|
581
|
+
accessory.context.set_min_cool = this.set_min_cool = device.irair?.set_min_cool ?? 0;
|
|
628
582
|
}
|
|
629
583
|
}
|
|
@@ -229,7 +229,7 @@ export class AirPurifier extends irdeviceBase {
|
|
|
229
229
|
const { body, statusCode } = await this.pushChangeRequest(bodyChange);
|
|
230
230
|
const deviceStatus: any = await body.json();
|
|
231
231
|
await this.pushStatusCodes(statusCode, deviceStatus);
|
|
232
|
-
if (
|
|
232
|
+
if (await this.successfulStatusCodes(statusCode, deviceStatus)) {
|
|
233
233
|
await this.successfulPushChange(statusCode, deviceStatus, bodyChange);
|
|
234
234
|
await this.updateHomeKitCharacteristics();
|
|
235
235
|
} else {
|
|
@@ -262,10 +262,10 @@ export class AirPurifier extends irdeviceBase {
|
|
|
262
262
|
}
|
|
263
263
|
|
|
264
264
|
async apiError(e: any): Promise<void> {
|
|
265
|
-
this.AirPurifier.Service.updateCharacteristic(this.hap.Characteristic.CurrentHeaterCoolerState, e);
|
|
266
|
-
this.AirPurifier.Service.updateCharacteristic(this.hap.Characteristic.CurrentAirPurifierState, e);
|
|
267
|
-
this.AirPurifier.Service.updateCharacteristic(this.hap.Characteristic.TargetAirPurifierState, e);
|
|
268
265
|
this.AirPurifier.Service.updateCharacteristic(this.hap.Characteristic.Active, e);
|
|
266
|
+
this.AirPurifier.Service.updateCharacteristic(this.hap.Characteristic.TargetAirPurifierState, e);
|
|
267
|
+
this.AirPurifier.Service.updateCharacteristic(this.hap.Characteristic.CurrentAirPurifierState, e);
|
|
268
|
+
this.AirPurifier.Service.updateCharacteristic(this.hap.Characteristic.CurrentHeaterCoolerState, e);
|
|
269
269
|
this.TemperatureSensor.Service.updateCharacteristic(this.hap.Characteristic.CurrentTemperature, e);
|
|
270
270
|
}
|
|
271
271
|
}
|
package/src/irdevice/camera.ts
CHANGED
|
@@ -106,7 +106,7 @@ export class Camera extends irdeviceBase {
|
|
|
106
106
|
const { body, statusCode } = await this.pushChangeRequest(bodyChange);
|
|
107
107
|
const deviceStatus: any = await body.json();
|
|
108
108
|
await this.pushStatusCodes(statusCode, deviceStatus);
|
|
109
|
-
if (
|
|
109
|
+
if (await this.successfulStatusCodes(statusCode, deviceStatus)) {
|
|
110
110
|
await this.successfulPushChange(statusCode, deviceStatus, bodyChange);
|
|
111
111
|
await this.updateHomeKitCharacteristics();
|
|
112
112
|
} else {
|
|
@@ -124,14 +124,9 @@ export class Camera extends irdeviceBase {
|
|
|
124
124
|
|
|
125
125
|
async updateHomeKitCharacteristics(): Promise<void> {
|
|
126
126
|
await this.debugLog('updateHomeKitCharacteristics');
|
|
127
|
-
//
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
} else {
|
|
131
|
-
this.accessory.context.On = this.Switch.On;
|
|
132
|
-
this.Switch.Service.updateCharacteristic(this.hap.Characteristic.On, this.Switch.On);
|
|
133
|
-
await this.debugLog(`updateCharacteristic On: ${this.Switch.On}`);
|
|
134
|
-
}
|
|
127
|
+
// Active
|
|
128
|
+
await this.updateCharacteristic(this.Switch.Service, this.hap.Characteristic.On,
|
|
129
|
+
this.Switch.On, 'On');
|
|
135
130
|
}
|
|
136
131
|
|
|
137
132
|
async apiError(e: any): Promise<void> {
|
package/src/irdevice/fan.ts
CHANGED
|
@@ -206,7 +206,7 @@ export class IRFan extends irdeviceBase {
|
|
|
206
206
|
const { body, statusCode } = await this.pushChangeRequest(bodyChange);
|
|
207
207
|
const deviceStatus: any = await body.json();
|
|
208
208
|
await this.pushStatusCodes(statusCode, deviceStatus);
|
|
209
|
-
if (
|
|
209
|
+
if (await this.successfulStatusCodes(statusCode, deviceStatus)) {
|
|
210
210
|
await this.successfulPushChange(statusCode, deviceStatus, bodyChange);
|
|
211
211
|
await this.updateHomeKitCharacteristics();
|
|
212
212
|
} else {
|
|
@@ -224,27 +224,15 @@ export class IRFan extends irdeviceBase {
|
|
|
224
224
|
|
|
225
225
|
async updateHomeKitCharacteristics(): Promise<void> {
|
|
226
226
|
await this.debugLog('updateHomeKitCharacteristics');
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
} else {
|
|
237
|
-
this.accessory.context.SwingMode = this.Fan.SwingMode;
|
|
238
|
-
this.Fan.Service.updateCharacteristic(this.hap.Characteristic.SwingMode, this.Fan.SwingMode);
|
|
239
|
-
await this.debugLog(`updateCharacteristic SwingMode: ${this.Fan.SwingMode}`);
|
|
240
|
-
}
|
|
241
|
-
if (this.Fan.RotationSpeed === undefined) {
|
|
242
|
-
await this.debugLog(`RotationSpeed: ${this.Fan.RotationSpeed}`);
|
|
243
|
-
} else {
|
|
244
|
-
this.accessory.context.RotationSpeed = this.Fan.RotationSpeed;
|
|
245
|
-
this.Fan.Service.updateCharacteristic(this.hap.Characteristic.RotationSpeed, this.Fan.RotationSpeed);
|
|
246
|
-
await this.debugLog(`updateCharacteristic RotationSpeed: ${this.Fan.RotationSpeed}`);
|
|
247
|
-
}
|
|
227
|
+
// Active
|
|
228
|
+
await this.updateCharacteristic(this.Fan.Service, this.hap.Characteristic.Active,
|
|
229
|
+
this.Fan.Active, 'Active');
|
|
230
|
+
// SwingMode
|
|
231
|
+
await this.updateCharacteristic(this.Fan.Service, this.hap.Characteristic.SwingMode,
|
|
232
|
+
this.Fan.SwingMode, 'SwingMode');
|
|
233
|
+
// RotationSpeed
|
|
234
|
+
await this.updateCharacteristic(this.Fan.Service, this.hap.Characteristic.RotationSpeed,
|
|
235
|
+
this.Fan.RotationSpeed, 'RotationSpeed');
|
|
248
236
|
}
|
|
249
237
|
|
|
250
238
|
async apiError(e: any): Promise<void> {
|
package/src/irdevice/irdevice.ts
CHANGED
|
@@ -44,7 +44,7 @@ export abstract class irdeviceBase {
|
|
|
44
44
|
.setCharacteristic(this.hap.Characteristic.Manufacturer, 'SwitchBot')
|
|
45
45
|
.setCharacteristic(this.hap.Characteristic.AppMatchingIdentifier, 'id1087374760')
|
|
46
46
|
.setCharacteristic(this.hap.Characteristic.Name, accessory.context.name ?? accessory.displayName)
|
|
47
|
-
.setCharacteristic(this.hap.Characteristic.ConfiguredName, accessory.context.name ?? accessory.displayName)
|
|
47
|
+
.setCharacteristic(this.hap.Characteristic.ConfiguredName, String(accessory.context.name ?? accessory.displayName))
|
|
48
48
|
.setCharacteristic(this.hap.Characteristic.Model, accessory.context.model ?? 'Unknown')
|
|
49
49
|
.setCharacteristic(this.hap.Characteristic.ProductData, accessory.context.deviceId)
|
|
50
50
|
.setCharacteristic(this.hap.Characteristic.SerialNumber, accessory.context.deviceId);
|
|
@@ -202,7 +202,7 @@ export abstract class irdeviceBase {
|
|
|
202
202
|
}
|
|
203
203
|
|
|
204
204
|
async successfulStatusCodes(statusCode: any, deviceStatus: any) {
|
|
205
|
-
return
|
|
205
|
+
return await this.successfulStatusCodes(statusCode, deviceStatus);
|
|
206
206
|
}
|
|
207
207
|
|
|
208
208
|
/**
|
package/src/irdevice/light.ts
CHANGED
|
@@ -219,7 +219,7 @@ export class Light extends irdeviceBase {
|
|
|
219
219
|
const { body, statusCode } = await this.pushChangeRequest(bodyChange);
|
|
220
220
|
const deviceStatus: any = await body.json();
|
|
221
221
|
await this.pushStatusCodes(statusCode, deviceStatus);
|
|
222
|
-
if (
|
|
222
|
+
if (await this.successfulStatusCodes(statusCode, deviceStatus)) {
|
|
223
223
|
await this.successfulPushChange(statusCode, deviceStatus, bodyChange);
|
|
224
224
|
this.accessory.context.On = On;
|
|
225
225
|
await this.updateHomeKitCharacteristics();
|
|
@@ -239,34 +239,20 @@ export class Light extends irdeviceBase {
|
|
|
239
239
|
|
|
240
240
|
async updateHomeKitCharacteristics(): Promise<void> {
|
|
241
241
|
await this.debugLog('updateHomeKitCharacteristics');
|
|
242
|
-
if (!this.device.irlight?.stateless) {
|
|
242
|
+
if (!this.device.irlight?.stateless && this.LightBulb?.Service) {
|
|
243
243
|
// On
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
} else {
|
|
247
|
-
this.accessory.context.On = this.LightBulb.On;
|
|
248
|
-
this.LightBulb?.Service.updateCharacteristic(this.hap.Characteristic.On, this.LightBulb.On);
|
|
249
|
-
await this.debugLog(`updateCharacteristic On: ${this.LightBulb.On}`);
|
|
250
|
-
}
|
|
244
|
+
await this.updateCharacteristic(this.LightBulb.Service, this.hap.Characteristic.On,
|
|
245
|
+
this.LightBulb.On, 'On');
|
|
251
246
|
} else {
|
|
247
|
+
if (this.ProgrammableSwitchOn?.Service) {
|
|
252
248
|
// On Stateful Programmable Switch
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
} else {
|
|
256
|
-
this.accessory.context.ProgrammableSwitchOutputStateOn = this.ProgrammableSwitchOn.ProgrammableSwitchOutputState;
|
|
257
|
-
this.ProgrammableSwitchOn?.Service.updateCharacteristic(this.hap.Characteristic.ProgrammableSwitchOutputState,
|
|
258
|
-
this.ProgrammableSwitchOn.ProgrammableSwitchOutputState);
|
|
259
|
-
this.debugLog('updateCharacteristic'
|
|
260
|
-
+ ` ProgrammableSwitchOutputStateOn: ${this.ProgrammableSwitchOn.ProgrammableSwitchOutputState}`);
|
|
249
|
+
await this.updateCharacteristic(this.ProgrammableSwitchOn.Service, this.hap.Characteristic.ProgrammableSwitchOutputState,
|
|
250
|
+
this.ProgrammableSwitchOn.ProgrammableSwitchOutputState, 'ProgrammableSwitchOutputState');
|
|
261
251
|
}
|
|
252
|
+
if (this.ProgrammableSwitchOff?.Service) {
|
|
262
253
|
// Off Stateful Programmable Switch
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
} else {
|
|
266
|
-
this.accessory.context.ProgrammableSwitchOutputStateOff = this.ProgrammableSwitchOff.ProgrammableSwitchOutputState;
|
|
267
|
-
this.ProgrammableSwitchOff.Service.updateCharacteristic(this.hap.Characteristic.ProgrammableSwitchOutputState,
|
|
268
|
-
this.ProgrammableSwitchOff.ProgrammableSwitchOutputState);
|
|
269
|
-
await this.debugLog(`updateCharacteristic ProgrammableSwitchOutputStateOff: ${this.ProgrammableSwitchOff?.ProgrammableSwitchOutputState}`);
|
|
254
|
+
await this.updateCharacteristic(this.ProgrammableSwitchOff.Service, this.hap.Characteristic.ProgrammableSwitchOutputState,
|
|
255
|
+
this.ProgrammableSwitchOff.ProgrammableSwitchOutputState, 'ProgrammableSwitchOutputState');
|
|
270
256
|
}
|
|
271
257
|
}
|
|
272
258
|
}
|
package/src/irdevice/other.ts
CHANGED
|
@@ -537,7 +537,7 @@ export class Others extends irdeviceBase {
|
|
|
537
537
|
const { body, statusCode } = await this.pushChangeRequest(bodyChange);
|
|
538
538
|
const deviceStatus: any = await body.json();
|
|
539
539
|
await this.pushStatusCodes(statusCode, deviceStatus);
|
|
540
|
-
if (
|
|
540
|
+
if (await this.successfulStatusCodes(statusCode, deviceStatus)) {
|
|
541
541
|
await this.successfulPushChange(statusCode, deviceStatus, bodyChange);
|
|
542
542
|
await this.updateHomeKitCharacteristics();
|
|
543
543
|
} else {
|
package/src/irdevice/tv.ts
CHANGED
|
@@ -369,7 +369,7 @@ export class TV extends irdeviceBase {
|
|
|
369
369
|
const { body, statusCode } = await this.pushChangeRequest(bodyChange);
|
|
370
370
|
const deviceStatus: any = await body.json();
|
|
371
371
|
await this.pushStatusCodes(statusCode, deviceStatus);
|
|
372
|
-
if (
|
|
372
|
+
if (await this.successfulStatusCodes(statusCode, deviceStatus)) {
|
|
373
373
|
await this.successfulPushChange(statusCode, deviceStatus, bodyChange);
|
|
374
374
|
await this.updateHomeKitCharacteristics();
|
|
375
375
|
} else {
|
|
@@ -388,22 +388,11 @@ export class TV extends irdeviceBase {
|
|
|
388
388
|
async updateHomeKitCharacteristics(): Promise<void> {
|
|
389
389
|
await this.debugLog('updateHomeKitCharacteristics');
|
|
390
390
|
// Active
|
|
391
|
-
|
|
392
|
-
|
|
393
|
-
} else {
|
|
394
|
-
this.accessory.context.Active = this.Television.Active;
|
|
395
|
-
this.Television.Service.updateCharacteristic(this.hap.Characteristic.Active, this.Television.Active);
|
|
396
|
-
await this.debugLog(`updateCharacteristic Active: ${this.Television.Active}`);
|
|
397
|
-
}
|
|
391
|
+
await this.updateCharacteristic(this.Television.Service, this.hap.Characteristic.Active,
|
|
392
|
+
this.Television.Active, 'Active');
|
|
398
393
|
// ActiveIdentifier
|
|
399
|
-
|
|
400
|
-
|
|
401
|
-
} else {
|
|
402
|
-
this.accessory.context.ActiveIdentifier = this.Television.ActiveIdentifier;
|
|
403
|
-
this.Television.Service.updateCharacteristic(this.hap.Characteristic.ActiveIdentifier, this.Television.ActiveIdentifier);
|
|
404
|
-
await this.debugLog('updateCharacteristic'
|
|
405
|
-
+ ` ActiveIdentifier: ${this.Television.ActiveIdentifier}`);
|
|
406
|
-
}
|
|
394
|
+
await this.updateCharacteristic(this.Television.Service, this.hap.Characteristic.ActiveIdentifier,
|
|
395
|
+
this.Television.ActiveIdentifier, 'ActiveIdentifier');
|
|
407
396
|
}
|
|
408
397
|
|
|
409
398
|
async apiError(e: any): Promise<void> {
|
|
@@ -103,7 +103,7 @@ export class VacuumCleaner extends irdeviceBase {
|
|
|
103
103
|
const { body, statusCode } = await this.pushChangeRequest(bodyChange);
|
|
104
104
|
const deviceStatus: any = await body.json();
|
|
105
105
|
await this.pushStatusCodes(statusCode, deviceStatus);
|
|
106
|
-
if (
|
|
106
|
+
if (await this.successfulStatusCodes(statusCode, deviceStatus)) {
|
|
107
107
|
await this.successfulPushChange(statusCode, deviceStatus, bodyChange);
|
|
108
108
|
await this.updateHomeKitCharacteristics();
|
|
109
109
|
} else {
|
|
@@ -122,13 +122,8 @@ export class VacuumCleaner extends irdeviceBase {
|
|
|
122
122
|
async updateHomeKitCharacteristics(): Promise<void> {
|
|
123
123
|
await this.debugLog('updateHomeKitCharacteristics');
|
|
124
124
|
// On
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
} else {
|
|
128
|
-
this.accessory.context.On = this.Switch.On;
|
|
129
|
-
this.Switch.Service.updateCharacteristic(this.hap.Characteristic.On, this.Switch.On);
|
|
130
|
-
await this.debugLog(`updateCharacteristic On: ${this.Switch.On}`);
|
|
131
|
-
}
|
|
125
|
+
await this.updateCharacteristic(this.Switch.Service, this.hap.Characteristic.On,
|
|
126
|
+
this.Switch.On, 'On');
|
|
132
127
|
}
|
|
133
128
|
|
|
134
129
|
async apiError(e: any): Promise<void> {
|
|
@@ -105,7 +105,7 @@ export class WaterHeater extends irdeviceBase {
|
|
|
105
105
|
const { body, statusCode } = await this.pushChangeRequest(bodyChange);
|
|
106
106
|
const deviceStatus: any = await body.json();
|
|
107
107
|
await this.pushStatusCodes(statusCode, deviceStatus);
|
|
108
|
-
if (
|
|
108
|
+
if (await this.successfulStatusCodes(statusCode, deviceStatus)) {
|
|
109
109
|
await this.successfulPushChange(statusCode, deviceStatus, bodyChange);
|
|
110
110
|
await this.updateHomeKitCharacteristics();
|
|
111
111
|
} else {
|
|
@@ -124,13 +124,8 @@ export class WaterHeater extends irdeviceBase {
|
|
|
124
124
|
async updateHomeKitCharacteristics(): Promise<void> {
|
|
125
125
|
await this.debugLog('updateHomeKitCharacteristics');
|
|
126
126
|
// Active
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
} else {
|
|
130
|
-
this.accessory.context.Active = this.Valve.Active;
|
|
131
|
-
this.Valve.Service.updateCharacteristic(this.hap.Characteristic.Active, this.Valve.Active);
|
|
132
|
-
await this.debugLog(`updateCharacteristic Active: ${this.Valve.Active}`);
|
|
133
|
-
}
|
|
127
|
+
await this.updateCharacteristic(this.Valve.Service, this.hap.Characteristic.Active,
|
|
128
|
+
this.Valve.Active, 'Active');
|
|
134
129
|
}
|
|
135
130
|
|
|
136
131
|
async apiError({ e }: { e: any }): Promise<void> {
|