@switchbot/homebridge-switchbot 3.5.1-beta.12 → 3.5.1-beta.13
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 +57 -45
- 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 +38 -24
- 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 +40 -21
- 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 +42 -31
- 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 +40 -28
- 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 +35 -22
- package/dist/device/curtain.js.map +1 -1
- package/dist/device/device.d.ts +13 -2
- package/dist/device/device.d.ts.map +1 -1
- package/dist/device/device.js +223 -108
- 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 +48 -29
- 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 +43 -26
- 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 +43 -26
- 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 +39 -24
- 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 +43 -27
- 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 +33 -22
- 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 +38 -24
- 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 +37 -24
- 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 +33 -22
- 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 +27 -16
- 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 +34 -21
- 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 +38 -23
- 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 +1 -1
- 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 +0 -11
- package/dist/platform.d.ts.map +1 -1
- package/dist/platform.js +11 -184
- 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 +60 -47
- package/src/device/bot.ts +47 -25
- package/src/device/ceilinglight.ts +52 -21
- package/src/device/colorbulb.ts +45 -31
- package/src/device/contact.ts +43 -28
- package/src/device/curtain.ts +45 -23
- package/src/device/device.ts +226 -96
- package/src/device/fan.ts +61 -30
- package/src/device/hub.ts +55 -29
- package/src/device/humidifier.ts +55 -31
- package/src/device/iosensor.ts +45 -27
- package/src/device/lightstrip.ts +48 -28
- package/src/device/lock.ts +49 -23
- package/src/device/meter.ts +54 -26
- package/src/device/meterplus.ts +50 -26
- package/src/device/motion.ts +45 -24
- package/src/device/plug.ts +34 -17
- package/src/device/robotvacuumcleaner.ts +49 -23
- package/src/device/waterdetector.ts +56 -25
- 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 +1 -1
- 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 +11 -184
- package/src/settings.ts +10 -8
- package/src/types/bledevicestatus.ts +4 -2
- package/src/types/devicestatus.ts +1 -1
|
@@ -35,6 +35,15 @@ export class RobotVacuumCleaner extends deviceBase {
|
|
|
35
35
|
ChargingState: CharacteristicValue;
|
|
36
36
|
};
|
|
37
37
|
|
|
38
|
+
// OpenAPI
|
|
39
|
+
deviceStatus!: robotVacuumCleanerS1Status | robotVacuumCleanerS1PlusStatus | floorCleaningRobotS10Status;
|
|
40
|
+
|
|
41
|
+
//Webhook
|
|
42
|
+
webhookContext!: robotVacuumCleanerS1WebhookContext | robotVacuumCleanerS1PlusWebhookContext | floorCleaningRobotS10WebhookContext;
|
|
43
|
+
|
|
44
|
+
// BLE
|
|
45
|
+
serviceData!: robotVacuumCleanerServiceData;
|
|
46
|
+
|
|
38
47
|
// Updates
|
|
39
48
|
robotVacuumCleanerUpdateInProgress!: boolean;
|
|
40
49
|
doRobotVacuumCleanerUpdate!: Subject<void>;
|
|
@@ -115,12 +124,11 @@ export class RobotVacuumCleaner extends deviceBase {
|
|
|
115
124
|
});
|
|
116
125
|
|
|
117
126
|
// Retrieve initial values and updateHomekit
|
|
127
|
+
this.debugLog('Retrieve initial values and update Homekit');
|
|
118
128
|
this.refreshStatus();
|
|
119
129
|
|
|
120
|
-
// Update Homekit
|
|
121
|
-
this.updateHomeKitCharacteristics();
|
|
122
|
-
|
|
123
130
|
//regisiter webhook event handler
|
|
131
|
+
this.debugLog('Registering Webhook Event Handler');
|
|
124
132
|
this.registerWebhook();
|
|
125
133
|
|
|
126
134
|
// Start an update interval
|
|
@@ -150,39 +158,51 @@ export class RobotVacuumCleaner extends deviceBase {
|
|
|
150
158
|
});
|
|
151
159
|
}
|
|
152
160
|
|
|
153
|
-
async BLEparseStatus(
|
|
161
|
+
async BLEparseStatus(): Promise<void> {
|
|
154
162
|
await this.debugLog('BLEparseStatus');
|
|
163
|
+
await this.debugLog(`(state, battery) = BLE: (${this.serviceData.state}, ${this.serviceData.battery}),`
|
|
164
|
+
+ ` current: (${this.LightBulb.On}, ${this.Battery.BatteryLevel})`);
|
|
165
|
+
|
|
155
166
|
// On
|
|
156
|
-
this.LightBulb.On = serviceData.state === 'on' ? true : false;
|
|
167
|
+
this.LightBulb.On = this.serviceData.state === 'on' ? true : false;
|
|
157
168
|
await this.debugLog(`On: ${this.LightBulb.On}`);
|
|
169
|
+
|
|
158
170
|
// BatteryLevel
|
|
159
|
-
this.Battery.BatteryLevel =
|
|
171
|
+
this.Battery.BatteryLevel = this.serviceData.battery;
|
|
160
172
|
await this.debugLog(`BatteryLevel: ${this.Battery.BatteryLevel}`);
|
|
173
|
+
|
|
161
174
|
// StatusLowBattery
|
|
162
175
|
this.Battery.StatusLowBattery = this.Battery.BatteryLevel < 10
|
|
163
176
|
? this.hap.Characteristic.StatusLowBattery.BATTERY_LEVEL_LOW : this.hap.Characteristic.StatusLowBattery.BATTERY_LEVEL_NORMAL;
|
|
164
177
|
await this.debugLog(`StatusLowBattery: ${this.Battery.StatusLowBattery}`);
|
|
165
178
|
}
|
|
166
179
|
|
|
167
|
-
async openAPIparseStatus(
|
|
180
|
+
async openAPIparseStatus() {
|
|
168
181
|
await this.debugLog('openAPIparseStatus');
|
|
182
|
+
await this.debugLog(`(onlineStatus, battery, workingStatus) = API: (${this.deviceStatus.onlineStatus}, ${this.deviceStatus.battery},`
|
|
183
|
+
+ ` ${this.deviceStatus.workingStatus}), current: (${this.LightBulb.On}, ${this.Battery.BatteryLevel}, ${this.Battery.ChargingState})`);
|
|
184
|
+
|
|
169
185
|
// On
|
|
170
|
-
this.LightBulb.On = deviceStatus.onlineStatus === 'online' ? true : false;
|
|
186
|
+
this.LightBulb.On = this.deviceStatus.onlineStatus === 'online' ? true : false;
|
|
171
187
|
await this.debugLog(`On: ${this.LightBulb.On}`);
|
|
188
|
+
|
|
172
189
|
// BatteryLevel
|
|
173
|
-
this.Battery.BatteryLevel =
|
|
190
|
+
this.Battery.BatteryLevel = this.deviceStatus.battery;
|
|
174
191
|
await this.debugLog(`BatteryLevel: ${this.Battery.BatteryLevel}`);
|
|
192
|
+
|
|
175
193
|
// StatusLowBattery
|
|
176
194
|
this.Battery.StatusLowBattery = this.Battery.BatteryLevel < 10
|
|
177
195
|
? this.hap.Characteristic.StatusLowBattery.BATTERY_LEVEL_LOW : this.hap.Characteristic.StatusLowBattery.BATTERY_LEVEL_NORMAL;
|
|
178
196
|
await this.debugLog(`StatusLowBattery: ${this.Battery.StatusLowBattery}`);
|
|
197
|
+
|
|
179
198
|
// ChargingState
|
|
180
|
-
this.Battery.ChargingState = deviceStatus.workingStatus === 'Charging'
|
|
199
|
+
this.Battery.ChargingState = this.deviceStatus.workingStatus === 'Charging'
|
|
181
200
|
? this.hap.Characteristic.ChargingState.CHARGING : this.hap.Characteristic.ChargingState.NOT_CHARGING;
|
|
182
201
|
await this.debugLog(`ChargingState: ${this.Battery.ChargingState}`);
|
|
202
|
+
|
|
183
203
|
// Firmware Version
|
|
184
|
-
if (deviceStatus.version) {
|
|
185
|
-
const version = deviceStatus.version.toString();
|
|
204
|
+
if (this.deviceStatus.version) {
|
|
205
|
+
const version = this.deviceStatus.version.toString();
|
|
186
206
|
await this.debugLog(`Firmware Version: ${version.replace(/^V|-.*$/g, '')}`);
|
|
187
207
|
const deviceVersion = version.replace(/^V|-.*$/g, '') ?? '0.0.0';
|
|
188
208
|
this.accessory
|
|
@@ -196,23 +216,26 @@ export class RobotVacuumCleaner extends deviceBase {
|
|
|
196
216
|
}
|
|
197
217
|
}
|
|
198
218
|
|
|
199
|
-
async parseStatusWebhook(
|
|
200
|
-
| floorCleaningRobotS10WebhookContext): Promise<void> {
|
|
219
|
+
async parseStatusWebhook(): Promise<void> {
|
|
201
220
|
await this.debugLog('parseStatusWebhook');
|
|
202
|
-
await this.debugLog(`(onlineStatus, battery, workingStatus) = Webhook: (${
|
|
203
|
-
+ ` current: (${this.LightBulb.On}, ${this.Battery.BatteryLevel}, ${this.Battery.ChargingState})`);
|
|
221
|
+
await this.debugLog(`(onlineStatus, battery, workingStatus) = Webhook: (${this.webhookContext.onlineStatus}, ${this.webhookContext.battery},`
|
|
222
|
+
+ ` ${this.webhookContext.workingStatus}), current: (${this.LightBulb.On}, ${this.Battery.BatteryLevel}, ${this.Battery.ChargingState})`);
|
|
223
|
+
|
|
204
224
|
// On
|
|
205
|
-
this.LightBulb.On =
|
|
225
|
+
this.LightBulb.On = this.webhookContext.onlineStatus === 'online' ? true : false;
|
|
206
226
|
await this.debugLog(`On: ${this.LightBulb.On}`);
|
|
227
|
+
|
|
207
228
|
// BatteryLevel
|
|
208
|
-
this.Battery.BatteryLevel =
|
|
229
|
+
this.Battery.BatteryLevel = this.webhookContext.battery;
|
|
209
230
|
await this.debugLog(`BatteryLevel: ${this.Battery.BatteryLevel}`);
|
|
231
|
+
|
|
210
232
|
// StatusLowBattery
|
|
211
233
|
this.Battery.StatusLowBattery = this.Battery.BatteryLevel < 10
|
|
212
234
|
? this.hap.Characteristic.StatusLowBattery.BATTERY_LEVEL_LOW : this.hap.Characteristic.StatusLowBattery.BATTERY_LEVEL_NORMAL;
|
|
213
235
|
await this.debugLog(`StatusLowBattery: ${this.Battery.StatusLowBattery}`);
|
|
236
|
+
|
|
214
237
|
// ChargingState
|
|
215
|
-
this.Battery.ChargingState =
|
|
238
|
+
this.Battery.ChargingState = this.webhookContext.workingStatus === 'Charging'
|
|
216
239
|
? this.hap.Characteristic.ChargingState.CHARGING : this.hap.Characteristic.ChargingState.NOT_CHARGING;
|
|
217
240
|
await this.debugLog(`ChargingState: ${this.Battery.ChargingState}`);
|
|
218
241
|
}
|
|
@@ -246,7 +269,8 @@ export class RobotVacuumCleaner extends deviceBase {
|
|
|
246
269
|
const serviceData = await this.monitorAdvertisementPackets(switchbot) as unknown as robotVacuumCleanerServiceData;
|
|
247
270
|
// Update HomeKit
|
|
248
271
|
if (serviceData.model === SwitchBotBLEModel.Unknown && serviceData.modelName === SwitchBotBLEModelName.Unknown) {
|
|
249
|
-
|
|
272
|
+
this.serviceData = serviceData;
|
|
273
|
+
await this.BLEparseStatus();
|
|
250
274
|
await this.updateHomeKitCharacteristics();
|
|
251
275
|
} else {
|
|
252
276
|
await this.errorLog(`failed to get serviceData, serviceData: ${serviceData}`);
|
|
@@ -264,7 +288,8 @@ export class RobotVacuumCleaner extends deviceBase {
|
|
|
264
288
|
await this.debugLog(`statusCode: ${statusCode}, deviceStatus: ${JSON.stringify(deviceStatus)}`);;
|
|
265
289
|
if (await this.successfulStatusCodes(statusCode, deviceStatus)) {
|
|
266
290
|
await this.debugSuccessLog(`statusCode: ${statusCode}, deviceStatus: ${JSON.stringify(deviceStatus)}`);
|
|
267
|
-
|
|
291
|
+
this.deviceStatus = deviceStatus.body;
|
|
292
|
+
await this.openAPIparseStatus();
|
|
268
293
|
await this.updateHomeKitCharacteristics();
|
|
269
294
|
} else {
|
|
270
295
|
await this.debugWarnLog(`statusCode: ${statusCode}, deviceStatus: ${JSON.stringify(deviceStatus)}`);
|
|
@@ -279,11 +304,12 @@ export class RobotVacuumCleaner extends deviceBase {
|
|
|
279
304
|
async registerWebhook() {
|
|
280
305
|
if (this.device.webhook) {
|
|
281
306
|
await this.debugLog('is listening webhook.');
|
|
282
|
-
this.
|
|
307
|
+
this.webhookEventHandler[this.device.deviceId] = async (context: robotVacuumCleanerS1WebhookContext
|
|
283
308
|
| robotVacuumCleanerS1PlusWebhookContext | floorCleaningRobotS10WebhookContext) => {
|
|
284
309
|
try {
|
|
285
310
|
await this.debugLog(`received Webhook: ${JSON.stringify(context)}`);
|
|
286
|
-
|
|
311
|
+
this.webhookContext = context;
|
|
312
|
+
await this.parseStatusWebhook();
|
|
287
313
|
await this.updateHomeKitCharacteristics();
|
|
288
314
|
} catch (e: any) {
|
|
289
315
|
await this.errorLog(`failed to handle webhook. Received: ${JSON.stringify(context)} Error: ${e}`);
|
|
@@ -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)}`);
|
|
@@ -259,10 +289,11 @@ export class WaterDetector extends deviceBase {
|
|
|
259
289
|
async registerWebhook() {
|
|
260
290
|
if (this.device.webhook) {
|
|
261
291
|
await this.debugLog('is listening webhook.');
|
|
262
|
-
this.
|
|
292
|
+
this.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
|
@@ -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 {
|