@switchbot/homebridge-switchbot 4.1.1-beta.0 → 4.1.1-beta.10
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 +14 -0
- package/config.schema.json +2 -2
- package/dist/device/blindtilt.js +104 -104
- package/dist/device/blindtilt.js.map +1 -1
- package/dist/device/bot.js +86 -86
- package/dist/device/bot.js.map +1 -1
- package/dist/device/ceilinglight.js +98 -98
- package/dist/device/ceilinglight.js.map +1 -1
- package/dist/device/colorbulb.js +140 -140
- package/dist/device/colorbulb.js.map +1 -1
- package/dist/device/contact.js +47 -47
- package/dist/device/contact.js.map +1 -1
- package/dist/device/curtain.d.ts +1 -1
- package/dist/device/curtain.d.ts.map +1 -1
- package/dist/device/curtain.js +95 -93
- package/dist/device/curtain.js.map +1 -1
- package/dist/device/device.d.ts +13 -13
- package/dist/device/device.d.ts.map +1 -1
- package/dist/device/device.js +46 -46
- package/dist/device/device.js.map +1 -1
- package/dist/device/fan.js +96 -96
- package/dist/device/fan.js.map +1 -1
- package/dist/device/hub.js +46 -46
- package/dist/device/hub.js.map +1 -1
- package/dist/device/humidifier.d.ts.map +1 -1
- package/dist/device/humidifier.js +85 -87
- package/dist/device/humidifier.js.map +1 -1
- package/dist/device/iosensor.js +44 -44
- package/dist/device/iosensor.js.map +1 -1
- package/dist/device/lightstrip.js +119 -119
- package/dist/device/lightstrip.js.map +1 -1
- package/dist/device/lock.js +75 -75
- package/dist/device/lock.js.map +1 -1
- package/dist/device/meter.js +44 -44
- package/dist/device/meter.js.map +1 -1
- package/dist/device/meterplus.js +42 -42
- package/dist/device/meterplus.js.map +1 -1
- package/dist/device/meterpro.js +42 -42
- package/dist/device/meterpro.js.map +1 -1
- package/dist/device/motion.js +44 -44
- package/dist/device/motion.js.map +1 -1
- package/dist/device/plug.d.ts.map +1 -1
- package/dist/device/plug.js +60 -60
- package/dist/device/plug.js.map +1 -1
- package/dist/device/robotvacuumcleaner.js +74 -74
- package/dist/device/robotvacuumcleaner.js.map +1 -1
- package/dist/device/waterdetector.d.ts.map +1 -1
- package/dist/device/waterdetector.js +54 -56
- package/dist/device/waterdetector.js.map +1 -1
- package/dist/irdevice/airconditioner.js +31 -31
- package/dist/irdevice/airconditioner.js.map +1 -1
- package/dist/irdevice/airpurifier.js +10 -10
- package/dist/irdevice/airpurifier.js.map +1 -1
- package/dist/irdevice/camera.js +9 -9
- package/dist/irdevice/camera.js.map +1 -1
- package/dist/irdevice/fan.js +11 -11
- package/dist/irdevice/fan.js.map +1 -1
- package/dist/irdevice/irdevice.js +11 -11
- package/dist/irdevice/irdevice.js.map +1 -1
- package/dist/irdevice/light.js +9 -9
- package/dist/irdevice/light.js.map +1 -1
- package/dist/irdevice/other.js +93 -93
- package/dist/irdevice/other.js.map +1 -1
- package/dist/irdevice/tv.js +33 -33
- package/dist/irdevice/tv.js.map +1 -1
- package/dist/irdevice/vacuumcleaner.js +9 -9
- package/dist/irdevice/vacuumcleaner.js.map +1 -1
- package/dist/irdevice/waterheater.js +9 -9
- package/dist/irdevice/waterheater.js.map +1 -1
- package/dist/platform.js +228 -228
- package/dist/platform.js.map +1 -1
- package/docs/functions/default.html +1 -1
- package/package.json +9 -9
- package/src/device/blindtilt.ts +104 -104
- package/src/device/bot.ts +86 -86
- package/src/device/ceilinglight.ts +98 -98
- package/src/device/colorbulb.ts +140 -140
- package/src/device/contact.ts +47 -47
- package/src/device/curtain.ts +95 -93
- package/src/device/device.ts +46 -46
- package/src/device/fan.ts +96 -96
- package/src/device/hub.ts +46 -46
- package/src/device/humidifier.ts +85 -87
- package/src/device/iosensor.ts +44 -44
- package/src/device/lightstrip.ts +119 -119
- package/src/device/lock.ts +75 -75
- package/src/device/meter.ts +44 -44
- package/src/device/meterplus.ts +42 -42
- package/src/device/meterpro.ts +42 -42
- package/src/device/motion.ts +44 -44
- package/src/device/plug.ts +62 -62
- package/src/device/robotvacuumcleaner.ts +74 -74
- package/src/device/waterdetector.ts +54 -55
- package/src/irdevice/airconditioner.ts +31 -31
- package/src/irdevice/airpurifier.ts +10 -10
- package/src/irdevice/camera.ts +9 -9
- package/src/irdevice/fan.ts +11 -11
- package/src/irdevice/irdevice.ts +11 -11
- package/src/irdevice/light.ts +9 -9
- package/src/irdevice/other.ts +93 -93
- package/src/irdevice/tv.ts +33 -33
- package/src/irdevice/vacuumcleaner.ts +9 -9
- package/src/irdevice/waterheater.ts +9 -9
- package/src/platform.ts +228 -228
|
@@ -139,49 +139,48 @@ export class WaterDetector extends deviceBase {
|
|
|
139
139
|
interval(this.deviceRefreshRate * 1000)
|
|
140
140
|
.pipe(skipWhile(() => this.WaterDetectorUpdateInProgress))
|
|
141
141
|
.subscribe(async () => {
|
|
142
|
-
|
|
142
|
+
this.debugLog(`update interval: ${this.deviceRefreshRate * 1000} seconds`)
|
|
143
143
|
await this.refreshStatus()
|
|
144
144
|
})
|
|
145
145
|
}
|
|
146
146
|
|
|
147
147
|
async BLEparseStatus(): Promise<void> {
|
|
148
|
-
|
|
149
|
-
|
|
148
|
+
this.debugLog('BLEparseStatus')
|
|
149
|
+
this.debugLog(`(leak, tampered, battery) = BLE: (${this.serviceData.leak}, ${this.serviceData.tampered}, ${this.serviceData.battery}), current:(${this.LeakSensor?.LeakDetected}, ${this.LeakSensor?.StatusActive}, ${this.Battery.BatteryLevel})`)
|
|
150
150
|
|
|
151
151
|
// LeakSensor
|
|
152
152
|
if (!(this.device as waterDetectorConfig).hide_leak && this.LeakSensor?.Service) {
|
|
153
153
|
// StatusActive
|
|
154
|
-
this.LeakSensor.StatusActive = this.serviceData.
|
|
155
|
-
|
|
154
|
+
this.LeakSensor.StatusActive = this.serviceData.leak
|
|
155
|
+
this.debugLog(`StatusActive: ${this.LeakSensor.StatusActive}`)
|
|
156
156
|
|
|
157
157
|
// LeakDetected
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
this.LeakSensor.LeakDetected = this.serviceData.status
|
|
163
|
-
this.debugLog(`LeakDetected: ${this.LeakSensor.LeakDetected}`)
|
|
164
|
-
}
|
|
158
|
+
this.LeakSensor.LeakDetected = (this.device as waterDetectorConfig).dry
|
|
159
|
+
? this.serviceData.tampered ? 1 : 0
|
|
160
|
+
: this.serviceData.tampered
|
|
161
|
+
this.debugLog(`LeakDetected: ${this.LeakSensor.LeakDetected}`)
|
|
165
162
|
}
|
|
166
163
|
// BatteryLevel
|
|
167
164
|
this.Battery.BatteryLevel = this.serviceData.battery
|
|
168
|
-
|
|
165
|
+
this.debugLog(`BatteryLevel: ${this.Battery.BatteryLevel}`)
|
|
169
166
|
// StatusLowBattery
|
|
170
|
-
this.Battery.StatusLowBattery = this.
|
|
167
|
+
this.Battery.StatusLowBattery = this.serviceData.low_battery
|
|
171
168
|
? this.hap.Characteristic.StatusLowBattery.BATTERY_LEVEL_LOW
|
|
172
|
-
: this.
|
|
173
|
-
|
|
169
|
+
: this.Battery.BatteryLevel < 10
|
|
170
|
+
? this.hap.Characteristic.StatusLowBattery.BATTERY_LEVEL_LOW
|
|
171
|
+
: this.hap.Characteristic.StatusLowBattery.BATTERY_LEVEL_NORMAL
|
|
172
|
+
this.debugLog(`StatusLowBattery: ${this.Battery.StatusLowBattery}`)
|
|
174
173
|
}
|
|
175
174
|
|
|
176
175
|
async openAPIparseStatus(): Promise<void> {
|
|
177
|
-
|
|
178
|
-
|
|
176
|
+
this.debugLog('openAPIparseStatus')
|
|
177
|
+
this.debugLog(`(status, battery) = OpenAPI: (${this.deviceStatus.status}, ${this.deviceStatus.battery}), current:(${this.LeakSensor?.LeakDetected}, ${this.Battery.BatteryLevel})`)
|
|
179
178
|
|
|
180
179
|
// LeakSensor
|
|
181
180
|
if (!(this.device as waterDetectorConfig).hide_leak && this.LeakSensor?.Service) {
|
|
182
181
|
// StatusActive
|
|
183
182
|
this.LeakSensor.StatusActive = this.deviceStatus.battery !== 0
|
|
184
|
-
|
|
183
|
+
this.debugLog(`StatusActive: ${this.LeakSensor.StatusActive}`)
|
|
185
184
|
|
|
186
185
|
// LeakDetected
|
|
187
186
|
if ((this.device as waterDetectorConfig).dry) {
|
|
@@ -195,18 +194,18 @@ export class WaterDetector extends deviceBase {
|
|
|
195
194
|
|
|
196
195
|
// BatteryLevel
|
|
197
196
|
this.Battery.BatteryLevel = this.deviceStatus.battery
|
|
198
|
-
|
|
197
|
+
this.debugLog(`BatteryLevel: ${this.Battery.BatteryLevel}`)
|
|
199
198
|
|
|
200
199
|
// StatusLowBattery
|
|
201
200
|
this.Battery.StatusLowBattery = this.Battery.BatteryLevel < 10
|
|
202
201
|
? this.hap.Characteristic.StatusLowBattery.BATTERY_LEVEL_LOW
|
|
203
202
|
: this.hap.Characteristic.StatusLowBattery.BATTERY_LEVEL_NORMAL
|
|
204
|
-
|
|
203
|
+
this.debugLog(`StatusLowBattery: ${this.Battery.StatusLowBattery}`)
|
|
205
204
|
|
|
206
205
|
// FirmwareVersion
|
|
207
206
|
if (this.deviceStatus.version) {
|
|
208
207
|
const version = this.deviceStatus.version.toString()
|
|
209
|
-
|
|
208
|
+
this.debugLog(`FirmwareVersion: ${version.replace(/^V|-.*$/g, '')}`)
|
|
210
209
|
const deviceVersion = version.replace(/^V|-.*$/g, '') ?? '0.0.0'
|
|
211
210
|
this.accessory
|
|
212
211
|
.getService(this.hap.Service.AccessoryInformation)!
|
|
@@ -215,19 +214,19 @@ export class WaterDetector extends deviceBase {
|
|
|
215
214
|
.getCharacteristic(this.hap.Characteristic.FirmwareRevision)
|
|
216
215
|
.updateValue(deviceVersion)
|
|
217
216
|
this.accessory.context.version = deviceVersion
|
|
218
|
-
|
|
217
|
+
this.debugSuccessLog(`version: ${this.accessory.context.version}`)
|
|
219
218
|
}
|
|
220
219
|
}
|
|
221
220
|
|
|
222
221
|
async parseStatusWebhook(): Promise<void> {
|
|
223
|
-
|
|
224
|
-
|
|
222
|
+
this.debugLog('parseStatusWebhook')
|
|
223
|
+
this.debugLog(`(detectionState, battery) = Webhook: (${this.webhookContext.detectionState}, ${this.webhookContext.battery}), current:(${this.LeakSensor?.LeakDetected}, ${this.Battery.BatteryLevel})`)
|
|
225
224
|
|
|
226
225
|
// LeakSensor
|
|
227
226
|
if (!(this.device as waterDetectorConfig).hide_leak && this.LeakSensor?.Service) {
|
|
228
227
|
// StatusActive
|
|
229
228
|
this.LeakSensor.StatusActive = !!this.webhookContext.detectionState
|
|
230
|
-
|
|
229
|
+
this.debugLog(`StatusActive: ${this.LeakSensor.StatusActive}`)
|
|
231
230
|
|
|
232
231
|
// LeakDetected
|
|
233
232
|
if ((this.device as waterDetectorConfig).dry) {
|
|
@@ -235,19 +234,19 @@ export class WaterDetector extends deviceBase {
|
|
|
235
234
|
this.debugLog(`LeakDetected: ${this.LeakSensor.LeakDetected}`)
|
|
236
235
|
} else {
|
|
237
236
|
this.LeakSensor.LeakDetected = this.webhookContext.detectionState
|
|
238
|
-
|
|
237
|
+
this.debugLog(`LeakDetected: ${this.LeakSensor.LeakDetected}`)
|
|
239
238
|
}
|
|
240
239
|
}
|
|
241
240
|
|
|
242
241
|
// BatteryLevel
|
|
243
242
|
this.Battery.BatteryLevel = this.webhookContext.battery
|
|
244
|
-
|
|
243
|
+
this.debugLog(`BatteryLevel: ${this.Battery.BatteryLevel}`)
|
|
245
244
|
|
|
246
245
|
// StatusLowBattery
|
|
247
246
|
this.Battery.StatusLowBattery = this.Battery.BatteryLevel < 10
|
|
248
247
|
? this.hap.Characteristic.StatusLowBattery.BATTERY_LEVEL_LOW
|
|
249
248
|
: this.hap.Characteristic.StatusLowBattery.BATTERY_LEVEL_NORMAL
|
|
250
|
-
|
|
249
|
+
this.debugLog(`StatusLowBattery: ${this.Battery.StatusLowBattery}`)
|
|
251
250
|
}
|
|
252
251
|
|
|
253
252
|
/**
|
|
@@ -255,19 +254,19 @@ export class WaterDetector extends deviceBase {
|
|
|
255
254
|
*/
|
|
256
255
|
async refreshStatus(): Promise<void> {
|
|
257
256
|
if (!this.device.enableCloudService && this.OpenAPI) {
|
|
258
|
-
|
|
257
|
+
this.errorLog(`refreshStatus enableCloudService: ${this.device.enableCloudService}`)
|
|
259
258
|
} else if (this.BLE) {
|
|
260
259
|
await this.BLERefreshStatus()
|
|
261
260
|
} else if (this.OpenAPI && this.platform.config.credentials?.token) {
|
|
262
261
|
await this.openAPIRefreshStatus()
|
|
263
262
|
} else {
|
|
264
263
|
await this.offlineOff()
|
|
265
|
-
|
|
264
|
+
this.debugWarnLog(`Connection Type: ${this.device.connectionType}, refreshStatus will not happen.`)
|
|
266
265
|
}
|
|
267
266
|
}
|
|
268
267
|
|
|
269
268
|
async BLERefreshStatus(): Promise<void> {
|
|
270
|
-
|
|
269
|
+
this.debugLog('BLERefreshStatus')
|
|
271
270
|
const switchBotBLE = await this.switchbotBLE()
|
|
272
271
|
if (switchBotBLE === undefined) {
|
|
273
272
|
await this.BLERefreshConnection(switchBotBLE)
|
|
@@ -277,12 +276,12 @@ export class WaterDetector extends deviceBase {
|
|
|
277
276
|
// Start to monitor advertisement packets
|
|
278
277
|
const serviceData = await this.monitorAdvertisementPackets(switchBotBLE) as waterLeakDetectorServiceData
|
|
279
278
|
// Update HomeKit
|
|
280
|
-
if (serviceData.model === SwitchBotBLEModel.
|
|
279
|
+
if (serviceData.model === SwitchBotBLEModel.Leak && serviceData.modelName === SwitchBotBLEModelName.Leak) {
|
|
281
280
|
this.serviceData = serviceData
|
|
282
281
|
await this.BLEparseStatus()
|
|
283
282
|
await this.updateHomeKitCharacteristics()
|
|
284
283
|
} else {
|
|
285
|
-
|
|
284
|
+
this.errorLog(`failed to get serviceData, serviceData: ${JSON.stringify(serviceData)}`)
|
|
286
285
|
await this.BLERefreshConnection(switchBotBLE)
|
|
287
286
|
}
|
|
288
287
|
})()
|
|
@@ -290,67 +289,67 @@ export class WaterDetector extends deviceBase {
|
|
|
290
289
|
}
|
|
291
290
|
|
|
292
291
|
async registerPlatformBLE(): Promise<void> {
|
|
293
|
-
|
|
292
|
+
this.debugLog('registerPlatformBLE')
|
|
294
293
|
if (this.config.options?.BLE) {
|
|
295
|
-
|
|
294
|
+
this.debugLog('is listening to Platform BLE.')
|
|
296
295
|
try {
|
|
297
296
|
const formattedDeviceId = formatDeviceIdAsMac(this.device.deviceId)
|
|
298
297
|
this.device.bleMac = formattedDeviceId
|
|
299
|
-
|
|
298
|
+
this.debugLog(`bleMac: ${this.device.bleMac}`)
|
|
300
299
|
this.platform.bleEventHandler[this.device.bleMac] = async (context: waterLeakDetectorServiceData) => {
|
|
301
300
|
try {
|
|
302
|
-
|
|
301
|
+
this.debugLog(`received BLE: ${JSON.stringify(context)}`)
|
|
303
302
|
this.serviceData = context
|
|
304
303
|
await this.BLEparseStatus()
|
|
305
304
|
await this.updateHomeKitCharacteristics()
|
|
306
305
|
} catch (e: any) {
|
|
307
|
-
|
|
306
|
+
this.errorLog(`failed to handle BLE. Received: ${JSON.stringify(context)} Error: ${e.message ?? e}`)
|
|
308
307
|
}
|
|
309
308
|
}
|
|
310
309
|
} catch (error) {
|
|
311
|
-
|
|
310
|
+
this.errorLog(`failed to format device ID as MAC, Error: ${error}`)
|
|
312
311
|
}
|
|
313
312
|
} else {
|
|
314
|
-
|
|
313
|
+
this.debugLog('is not listening to Platform BLE')
|
|
315
314
|
}
|
|
316
315
|
}
|
|
317
316
|
|
|
318
317
|
async openAPIRefreshStatus(): Promise<void> {
|
|
319
|
-
|
|
318
|
+
this.debugLog('openAPIRefreshStatus')
|
|
320
319
|
try {
|
|
321
|
-
const
|
|
322
|
-
const deviceStatus: any =
|
|
323
|
-
|
|
320
|
+
const response = await this.deviceRefreshStatus()
|
|
321
|
+
const deviceStatus: any = response.body
|
|
322
|
+
this.debugLog(`statusCode: ${deviceStatus.statusCode}, deviceStatus: ${JSON.stringify(deviceStatus)}`)
|
|
324
323
|
if (await this.successfulStatusCodes(deviceStatus)) {
|
|
325
|
-
|
|
324
|
+
this.debugSuccessLog(`statusCode: ${deviceStatus.statusCode}, deviceStatus: ${JSON.stringify(deviceStatus)}`)
|
|
326
325
|
this.deviceStatus = deviceStatus.body
|
|
327
326
|
await this.openAPIparseStatus()
|
|
328
327
|
await this.updateHomeKitCharacteristics()
|
|
329
328
|
} else {
|
|
330
|
-
|
|
331
|
-
|
|
329
|
+
this.debugWarnLog(`statusCode: ${deviceStatus.statusCode}, deviceStatus: ${JSON.stringify(deviceStatus)}`)
|
|
330
|
+
this.debugWarnLog(deviceStatus)
|
|
332
331
|
}
|
|
333
332
|
} catch (e: any) {
|
|
334
333
|
await this.apiError(e)
|
|
335
|
-
|
|
334
|
+
this.errorLog(`failed openAPIRefreshStatus with ${this.device.connectionType} Connection, Error Message: ${JSON.stringify(e.message)}`)
|
|
336
335
|
}
|
|
337
336
|
}
|
|
338
337
|
|
|
339
338
|
async registerWebhook() {
|
|
340
339
|
if (this.device.webhook) {
|
|
341
|
-
|
|
340
|
+
this.debugLog('is listening webhook.')
|
|
342
341
|
this.platform.webhookEventHandler[this.device.deviceId] = async (context: waterLeakDetectorWebhookContext) => {
|
|
343
342
|
try {
|
|
344
|
-
|
|
343
|
+
this.debugLog(`received Webhook: ${JSON.stringify(context)}`)
|
|
345
344
|
this.webhookContext = context
|
|
346
345
|
await this.parseStatusWebhook()
|
|
347
346
|
await this.updateHomeKitCharacteristics()
|
|
348
347
|
} catch (e: any) {
|
|
349
|
-
|
|
348
|
+
this.errorLog(`failed to handle webhook. Received: ${JSON.stringify(context)} Error: ${e.message ?? e}`)
|
|
350
349
|
}
|
|
351
350
|
}
|
|
352
351
|
} else {
|
|
353
|
-
|
|
352
|
+
this.debugLog('is not listening webhook.')
|
|
354
353
|
}
|
|
355
354
|
}
|
|
356
355
|
|
|
@@ -371,9 +370,9 @@ export class WaterDetector extends deviceBase {
|
|
|
371
370
|
}
|
|
372
371
|
|
|
373
372
|
async BLERefreshConnection(switchbot: any): Promise<void> {
|
|
374
|
-
|
|
373
|
+
this.errorLog(`wasn't able to establish BLE Connection, node-switchbot: ${switchbot}`)
|
|
375
374
|
if (this.platform.config.credentials?.token && this.device.connectionType === 'BLE/OpenAPI') {
|
|
376
|
-
|
|
375
|
+
this.warnLog('Using OpenAPI Connection to Refresh Status')
|
|
377
376
|
await this.openAPIRefreshStatus()
|
|
378
377
|
}
|
|
379
378
|
}
|
|
@@ -158,7 +158,7 @@ export class AirConditioner extends irdeviceBase {
|
|
|
158
158
|
* AirConditioner: "command" "highSpeed" "default" = fan speed to high
|
|
159
159
|
*/
|
|
160
160
|
async pushAirConditionerOnChanges(): Promise<void> {
|
|
161
|
-
|
|
161
|
+
this.debugLog(`pushAirConditionerOnChanges Active: ${this.HeaterCooler.Active}, disablePushOn: ${this.disablePushOn}`)
|
|
162
162
|
if (this.HeaterCooler.Active === this.hap.Characteristic.Active.ACTIVE && !this.disablePushOn) {
|
|
163
163
|
const commandType: string = await this.commandType()
|
|
164
164
|
const command: string = await this.commandOn()
|
|
@@ -172,7 +172,7 @@ export class AirConditioner extends irdeviceBase {
|
|
|
172
172
|
}
|
|
173
173
|
|
|
174
174
|
async pushAirConditionerOffChanges(): Promise<void> {
|
|
175
|
-
|
|
175
|
+
this.debugLog(`pushAirConditionerOffChanges Active: ${this.HeaterCooler.Active}, disablePushOff: ${this.disablePushOff}`)
|
|
176
176
|
if (this.HeaterCooler.Active === this.hap.Characteristic.Active.INACTIVE && !this.disablePushOff) {
|
|
177
177
|
const commandType: string = await this.commandType()
|
|
178
178
|
const command: string = await this.commandOff()
|
|
@@ -186,7 +186,7 @@ export class AirConditioner extends irdeviceBase {
|
|
|
186
186
|
}
|
|
187
187
|
|
|
188
188
|
async pushAirConditionerStatusChanges(): Promise<void> {
|
|
189
|
-
|
|
189
|
+
this.debugLog(`pushAirConditionerStatusChanges Active: ${this.HeaterCooler.Active}, disablePushOff: ${this.disablePushOff}, disablePushOn: ${this.disablePushOn}`)
|
|
190
190
|
if (!this.Busy) {
|
|
191
191
|
this.Busy = true
|
|
192
192
|
this.HeaterCooler.CurrentHeaterCoolerState = this.hap.Characteristic.CurrentHeaterCoolerState.IDLE
|
|
@@ -198,7 +198,7 @@ export class AirConditioner extends irdeviceBase {
|
|
|
198
198
|
}
|
|
199
199
|
|
|
200
200
|
async pushAirConditionerDetailsChanges(): Promise<void> {
|
|
201
|
-
|
|
201
|
+
this.debugLog(`pushAirConditionerDetailsChanges Active: ${this.HeaterCooler.Active}, disablePushOff: ${this.disablePushOff}, disablePushOn: ${this.disablePushOn}`)
|
|
202
202
|
// await this.deviceContext();
|
|
203
203
|
if (this.CurrentMode === undefined) {
|
|
204
204
|
this.CurrentMode = 1
|
|
@@ -214,7 +214,7 @@ export class AirConditioner extends irdeviceBase {
|
|
|
214
214
|
if (this.CurrentMode === 1) {
|
|
215
215
|
// Remove or make configurable?
|
|
216
216
|
this.HeaterCooler.ThresholdTemperature = 25
|
|
217
|
-
|
|
217
|
+
this.debugLog(`CurrentMode: ${this.CurrentMode}, ThresholdTemperature: ${this.HeaterCooler.ThresholdTemperature}`)
|
|
218
218
|
}
|
|
219
219
|
const parameter = `${this.HeaterCooler.ThresholdTemperature},${this.CurrentMode},${this.CurrentFanSpeed},${this.state}`
|
|
220
220
|
|
|
@@ -312,12 +312,12 @@ export class AirConditioner extends irdeviceBase {
|
|
|
312
312
|
}
|
|
313
313
|
|
|
314
314
|
async pushChanges(bodyChange: any): Promise<void> {
|
|
315
|
-
|
|
315
|
+
this.debugLog('pushChanges')
|
|
316
316
|
if (this.device.connectionType === 'OpenAPI' && !this.disablePushDetail) {
|
|
317
|
-
|
|
317
|
+
this.infoLog(`Sending request to SwitchBot API, body: ${JSON.stringify(bodyChange)}`)
|
|
318
318
|
try {
|
|
319
|
-
const
|
|
320
|
-
const deviceStatus: any =
|
|
319
|
+
const response = await this.pushChangeRequest(bodyChange)
|
|
320
|
+
const deviceStatus: any = response.body
|
|
321
321
|
await this.pushStatusCodes(deviceStatus)
|
|
322
322
|
if (await this.successfulStatusCodes(deviceStatus)) {
|
|
323
323
|
await this.successfulPushChange(deviceStatus, bodyChange)
|
|
@@ -330,8 +330,8 @@ export class AirConditioner extends irdeviceBase {
|
|
|
330
330
|
await this.pushChangeError(e)
|
|
331
331
|
}
|
|
332
332
|
} else {
|
|
333
|
-
|
|
334
|
-
|
|
333
|
+
this.warnLog(`Connection Type: ${this.device.connectionType}, commands will not be sent to OpenAPI`)
|
|
334
|
+
this.debugLog(`Connection Type: ${this.device.connectionType}, disablePushDetails: ${this.disablePushDetail}`)
|
|
335
335
|
await this.updateHomeKitCharacteristics()
|
|
336
336
|
}
|
|
337
337
|
}
|
|
@@ -339,22 +339,22 @@ export class AirConditioner extends irdeviceBase {
|
|
|
339
339
|
async CurrentTemperatureGet(): Promise<CharacteristicValue> {
|
|
340
340
|
if (this.meter?.context?.CurrentTemperature) {
|
|
341
341
|
this.accessory.context.CurrentTemperature = this.meter.context.CurrentTemperature
|
|
342
|
-
|
|
342
|
+
this.debugLog(`Using CurrentTemperature from ${this.meter.context.deviceType} (${this.meter.context.deviceId})`)
|
|
343
343
|
}
|
|
344
344
|
|
|
345
345
|
this.HeaterCooler.CurrentTemperature = this.accessory.context.CurrentTemperature || 24
|
|
346
|
-
|
|
346
|
+
this.debugLog(`Get CurrentTemperature: ${this.HeaterCooler.CurrentTemperature}`)
|
|
347
347
|
return this.HeaterCooler.CurrentTemperature
|
|
348
348
|
}
|
|
349
349
|
|
|
350
350
|
async CurrentRelativeHumidityGet(): Promise<CharacteristicValue> {
|
|
351
351
|
if (this.meter?.context?.CurrentRelativeHumidity) {
|
|
352
352
|
this.accessory.context.CurrentRelativeHumidity = this.meter.context.CurrentRelativeHumidity
|
|
353
|
-
|
|
353
|
+
this.debugLog(`Using CurrentRelativeHumidity from ${this.meter.context.deviceType} (${this.meter.context.deviceId})`)
|
|
354
354
|
}
|
|
355
355
|
|
|
356
356
|
this.HumiditySensor!.CurrentRelativeHumidity = this.accessory.context.CurrentRelativeHumidity || 0
|
|
357
|
-
|
|
357
|
+
this.debugLog(`Get CurrentRelativeHumidity: ${this.HumiditySensor!.CurrentRelativeHumidity}`)
|
|
358
358
|
return this.HumiditySensor!.CurrentRelativeHumidity as CharacteristicValue
|
|
359
359
|
}
|
|
360
360
|
|
|
@@ -364,7 +364,7 @@ export class AirConditioner extends irdeviceBase {
|
|
|
364
364
|
} else {
|
|
365
365
|
this.HeaterCooler.RotationSpeed = this.CurrentFanSpeed - 1
|
|
366
366
|
}
|
|
367
|
-
|
|
367
|
+
this.debugLog(`Get RotationSpeed: ${this.HeaterCooler.RotationSpeed}`)
|
|
368
368
|
return this.HeaterCooler.RotationSpeed
|
|
369
369
|
}
|
|
370
370
|
|
|
@@ -375,23 +375,23 @@ export class AirConditioner extends irdeviceBase {
|
|
|
375
375
|
this.CurrentFanSpeed = Number(value) + 1
|
|
376
376
|
}
|
|
377
377
|
this.HeaterCooler.RotationSpeed = value
|
|
378
|
-
|
|
378
|
+
this.debugLog(`Set RotationSpeed: ${this.HeaterCooler.RotationSpeed}, CurrentFanSpeed: ${this.CurrentFanSpeed}`)
|
|
379
379
|
this.pushAirConditionerStatusChanges()
|
|
380
380
|
}
|
|
381
381
|
|
|
382
382
|
async ActiveSet(value: CharacteristicValue): Promise<void> {
|
|
383
|
-
|
|
383
|
+
this.debugLog(`Set Active: ${value}`)
|
|
384
384
|
|
|
385
385
|
this.HeaterCooler.Active = value
|
|
386
386
|
if (this.HeaterCooler.Active === this.hap.Characteristic.Active.ACTIVE) {
|
|
387
|
-
|
|
387
|
+
this.debugLog(`pushAirConditionerOnChanges, Active: ${this.HeaterCooler.Active}`)
|
|
388
388
|
if (this.disablePushOn) {
|
|
389
389
|
this.pushAirConditionerStatusChanges()
|
|
390
390
|
} else {
|
|
391
391
|
this.pushAirConditionerOnChanges()
|
|
392
392
|
}
|
|
393
393
|
} else {
|
|
394
|
-
|
|
394
|
+
this.debugLog(`pushAirConditionerOffChanges, Active: ${this.HeaterCooler.Active}`)
|
|
395
395
|
this.pushAirConditionerOffChanges()
|
|
396
396
|
}
|
|
397
397
|
}
|
|
@@ -399,7 +399,7 @@ export class AirConditioner extends irdeviceBase {
|
|
|
399
399
|
async TargetHeaterCoolerStateGet(): Promise<CharacteristicValue> {
|
|
400
400
|
const targetState = this.HeaterCooler.TargetHeaterCoolerState || this.accessory.context.TargetHeaterCoolerState
|
|
401
401
|
this.HeaterCooler.TargetHeaterCoolerState = this.ValidValues.includes(targetState) ? targetState : this.ValidValues[0]
|
|
402
|
-
|
|
402
|
+
this.debugLog(`Get (${this.getTargetHeaterCoolerStateName()}) TargetHeaterCoolerState: ${this.HeaterCooler.TargetHeaterCoolerState}, ValidValues: ${this.ValidValues}, hide_automode: ${this.hide_automode}`)
|
|
403
403
|
return this.HeaterCooler.TargetHeaterCoolerState
|
|
404
404
|
}
|
|
405
405
|
|
|
@@ -419,27 +419,27 @@ export class AirConditioner extends irdeviceBase {
|
|
|
419
419
|
async TargetHeaterCoolerStateAUTO(): Promise<void> {
|
|
420
420
|
this.HeaterCooler.TargetHeaterCoolerState = this.hap.Characteristic.TargetHeaterCoolerState.AUTO
|
|
421
421
|
this.CurrentMode = 1
|
|
422
|
-
|
|
423
|
-
|
|
422
|
+
this.debugLog(`Set (AUTO) TargetHeaterCoolerState: ${this.HeaterCooler.TargetHeaterCoolerState}`)
|
|
423
|
+
this.debugLog(`Switchbot CurrentMode: ${this.CurrentMode}`)
|
|
424
424
|
}
|
|
425
425
|
|
|
426
426
|
async TargetHeaterCoolerStateCOOL(): Promise<void> {
|
|
427
427
|
this.HeaterCooler.TargetHeaterCoolerState = this.hap.Characteristic.TargetHeaterCoolerState.COOL
|
|
428
428
|
this.CurrentMode = 2
|
|
429
|
-
|
|
430
|
-
|
|
429
|
+
this.debugLog(`Set (COOL) TargetHeaterCoolerState: ${this.HeaterCooler.TargetHeaterCoolerState}`)
|
|
430
|
+
this.debugLog(`Switchbot CurrentMode: ${this.CurrentMode}`)
|
|
431
431
|
}
|
|
432
432
|
|
|
433
433
|
async TargetHeaterCoolerStateHEAT(): Promise<void> {
|
|
434
434
|
this.HeaterCooler.TargetHeaterCoolerState = this.hap.Characteristic.TargetHeaterCoolerState.HEAT
|
|
435
435
|
this.CurrentMode = 5
|
|
436
|
-
|
|
437
|
-
|
|
436
|
+
this.debugLog(`Set (HEAT) TargetHeaterCoolerState: ${this.HeaterCooler.TargetHeaterCoolerState}`)
|
|
437
|
+
this.debugLog(`Switchbot CurrentMode: ${this.CurrentMode}`)
|
|
438
438
|
}
|
|
439
439
|
|
|
440
440
|
async CurrentHeaterCoolerStateGet(): Promise<CharacteristicValue> {
|
|
441
441
|
await this.UpdateCurrentHeaterCoolerState()
|
|
442
|
-
|
|
442
|
+
this.debugLog(`Get (${this.getTargetHeaterCoolerStateName()}) CurrentHeaterCoolerState: ${this.HeaterCooler.CurrentHeaterCoolerState}`)
|
|
443
443
|
|
|
444
444
|
return this.HeaterCooler.CurrentHeaterCoolerState
|
|
445
445
|
}
|
|
@@ -481,18 +481,18 @@ export class AirConditioner extends irdeviceBase {
|
|
|
481
481
|
? 0
|
|
482
482
|
: this.HumiditySensor.CurrentRelativeHumidity ?? this.accessory.context.CurrentRelativeHumidity
|
|
483
483
|
}
|
|
484
|
-
|
|
484
|
+
this.debugLog(`Get ThresholdTemperature: ${this.HeaterCooler.ThresholdTemperature}`)
|
|
485
485
|
return this.HeaterCooler.ThresholdTemperature
|
|
486
486
|
}
|
|
487
487
|
|
|
488
488
|
async ThresholdTemperatureSet(value: CharacteristicValue): Promise<void> {
|
|
489
489
|
this.HeaterCooler.ThresholdTemperature = value
|
|
490
|
-
|
|
490
|
+
this.debugLog(`Set ThresholdTemperature: ${this.HeaterCooler.ThresholdTemperature}, ThresholdTemperatureCached: ${this.accessory.context.ThresholdTemperature}`)
|
|
491
491
|
this.pushAirConditionerStatusChanges()
|
|
492
492
|
}
|
|
493
493
|
|
|
494
494
|
async updateHomeKitCharacteristics(): Promise<void> {
|
|
495
|
-
|
|
495
|
+
this.debugLog('updateHomeKitCharacteristics')
|
|
496
496
|
// Active
|
|
497
497
|
await this.updateCharacteristic(this.HeaterCooler.Service, this.hap.Characteristic.Active, this.HeaterCooler.Active, 'Active')
|
|
498
498
|
// RotationSpeed
|
|
@@ -98,7 +98,7 @@ export class AirPurifier extends irdeviceBase {
|
|
|
98
98
|
}
|
|
99
99
|
|
|
100
100
|
async ActiveSet(value: CharacteristicValue): Promise<void> {
|
|
101
|
-
|
|
101
|
+
this.debugLog(`Set Active: ${value}`)
|
|
102
102
|
|
|
103
103
|
this.AirPurifier.Active = value
|
|
104
104
|
if (this.AirPurifier.Active === this.hap.Characteristic.Active.ACTIVE) {
|
|
@@ -145,7 +145,7 @@ export class AirPurifier extends irdeviceBase {
|
|
|
145
145
|
* AirPurifier: "command" "highSpeed" "default" = fan speed to high
|
|
146
146
|
*/
|
|
147
147
|
async pushAirPurifierOnChanges(): Promise<void> {
|
|
148
|
-
|
|
148
|
+
this.debugLog(`pushAirPurifierOnChanges Active: ${this.AirPurifier.Active}, disablePushOn: ${this.disablePushOn}`)
|
|
149
149
|
if (this.AirPurifier.Active === this.hap.Characteristic.Active.ACTIVE && !this.disablePushOn) {
|
|
150
150
|
const commandType: string = await this.commandType()
|
|
151
151
|
const command: string = await this.commandOn()
|
|
@@ -159,7 +159,7 @@ export class AirPurifier extends irdeviceBase {
|
|
|
159
159
|
}
|
|
160
160
|
|
|
161
161
|
async pushAirPurifierOffChanges(): Promise<void> {
|
|
162
|
-
|
|
162
|
+
this.debugLog(`pushAirPurifierOffChanges Active: ${this.AirPurifier.Active}, disablePushOff: ${this.disablePushOff}`)
|
|
163
163
|
if (this.AirPurifier.Active === this.hap.Characteristic.Active.INACTIVE && !this.disablePushOn) {
|
|
164
164
|
const commandType: string = await this.commandType()
|
|
165
165
|
const command: string = await this.commandOff()
|
|
@@ -173,7 +173,7 @@ export class AirPurifier extends irdeviceBase {
|
|
|
173
173
|
}
|
|
174
174
|
|
|
175
175
|
async pushAirPurifierStatusChanges(): Promise<void> {
|
|
176
|
-
|
|
176
|
+
this.debugLog(`pushAirPurifierStatusChanges Active: ${this.AirPurifier.Active}, disablePushOff: ${this.disablePushOff}, disablePushOn: ${this.disablePushOn}`)
|
|
177
177
|
if (!this.Busy) {
|
|
178
178
|
this.Busy = true
|
|
179
179
|
this.AirPurifier.CurrentHeaterCoolerState = this.hap.Characteristic.CurrentHeaterCoolerState.IDLE
|
|
@@ -185,7 +185,7 @@ export class AirPurifier extends irdeviceBase {
|
|
|
185
185
|
}
|
|
186
186
|
|
|
187
187
|
async pushAirPurifierDetailsChanges(): Promise<void> {
|
|
188
|
-
|
|
188
|
+
this.debugLog(`pushAirPurifierDetailsChanges Active: ${this.AirPurifier.Active}, disablePushOff: ${this.disablePushOff}, disablePushOn: ${this.disablePushOn}`)
|
|
189
189
|
this.CurrentAPTemp = this.TemperatureSensor!.CurrentTemperature ?? 24
|
|
190
190
|
this.CurrentAPMode = this.CurrentMode ?? 1
|
|
191
191
|
this.CurrentAPFanSpeed = this.CurrentFanSpeed ?? 1
|
|
@@ -209,12 +209,12 @@ export class AirPurifier extends irdeviceBase {
|
|
|
209
209
|
}
|
|
210
210
|
|
|
211
211
|
async pushChanges(bodyChange: any): Promise<void> {
|
|
212
|
-
|
|
212
|
+
this.debugLog('pushChanges')
|
|
213
213
|
if (this.device.connectionType === 'OpenAPI') {
|
|
214
|
-
|
|
214
|
+
this.infoLog(`Sending request to SwitchBot API, body: ${JSON.stringify(bodyChange)}`)
|
|
215
215
|
try {
|
|
216
|
-
const
|
|
217
|
-
const deviceStatus: any =
|
|
216
|
+
const response = await this.pushChangeRequest(bodyChange)
|
|
217
|
+
const deviceStatus: any = response.body
|
|
218
218
|
await this.pushStatusCodes(deviceStatus)
|
|
219
219
|
if (await this.successfulStatusCodes(deviceStatus)) {
|
|
220
220
|
await this.successfulPushChange(deviceStatus, bodyChange)
|
|
@@ -232,7 +232,7 @@ export class AirPurifier extends irdeviceBase {
|
|
|
232
232
|
}
|
|
233
233
|
|
|
234
234
|
async updateHomeKitCharacteristics(): Promise<void> {
|
|
235
|
-
|
|
235
|
+
this.debugLog('updateHomeKitCharacteristics')
|
|
236
236
|
// Active
|
|
237
237
|
await this.updateCharacteristic(this.AirPurifier.Service, this.hap.Characteristic.Active, this.AirPurifier.Active, 'Active')
|
|
238
238
|
// CurrentAirPurifierState
|
package/src/irdevice/camera.ts
CHANGED
|
@@ -47,7 +47,7 @@ export class Camera extends irdeviceBase {
|
|
|
47
47
|
}
|
|
48
48
|
|
|
49
49
|
async OnSet(value: CharacteristicValue): Promise<void> {
|
|
50
|
-
|
|
50
|
+
this.debugLog(`On: ${value}`)
|
|
51
51
|
|
|
52
52
|
this.Switch.On = value
|
|
53
53
|
if (this.Switch.On) {
|
|
@@ -68,7 +68,7 @@ export class Camera extends irdeviceBase {
|
|
|
68
68
|
* Camera - "command" "channelSub" "default" = previous channel
|
|
69
69
|
*/
|
|
70
70
|
async pushOnChanges(): Promise<void> {
|
|
71
|
-
|
|
71
|
+
this.debugLog(`pushOnChanges On: ${this.Switch.On}, disablePushOn: ${this.disablePushOn}`)
|
|
72
72
|
if (this.Switch.On && !this.disablePushOn) {
|
|
73
73
|
const commandType: string = await this.commandType()
|
|
74
74
|
const command: string = await this.commandOn()
|
|
@@ -82,7 +82,7 @@ export class Camera extends irdeviceBase {
|
|
|
82
82
|
}
|
|
83
83
|
|
|
84
84
|
async pushOffChanges(): Promise<void> {
|
|
85
|
-
|
|
85
|
+
this.debugLog(`pushOffChanges On: ${this.Switch.On}, disablePushOff: ${this.disablePushOff}`)
|
|
86
86
|
if (!this.Switch.On && !this.disablePushOff) {
|
|
87
87
|
const commandType: string = await this.commandType()
|
|
88
88
|
const command: string = await this.commandOff()
|
|
@@ -96,12 +96,12 @@ export class Camera extends irdeviceBase {
|
|
|
96
96
|
}
|
|
97
97
|
|
|
98
98
|
async pushChanges(bodyChange: any): Promise<void> {
|
|
99
|
-
|
|
99
|
+
this.debugLog('pushChanges')
|
|
100
100
|
if (this.device.connectionType === 'OpenAPI') {
|
|
101
|
-
|
|
101
|
+
this.infoLog(`Sending request to SwitchBot API, body: ${JSON.stringify(bodyChange)}`)
|
|
102
102
|
try {
|
|
103
|
-
const
|
|
104
|
-
const deviceStatus: any =
|
|
103
|
+
const response = await this.pushChangeRequest(bodyChange)
|
|
104
|
+
const deviceStatus: any = response.body
|
|
105
105
|
await this.pushStatusCodes(deviceStatus)
|
|
106
106
|
if (await this.successfulStatusCodes(deviceStatus)) {
|
|
107
107
|
await this.successfulPushChange(deviceStatus, bodyChange)
|
|
@@ -114,12 +114,12 @@ export class Camera extends irdeviceBase {
|
|
|
114
114
|
await this.pushChangeError(e)
|
|
115
115
|
}
|
|
116
116
|
} else {
|
|
117
|
-
|
|
117
|
+
this.warnLog(`Connection Type: ${this.device.connectionType}, commands will not be sent to OpenAPI`)
|
|
118
118
|
}
|
|
119
119
|
}
|
|
120
120
|
|
|
121
121
|
async updateHomeKitCharacteristics(): Promise<void> {
|
|
122
|
-
|
|
122
|
+
this.debugLog('updateHomeKitCharacteristics')
|
|
123
123
|
// Active
|
|
124
124
|
await this.updateCharacteristic(this.Switch.Service, this.hap.Characteristic.On, this.Switch.On, 'On')
|
|
125
125
|
}
|