@switchbot/homebridge-switchbot 3.8.3 → 4.0.0-beta.1
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/.github/npm-version-script.cjs +81 -0
- package/.github/workflows/beta-release.yml +12 -4
- package/CHANGELOG.md +15 -1
- package/config.schema.json +583 -937
- package/dist/device/blindtilt.d.ts +1 -4
- package/dist/device/blindtilt.d.ts.map +1 -1
- package/dist/device/blindtilt.js +68 -66
- package/dist/device/blindtilt.js.map +1 -1
- package/dist/device/bot.d.ts +1 -4
- package/dist/device/bot.d.ts.map +1 -1
- package/dist/device/bot.js +63 -59
- package/dist/device/bot.js.map +1 -1
- package/dist/device/ceilinglight.d.ts +1 -4
- package/dist/device/ceilinglight.d.ts.map +1 -1
- package/dist/device/ceilinglight.js +56 -65
- package/dist/device/ceilinglight.js.map +1 -1
- package/dist/device/colorbulb.d.ts +1 -4
- package/dist/device/colorbulb.d.ts.map +1 -1
- package/dist/device/colorbulb.js +73 -80
- package/dist/device/colorbulb.js.map +1 -1
- package/dist/device/contact.d.ts +1 -4
- package/dist/device/contact.d.ts.map +1 -1
- package/dist/device/contact.js +38 -38
- package/dist/device/contact.js.map +1 -1
- package/dist/device/curtain.d.ts +1 -4
- package/dist/device/curtain.d.ts.map +1 -1
- package/dist/device/curtain.js +60 -60
- package/dist/device/curtain.js.map +1 -1
- package/dist/device/device.d.ts +6 -6
- package/dist/device/device.d.ts.map +1 -1
- package/dist/device/device.js +86 -20
- package/dist/device/device.js.map +1 -1
- package/dist/device/fan.d.ts +1 -4
- package/dist/device/fan.d.ts.map +1 -1
- package/dist/device/fan.js +50 -51
- package/dist/device/fan.js.map +1 -1
- package/dist/device/hub.d.ts +1 -4
- package/dist/device/hub.d.ts.map +1 -1
- package/dist/device/hub.js +48 -48
- package/dist/device/hub.js.map +1 -1
- package/dist/device/humidifier.d.ts +1 -4
- package/dist/device/humidifier.d.ts.map +1 -1
- package/dist/device/humidifier.js +53 -55
- package/dist/device/humidifier.js.map +1 -1
- package/dist/device/iosensor.d.ts +1 -4
- package/dist/device/iosensor.d.ts.map +1 -1
- package/dist/device/iosensor.js +35 -35
- package/dist/device/iosensor.js.map +1 -1
- package/dist/device/lightstrip.d.ts +1 -4
- package/dist/device/lightstrip.d.ts.map +1 -1
- package/dist/device/lightstrip.js +57 -65
- package/dist/device/lightstrip.js.map +1 -1
- package/dist/device/lock.d.ts +1 -4
- package/dist/device/lock.d.ts.map +1 -1
- package/dist/device/lock.js +38 -39
- package/dist/device/lock.js.map +1 -1
- package/dist/device/meter.d.ts +1 -4
- package/dist/device/meter.d.ts.map +1 -1
- package/dist/device/meter.js +35 -35
- package/dist/device/meter.js.map +1 -1
- package/dist/device/meterplus.d.ts +1 -4
- package/dist/device/meterplus.d.ts.map +1 -1
- package/dist/device/meterplus.js +35 -35
- package/dist/device/meterplus.js.map +1 -1
- package/dist/device/motion.d.ts +1 -4
- package/dist/device/motion.d.ts.map +1 -1
- package/dist/device/motion.js +27 -27
- package/dist/device/motion.js.map +1 -1
- package/dist/device/plug.d.ts +1 -4
- package/dist/device/plug.d.ts.map +1 -1
- package/dist/device/plug.js +32 -32
- package/dist/device/plug.js.map +1 -1
- package/dist/device/robotvacuumcleaner.d.ts +1 -4
- package/dist/device/robotvacuumcleaner.d.ts.map +1 -1
- package/dist/device/robotvacuumcleaner.js +39 -40
- package/dist/device/robotvacuumcleaner.js.map +1 -1
- package/dist/device/waterdetector.d.ts +1 -4
- package/dist/device/waterdetector.d.ts.map +1 -1
- package/dist/device/waterdetector.js +28 -28
- package/dist/device/waterdetector.js.map +1 -1
- package/dist/irdevice/airconditioner.d.ts +1 -1
- package/dist/irdevice/airconditioner.d.ts.map +1 -1
- package/dist/irdevice/airconditioner.js +31 -32
- package/dist/irdevice/airconditioner.js.map +1 -1
- package/dist/irdevice/airpurifier.d.ts +1 -1
- package/dist/irdevice/airpurifier.d.ts.map +1 -1
- package/dist/irdevice/airpurifier.js +11 -12
- package/dist/irdevice/airpurifier.js.map +1 -1
- package/dist/irdevice/camera.d.ts +1 -1
- package/dist/irdevice/camera.d.ts.map +1 -1
- package/dist/irdevice/camera.js +9 -10
- package/dist/irdevice/camera.js.map +1 -1
- package/dist/irdevice/fan.d.ts +1 -1
- package/dist/irdevice/fan.d.ts.map +1 -1
- package/dist/irdevice/fan.js +22 -23
- package/dist/irdevice/fan.js.map +1 -1
- package/dist/irdevice/irdevice.d.ts +6 -6
- package/dist/irdevice/irdevice.d.ts.map +1 -1
- package/dist/irdevice/irdevice.js +28 -14
- package/dist/irdevice/irdevice.js.map +1 -1
- package/dist/irdevice/light.d.ts +1 -1
- package/dist/irdevice/light.d.ts.map +1 -1
- package/dist/irdevice/light.js +12 -13
- package/dist/irdevice/light.js.map +1 -1
- package/dist/irdevice/other.d.ts +1 -1
- package/dist/irdevice/other.d.ts.map +1 -1
- package/dist/irdevice/other.js +12 -15
- package/dist/irdevice/other.js.map +1 -1
- package/dist/irdevice/tv.d.ts +1 -1
- package/dist/irdevice/tv.d.ts.map +1 -1
- package/dist/irdevice/tv.js +27 -28
- package/dist/irdevice/tv.js.map +1 -1
- package/dist/irdevice/vacuumcleaner.d.ts +1 -1
- package/dist/irdevice/vacuumcleaner.d.ts.map +1 -1
- package/dist/irdevice/vacuumcleaner.js +9 -10
- package/dist/irdevice/vacuumcleaner.js.map +1 -1
- package/dist/irdevice/waterheater.d.ts +1 -1
- package/dist/irdevice/waterheater.d.ts.map +1 -1
- package/dist/irdevice/waterheater.js +9 -10
- package/dist/irdevice/waterheater.js.map +1 -1
- package/dist/platform.d.ts +9 -22
- package/dist/platform.d.ts.map +1 -1
- package/dist/platform.js +154 -260
- package/dist/platform.js.map +1 -1
- package/dist/settings.d.ts +64 -82
- package/dist/settings.d.ts.map +1 -1
- package/dist/settings.js +0 -20
- package/dist/settings.js.map +1 -1
- package/dist/utils.d.ts +1 -102
- package/dist/utils.d.ts.map +1 -1
- package/dist/utils.js +0 -105
- package/dist/utils.js.map +1 -1
- package/docs/assets/highlight.css +42 -0
- package/docs/assets/main.js +1 -1
- package/docs/functions/default.html +1 -1
- package/docs/index.html +61 -50
- package/docs/media/security-privacy-bluetooth.png +0 -0
- package/package.json +5 -7
- package/src/device/blindtilt.ts +74 -74
- package/src/device/bot.ts +68 -67
- package/src/device/ceilinglight.ts +59 -70
- package/src/device/colorbulb.ts +79 -88
- package/src/device/contact.ts +40 -43
- package/src/device/curtain.ts +66 -68
- package/src/device/device.ts +86 -40
- package/src/device/fan.ts +52 -56
- package/src/device/hub.ts +50 -53
- package/src/device/humidifier.ts +56 -61
- package/src/device/iosensor.ts +37 -40
- package/src/device/lightstrip.ts +62 -72
- package/src/device/lock.ts +41 -45
- package/src/device/meter.ts +37 -40
- package/src/device/meterplus.ts +37 -40
- package/src/device/motion.ts +29 -32
- package/src/device/plug.ts +34 -37
- package/src/device/robotvacuumcleaner.ts +41 -49
- package/src/device/waterdetector.ts +30 -33
- package/src/irdevice/airconditioner.ts +33 -35
- package/src/irdevice/airpurifier.ts +12 -13
- package/src/irdevice/camera.ts +10 -11
- package/src/irdevice/fan.ts +24 -25
- package/src/irdevice/irdevice.ts +31 -27
- package/src/irdevice/light.ts +14 -15
- package/src/irdevice/other.ts +14 -17
- package/src/irdevice/tv.ts +28 -29
- package/src/irdevice/vacuumcleaner.ts +10 -11
- package/src/irdevice/waterheater.ts +10 -11
- package/src/platform.ts +178 -287
- package/src/settings.ts +67 -88
- package/src/utils.ts +2 -106
- package/dist/types/bledevicestatus.d.ts +0 -281
- package/dist/types/bledevicestatus.d.ts.map +0 -1
- package/dist/types/bledevicestatus.js +0 -2
- package/dist/types/bledevicestatus.js.map +0 -1
- package/dist/types/devicelist.d.ts +0 -89
- package/dist/types/devicelist.d.ts.map +0 -1
- package/dist/types/devicelist.js +0 -6
- package/dist/types/devicelist.js.map +0 -1
- package/dist/types/deviceresponse.d.ts +0 -13
- package/dist/types/deviceresponse.d.ts.map +0 -1
- package/dist/types/deviceresponse.js +0 -2
- package/dist/types/deviceresponse.js.map +0 -1
- package/dist/types/devicestatus.d.ts +0 -149
- package/dist/types/devicestatus.d.ts.map +0 -1
- package/dist/types/devicestatus.js +0 -3
- package/dist/types/devicestatus.js.map +0 -1
- package/dist/types/devicewebhookstatus.d.ts +0 -156
- package/dist/types/devicewebhookstatus.d.ts.map +0 -1
- package/dist/types/devicewebhookstatus.js +0 -2
- package/dist/types/devicewebhookstatus.js.map +0 -1
- package/dist/types/irdevicelist.d.ts +0 -10
- package/dist/types/irdevicelist.d.ts.map +0 -1
- package/dist/types/irdevicelist.js +0 -2
- package/dist/types/irdevicelist.js.map +0 -1
- package/dist/types/pushbody.d.ts +0 -6
- package/dist/types/pushbody.d.ts.map +0 -1
- package/dist/types/pushbody.js +0 -2
- package/dist/types/pushbody.js.map +0 -1
- package/src/types/bledevicestatus.ts +0 -303
- package/src/types/devicelist.ts +0 -124
- package/src/types/deviceresponse.ts +0 -14
- package/src/types/devicestatus.ts +0 -178
- package/src/types/devicewebhookstatus.ts +0 -191
- package/src/types/irdevicelist.ts +0 -15
- package/src/types/pushbody.ts +0 -9
package/src/device/humidifier.ts
CHANGED
|
@@ -3,13 +3,10 @@
|
|
|
3
3
|
* humidifier.ts: @switchbot/homebridge-switchbot.
|
|
4
4
|
*/
|
|
5
5
|
import type { CharacteristicValue, PlatformAccessory, Service } from 'homebridge'
|
|
6
|
+
import type { bodyChange, device, humidifierServiceData, humidifierStatus, humidifierWebhookContext, SwitchbotDevice, WoHumi } from 'node-switchbot'
|
|
6
7
|
|
|
7
8
|
import type { SwitchBotPlatform } from '../platform.js'
|
|
8
|
-
import type { devicesConfig } from '../settings.js'
|
|
9
|
-
import type { humidifierServiceData } from '../types/bledevicestatus.js'
|
|
10
|
-
import type { device } from '../types/devicelist.js'
|
|
11
|
-
import type { humidifierStatus } from '../types/devicestatus.js'
|
|
12
|
-
import type { humidifierWebhookContext } from '../types/devicewebhookstatus.js'
|
|
9
|
+
import type { devicesConfig, humidifierConfig } from '../settings.js'
|
|
13
10
|
|
|
14
11
|
/*
|
|
15
12
|
* For Testing Locally:
|
|
@@ -103,13 +100,13 @@ export class Humidifier extends deviceBase {
|
|
|
103
100
|
validValueRanges: [0, 100],
|
|
104
101
|
minValue: 0,
|
|
105
102
|
maxValue: 100,
|
|
106
|
-
minStep: device.
|
|
103
|
+
minStep: (device as humidifierConfig).set_minStep ?? 1,
|
|
107
104
|
}).onGet(() => {
|
|
108
105
|
return this.HumidifierDehumidifier.RelativeHumidityHumidifierThreshold
|
|
109
106
|
}).onSet(this.RelativeHumidityHumidifierThresholdSet.bind(this))
|
|
110
107
|
|
|
111
108
|
// Initialize the Temperature Sensor Service
|
|
112
|
-
if (device.
|
|
109
|
+
if ((device as humidifierConfig).hide_temperature) {
|
|
113
110
|
if (this.TemperatureSensor) {
|
|
114
111
|
this.debugLog('Removing Temperature Sensor Service')
|
|
115
112
|
this.TemperatureSensor!.Service = this.accessory.getService(this.hap.Service.TemperatureSensor) as Service
|
|
@@ -140,7 +137,7 @@ export class Humidifier extends deviceBase {
|
|
|
140
137
|
this.debugLog('Retrieve initial values and update Homekit')
|
|
141
138
|
this.refreshStatus()
|
|
142
139
|
} catch (e: any) {
|
|
143
|
-
this.errorLog(`failed to retrieve initial values and update Homekit, Error: ${e}`)
|
|
140
|
+
this.errorLog(`failed to retrieve initial values and update Homekit, Error: ${e.message ?? e}`)
|
|
144
141
|
}
|
|
145
142
|
|
|
146
143
|
// regisiter webhook event handler if enabled
|
|
@@ -148,7 +145,7 @@ export class Humidifier extends deviceBase {
|
|
|
148
145
|
this.debugLog('Registering Webhook Event Handler')
|
|
149
146
|
this.registerWebhook()
|
|
150
147
|
} catch (e: any) {
|
|
151
|
-
this.errorLog(`failed to registerWebhook, Error: ${e}`)
|
|
148
|
+
this.errorLog(`failed to registerWebhook, Error: ${e.message ?? e}`)
|
|
152
149
|
}
|
|
153
150
|
|
|
154
151
|
// regisiter platform BLE event handler if enabled
|
|
@@ -156,7 +153,7 @@ export class Humidifier extends deviceBase {
|
|
|
156
153
|
this.debugLog('Registering Platform BLE Event Handler')
|
|
157
154
|
this.registerPlatformBLE()
|
|
158
155
|
} catch (e: any) {
|
|
159
|
-
this.errorLog(`failed to registerPlatformBLE, Error: ${e}`)
|
|
156
|
+
this.errorLog(`failed to registerPlatformBLE, Error: ${e.message ?? e}`)
|
|
160
157
|
}
|
|
161
158
|
|
|
162
159
|
// Start an update interval
|
|
@@ -236,7 +233,7 @@ export class Humidifier extends deviceBase {
|
|
|
236
233
|
await this.debugLog(`CurrentRelativeHumidity: ${this.HumidifierDehumidifier.CurrentRelativeHumidity}`)
|
|
237
234
|
|
|
238
235
|
// Current Temperature
|
|
239
|
-
if (!this.device.
|
|
236
|
+
if (!(this.device as humidifierConfig).hide_temperature && this.TemperatureSensor?.Service) {
|
|
240
237
|
this.TemperatureSensor.CurrentTemperature = this.deviceStatus.temperature
|
|
241
238
|
await this.debugLog(`CurrentTemperature: ${this.TemperatureSensor.CurrentTemperature}`)
|
|
242
239
|
}
|
|
@@ -289,15 +286,15 @@ export class Humidifier extends deviceBase {
|
|
|
289
286
|
|
|
290
287
|
async parseStatusWebhook(): Promise<void> {
|
|
291
288
|
await this.debugLog('parseStatusWebhook')
|
|
292
|
-
await this.debugLog(`(temperature, humidity) = Webhook:(${convertUnits(this.webhookContext.temperature, this.webhookContext.scale, this.device.
|
|
289
|
+
await this.debugLog(`(temperature, humidity) = Webhook:(${convertUnits(this.webhookContext.temperature, this.webhookContext.scale, (this.device as humidifierConfig).convertUnitTo)}, ${this.webhookContext.humidity}), current:(${this.TemperatureSensor?.CurrentTemperature}, ${this.HumidifierDehumidifier.CurrentRelativeHumidity})`)
|
|
293
290
|
|
|
294
291
|
// CurrentRelativeHumidity
|
|
295
292
|
this.HumidifierDehumidifier.CurrentRelativeHumidity = validHumidity(this.webhookContext.humidity)
|
|
296
293
|
await this.debugLog(`CurrentRelativeHumidity: ${this.HumidifierDehumidifier.CurrentRelativeHumidity}`)
|
|
297
294
|
|
|
298
295
|
// CurrentTemperature
|
|
299
|
-
if (!this.device.
|
|
300
|
-
this.TemperatureSensor.CurrentTemperature = convertUnits(this.webhookContext.temperature, this.webhookContext.scale, this.device.
|
|
296
|
+
if (!(this.device as humidifierConfig).hide_temperature && this.TemperatureSensor?.Service) {
|
|
297
|
+
this.TemperatureSensor.CurrentTemperature = convertUnits(this.webhookContext.temperature, this.webhookContext.scale, (this.device as humidifierConfig).convertUnitTo)
|
|
301
298
|
await this.debugLog(`CurrentTemperature: ${this.TemperatureSensor.CurrentTemperature}`)
|
|
302
299
|
}
|
|
303
300
|
}
|
|
@@ -320,22 +317,22 @@ export class Humidifier extends deviceBase {
|
|
|
320
317
|
|
|
321
318
|
async BLERefreshStatus(): Promise<void> {
|
|
322
319
|
await this.debugLog('BLERefreshStatus')
|
|
323
|
-
const
|
|
324
|
-
if (
|
|
325
|
-
await this.BLERefreshConnection(
|
|
320
|
+
const switchBotBLE = await this.switchbotBLE()
|
|
321
|
+
if (switchBotBLE === undefined) {
|
|
322
|
+
await this.BLERefreshConnection(switchBotBLE)
|
|
326
323
|
} else {
|
|
327
324
|
// Start to monitor advertisement packets
|
|
328
325
|
(async () => {
|
|
329
326
|
// Start to monitor advertisement packets
|
|
330
|
-
const serviceData = await this.monitorAdvertisementPackets(
|
|
327
|
+
const serviceData = await this.monitorAdvertisementPackets(switchBotBLE) as humidifierServiceData
|
|
331
328
|
// Update HomeKit
|
|
332
329
|
if (serviceData.model === SwitchBotBLEModel.Humidifier && serviceData.modelName === SwitchBotBLEModelName.Humidifier) {
|
|
333
330
|
this.serviceData = serviceData
|
|
334
331
|
await this.BLEparseStatus()
|
|
335
332
|
await this.updateHomeKitCharacteristics()
|
|
336
333
|
} else {
|
|
337
|
-
await this.errorLog(`failed to get serviceData, serviceData: ${serviceData}`)
|
|
338
|
-
await this.BLERefreshConnection(
|
|
334
|
+
await this.errorLog(`failed to get serviceData, serviceData: ${JSON.stringify(serviceData)}`)
|
|
335
|
+
await this.BLERefreshConnection(switchBotBLE)
|
|
339
336
|
}
|
|
340
337
|
})()
|
|
341
338
|
}
|
|
@@ -356,7 +353,7 @@ export class Humidifier extends deviceBase {
|
|
|
356
353
|
await this.BLEparseStatus()
|
|
357
354
|
await this.updateHomeKitCharacteristics()
|
|
358
355
|
} catch (e: any) {
|
|
359
|
-
await this.errorLog(`failed to handle BLE. Received: ${JSON.stringify(context)} Error: ${e}`)
|
|
356
|
+
await this.errorLog(`failed to handle BLE. Received: ${JSON.stringify(context)} Error: ${e.message ?? e}`)
|
|
360
357
|
}
|
|
361
358
|
}
|
|
362
359
|
} catch (error) {
|
|
@@ -370,17 +367,17 @@ export class Humidifier extends deviceBase {
|
|
|
370
367
|
async openAPIRefreshStatus(): Promise<void> {
|
|
371
368
|
await this.debugLog('openAPIRefreshStatus')
|
|
372
369
|
try {
|
|
373
|
-
const { body
|
|
374
|
-
const deviceStatus: any = await body
|
|
375
|
-
await this.debugLog(`statusCode: ${statusCode}, deviceStatus: ${JSON.stringify(deviceStatus)}`)
|
|
376
|
-
if (await this.successfulStatusCodes(
|
|
377
|
-
await this.debugSuccessLog(`statusCode: ${statusCode}, deviceStatus: ${JSON.stringify(deviceStatus)}`)
|
|
370
|
+
const { body } = await this.deviceRefreshStatus()
|
|
371
|
+
const deviceStatus: any = await body
|
|
372
|
+
await this.debugLog(`statusCode: ${deviceStatus.statusCode}, deviceStatus: ${JSON.stringify(deviceStatus)}`)
|
|
373
|
+
if (await this.successfulStatusCodes(deviceStatus)) {
|
|
374
|
+
await this.debugSuccessLog(`statusCode: ${deviceStatus.statusCode}, deviceStatus: ${JSON.stringify(deviceStatus)}`)
|
|
378
375
|
this.deviceStatus = deviceStatus.body
|
|
379
376
|
await this.openAPIparseStatus()
|
|
380
377
|
await this.updateHomeKitCharacteristics()
|
|
381
378
|
} else {
|
|
382
|
-
await this.debugWarnLog(`statusCode: ${statusCode}, deviceStatus: ${JSON.stringify(deviceStatus)}`)
|
|
383
|
-
await this.debugWarnLog(
|
|
379
|
+
await this.debugWarnLog(`statusCode: ${deviceStatus.statusCode}, deviceStatus: ${JSON.stringify(deviceStatus)}`)
|
|
380
|
+
await this.debugWarnLog(deviceStatus)
|
|
384
381
|
}
|
|
385
382
|
} catch (e: any) {
|
|
386
383
|
await this.apiError(e)
|
|
@@ -398,7 +395,7 @@ export class Humidifier extends deviceBase {
|
|
|
398
395
|
await this.parseStatusWebhook()
|
|
399
396
|
await this.updateHomeKitCharacteristics()
|
|
400
397
|
} catch (e: any) {
|
|
401
|
-
await this.errorLog(`failed to handle webhook. Received: ${JSON.stringify(context)} Error: ${e}`)
|
|
398
|
+
await this.errorLog(`failed to handle webhook. Received: ${JSON.stringify(context)} Error: ${e.message ?? e}`)
|
|
402
399
|
}
|
|
403
400
|
}
|
|
404
401
|
}
|
|
@@ -432,16 +429,17 @@ export class Humidifier extends deviceBase {
|
|
|
432
429
|
if ((this.HumidifierDehumidifier.TargetHumidifierDehumidifierState === this.hap.Characteristic.TargetHumidifierDehumidifierState.HUMIDIFIER)
|
|
433
430
|
&& (this.HumidifierDehumidifier.Active === this.hap.Characteristic.Active.ACTIVE)
|
|
434
431
|
&& (this.HumidifierDehumidifier.RelativeHumidityHumidifierThreshold !== this.HumidifierDehumidifier.CurrentRelativeHumidity)) {
|
|
435
|
-
const
|
|
432
|
+
const switchBotBLE = await this.platform.connectBLE(this.accessory, this.device)
|
|
436
433
|
try {
|
|
437
434
|
const formattedDeviceId = formatDeviceIdAsMac(this.device.deviceId)
|
|
438
435
|
this.device.bleMac = formattedDeviceId
|
|
439
436
|
await this.debugLog(`bleMac: ${this.device.bleMac}`)
|
|
440
|
-
if (
|
|
441
|
-
|
|
437
|
+
if (switchBotBLE !== false) {
|
|
438
|
+
switchBotBLE
|
|
442
439
|
.discover({ model: this.device.bleModel, quick: true, id: this.device.bleMac })
|
|
443
|
-
.then(async (device_list:
|
|
444
|
-
|
|
440
|
+
.then(async (device_list: SwitchbotDevice[]) => {
|
|
441
|
+
const deviceList = device_list as unknown as WoHumi[]
|
|
442
|
+
return await deviceList[0].percentage(this.HumidifierDehumidifier.RelativeHumidityHumidifierThreshold)
|
|
445
443
|
})
|
|
446
444
|
.then(async () => {
|
|
447
445
|
await this.successLog(`RelativeHumidityHumidifierThreshold: ${this.HumidifierDehumidifier.RelativeHumidityHumidifierThreshold} sent over BLE, sent successfully`)
|
|
@@ -453,7 +451,7 @@ export class Humidifier extends deviceBase {
|
|
|
453
451
|
await this.BLEPushConnection()
|
|
454
452
|
})
|
|
455
453
|
} else {
|
|
456
|
-
await this.errorLog(`wasn't able to establish BLE Connection, node-switchbot: ${
|
|
454
|
+
await this.errorLog(`wasn't able to establish BLE Connection, node-switchbot: ${JSON.stringify(switchBotBLE)}`)
|
|
457
455
|
await this.BLEPushConnection()
|
|
458
456
|
}
|
|
459
457
|
} catch (error) {
|
|
@@ -470,21 +468,20 @@ export class Humidifier extends deviceBase {
|
|
|
470
468
|
&& (this.HumidifierDehumidifier.Active === this.hap.Characteristic.Active.ACTIVE)
|
|
471
469
|
&& (this.HumidifierDehumidifier.RelativeHumidityHumidifierThreshold !== this.HumidifierDehumidifier.CurrentRelativeHumidity)) {
|
|
472
470
|
await this.debugLog(`Auto Off, RelativeHumidityHumidifierThreshold: ${this.HumidifierDehumidifier.RelativeHumidityHumidifierThreshold}!`)
|
|
473
|
-
const bodyChange =
|
|
471
|
+
const bodyChange: bodyChange = {
|
|
474
472
|
command: 'setMode',
|
|
475
473
|
parameter: `${this.HumidifierDehumidifier.RelativeHumidityHumidifierThreshold}`,
|
|
476
474
|
commandType: 'command',
|
|
477
|
-
}
|
|
475
|
+
}
|
|
478
476
|
await this.debugLog(`SwitchBot OpenAPI bodyChange: ${JSON.stringify(bodyChange)}`)
|
|
479
477
|
try {
|
|
480
|
-
const { body
|
|
481
|
-
const deviceStatus: any = await body
|
|
482
|
-
await this.debugLog(`statusCode: ${statusCode}, deviceStatus: ${JSON.stringify(deviceStatus)}`)
|
|
483
|
-
if (await this.successfulStatusCodes(
|
|
484
|
-
await this.debugSuccessLog(`statusCode: ${statusCode}, deviceStatus: ${JSON.stringify(deviceStatus)}`)
|
|
478
|
+
const { body } = await this.pushChangeRequest(bodyChange)
|
|
479
|
+
const deviceStatus: any = await body
|
|
480
|
+
await this.debugLog(`statusCode: ${deviceStatus.statusCode}, deviceStatus: ${JSON.stringify(deviceStatus)}`)
|
|
481
|
+
if (await this.successfulStatusCodes(deviceStatus)) {
|
|
482
|
+
await this.debugSuccessLog(`statusCode: ${deviceStatus.statusCode}, deviceStatus: ${JSON.stringify(deviceStatus)}`)
|
|
485
483
|
await this.updateHomeKitCharacteristics()
|
|
486
484
|
} else {
|
|
487
|
-
await this.statusCode(statusCode)
|
|
488
485
|
await this.statusCode(deviceStatus.statusCode)
|
|
489
486
|
}
|
|
490
487
|
} catch (e: any) {
|
|
@@ -507,21 +504,20 @@ export class Humidifier extends deviceBase {
|
|
|
507
504
|
=== this.hap.Characteristic.TargetHumidifierDehumidifierState.HUMIDIFIER_OR_DEHUMIDIFIER)
|
|
508
505
|
&& (this.HumidifierDehumidifier.Active === this.hap.Characteristic.Active.ACTIVE)) {
|
|
509
506
|
await this.debugLog('Pushing Auto')
|
|
510
|
-
const bodyChange =
|
|
507
|
+
const bodyChange: bodyChange = {
|
|
511
508
|
command: 'setMode',
|
|
512
509
|
parameter: 'auto',
|
|
513
510
|
commandType: 'command',
|
|
514
|
-
}
|
|
511
|
+
}
|
|
515
512
|
await this.debugLog(`pushAutoChanges, SwitchBot OpenAPI bodyChange: ${JSON.stringify(bodyChange)}`)
|
|
516
513
|
try {
|
|
517
|
-
const { body
|
|
518
|
-
const deviceStatus: any = await body
|
|
519
|
-
await this.debugLog(`statusCode: ${statusCode}, deviceStatus: ${JSON.stringify(deviceStatus)}`)
|
|
520
|
-
if (await this.successfulStatusCodes(
|
|
521
|
-
await this.debugSuccessLog(`statusCode: ${statusCode}, deviceStatus: ${JSON.stringify(deviceStatus)}`)
|
|
514
|
+
const { body } = await this.pushChangeRequest(bodyChange)
|
|
515
|
+
const deviceStatus: any = await body
|
|
516
|
+
await this.debugLog(`statusCode: ${deviceStatus.statusCode}, deviceStatus: ${JSON.stringify(deviceStatus)}`)
|
|
517
|
+
if (await this.successfulStatusCodes(deviceStatus)) {
|
|
518
|
+
await this.debugSuccessLog(`statusCode: ${deviceStatus.statusCode}, deviceStatus: ${JSON.stringify(deviceStatus)}`)
|
|
522
519
|
await this.updateHomeKitCharacteristics()
|
|
523
520
|
} else {
|
|
524
|
-
await this.statusCode(statusCode)
|
|
525
521
|
await this.statusCode(deviceStatus.statusCode)
|
|
526
522
|
}
|
|
527
523
|
} catch (e: any) {
|
|
@@ -540,21 +536,20 @@ export class Humidifier extends deviceBase {
|
|
|
540
536
|
await this.debugLog('pushActiveChanges')
|
|
541
537
|
if (this.HumidifierDehumidifier.Active === this.hap.Characteristic.Active.INACTIVE) {
|
|
542
538
|
await this.debugLog('Pushing Off')
|
|
543
|
-
const bodyChange =
|
|
539
|
+
const bodyChange: bodyChange = {
|
|
544
540
|
command: 'turnOff',
|
|
545
541
|
parameter: 'default',
|
|
546
542
|
commandType: 'command',
|
|
547
|
-
}
|
|
543
|
+
}
|
|
548
544
|
await this.debugLog(`pushActiveChanges, SwitchBot OpenAPI bodyChange: ${JSON.stringify(bodyChange)}`)
|
|
549
545
|
try {
|
|
550
|
-
const { body
|
|
551
|
-
const deviceStatus: any = await body
|
|
552
|
-
await this.debugLog(`statusCode: ${statusCode}, deviceStatus: ${JSON.stringify(deviceStatus)}`)
|
|
553
|
-
if (await this.successfulStatusCodes(
|
|
554
|
-
await this.debugSuccessLog(`statusCode: ${statusCode}, deviceStatus: ${JSON.stringify(deviceStatus)}`)
|
|
546
|
+
const { body } = await this.pushChangeRequest(bodyChange)
|
|
547
|
+
const deviceStatus: any = await body
|
|
548
|
+
await this.debugLog(`statusCode: ${deviceStatus.statusCode}, deviceStatus: ${JSON.stringify(deviceStatus)}`)
|
|
549
|
+
if (await this.successfulStatusCodes(deviceStatus)) {
|
|
550
|
+
await this.debugSuccessLog(`statusCode: ${deviceStatus.statusCode}, deviceStatus: ${JSON.stringify(deviceStatus)}`)
|
|
555
551
|
await this.updateHomeKitCharacteristics()
|
|
556
552
|
} else {
|
|
557
|
-
await this.statusCode(statusCode)
|
|
558
553
|
await this.statusCode(deviceStatus.statusCode)
|
|
559
554
|
}
|
|
560
555
|
} catch (e: any) {
|
|
@@ -630,7 +625,7 @@ export class Humidifier extends deviceBase {
|
|
|
630
625
|
// RelativeHumidityHumidifierThreshold
|
|
631
626
|
await this.updateCharacteristic(this.HumidifierDehumidifier.Service, this.hap.Characteristic.RelativeHumidityHumidifierThreshold, this.HumidifierDehumidifier.RelativeHumidityHumidifierThreshold, 'RelativeHumidityHumidifierThreshold')
|
|
632
627
|
// CurrentTemperature
|
|
633
|
-
if (!this.device.
|
|
628
|
+
if (!(this.device as humidifierConfig).hide_temperature && this.TemperatureSensor?.Service) {
|
|
634
629
|
await this.updateCharacteristic(this.TemperatureSensor.Service, this.hap.Characteristic.CurrentTemperature, this.TemperatureSensor.CurrentTemperature, 'CurrentTemperature')
|
|
635
630
|
}
|
|
636
631
|
}
|
|
@@ -665,7 +660,7 @@ export class Humidifier extends deviceBase {
|
|
|
665
660
|
this.HumidifierDehumidifier.Service.updateCharacteristic(this.hap.Characteristic.TargetHumidifierDehumidifierState, e)
|
|
666
661
|
this.HumidifierDehumidifier.Service.updateCharacteristic(this.hap.Characteristic.Active, e)
|
|
667
662
|
this.HumidifierDehumidifier.Service.updateCharacteristic(this.hap.Characteristic.RelativeHumidityHumidifierThreshold, e)
|
|
668
|
-
if (!this.device.
|
|
663
|
+
if (!(this.device as humidifierConfig).hide_temperature && this.TemperatureSensor?.Service) {
|
|
669
664
|
this.TemperatureSensor.Service.updateCharacteristic(this.hap.Characteristic.CurrentTemperature, e)
|
|
670
665
|
}
|
|
671
666
|
}
|
package/src/device/iosensor.ts
CHANGED
|
@@ -3,13 +3,10 @@
|
|
|
3
3
|
* iosensor.ts: @switchbot/homebridge-switchbot.
|
|
4
4
|
*/
|
|
5
5
|
import type { CharacteristicValue, PlatformAccessory, Service } from 'homebridge'
|
|
6
|
+
import type { device, outdoorMeterServiceData, outdoorMeterStatus, outdoorMeterWebhookContext } from 'node-switchbot'
|
|
6
7
|
|
|
7
8
|
import type { SwitchBotPlatform } from '../platform.js'
|
|
8
|
-
import type { devicesConfig } from '../settings.js'
|
|
9
|
-
import type { outdoorMeterServiceData } from '../types/bledevicestatus.js'
|
|
10
|
-
import type { device } from '../types/devicelist.js'
|
|
11
|
-
import type { outdoorMeterStatus } from '../types/devicestatus.js'
|
|
12
|
-
import type { outdoorMeterWebhookContext } from '../types/devicewebhookstatus.js'
|
|
9
|
+
import type { devicesConfig, indoorOutdoorSensorConfig } from '../settings.js'
|
|
13
10
|
|
|
14
11
|
import { Units } from 'homebridge'
|
|
15
12
|
/*
|
|
@@ -95,7 +92,7 @@ export class IOSensor extends deviceBase {
|
|
|
95
92
|
accessory.context.BatteryName = this.Battery.Name
|
|
96
93
|
|
|
97
94
|
// InitializeTemperature Sensor Service
|
|
98
|
-
if (device.
|
|
95
|
+
if ((device as indoorOutdoorSensorConfig).hide_temperature) {
|
|
99
96
|
if (this.TemperatureSensor) {
|
|
100
97
|
this.debugLog('Removing Temperature Sensor Service')
|
|
101
98
|
this.TemperatureSensor.Service = this.accessory.getService(this.hap.Service.TemperatureSensor) as Service
|
|
@@ -123,7 +120,7 @@ export class IOSensor extends deviceBase {
|
|
|
123
120
|
}
|
|
124
121
|
|
|
125
122
|
// Initialize Humidity Sensor Service
|
|
126
|
-
if (device.
|
|
123
|
+
if ((device as indoorOutdoorSensorConfig).hide_humidity) {
|
|
127
124
|
if (this.HumiditySensor) {
|
|
128
125
|
this.debugLog('Removing Humidity Sensor Service')
|
|
129
126
|
this.HumiditySensor.Service = this.accessory.getService(this.hap.Service.HumiditySensor) as Service
|
|
@@ -151,7 +148,7 @@ export class IOSensor extends deviceBase {
|
|
|
151
148
|
this.debugLog('Retrieve initial values and update Homekit')
|
|
152
149
|
this.refreshStatus()
|
|
153
150
|
} catch (e: any) {
|
|
154
|
-
this.errorLog(`failed to retrieve initial values and update Homekit, Error: ${e}`)
|
|
151
|
+
this.errorLog(`failed to retrieve initial values and update Homekit, Error: ${e.message ?? e}`)
|
|
155
152
|
}
|
|
156
153
|
|
|
157
154
|
// regisiter webhook event handler if enabled
|
|
@@ -159,7 +156,7 @@ export class IOSensor extends deviceBase {
|
|
|
159
156
|
this.debugLog('Registering Webhook Event Handler')
|
|
160
157
|
this.registerWebhook()
|
|
161
158
|
} catch (e: any) {
|
|
162
|
-
this.errorLog(`failed to registerWebhook, Error: ${e}`)
|
|
159
|
+
this.errorLog(`failed to registerWebhook, Error: ${e.message ?? e}`)
|
|
163
160
|
}
|
|
164
161
|
|
|
165
162
|
// regisiter platform BLE event handler if enabled
|
|
@@ -167,7 +164,7 @@ export class IOSensor extends deviceBase {
|
|
|
167
164
|
this.debugLog('Registering Platform BLE Event Handler')
|
|
168
165
|
this.registerPlatformBLE()
|
|
169
166
|
} catch (e: any) {
|
|
170
|
-
this.errorLog(`failed to registerPlatformBLE, Error: ${e}`)
|
|
167
|
+
this.errorLog(`failed to registerPlatformBLE, Error: ${e.message ?? e}`)
|
|
171
168
|
}
|
|
172
169
|
|
|
173
170
|
// Start an update interval
|
|
@@ -193,13 +190,13 @@ export class IOSensor extends deviceBase {
|
|
|
193
190
|
await this.debugLog(`StatusLowBattery: ${this.Battery.StatusLowBattery}`)
|
|
194
191
|
|
|
195
192
|
// CurrentRelativeHumidity
|
|
196
|
-
if (!this.device.
|
|
193
|
+
if (!(this.device as indoorOutdoorSensorConfig).hide_humidity && this.HumiditySensor?.Service) {
|
|
197
194
|
this.HumiditySensor.CurrentRelativeHumidity = validHumidity(this.serviceData.humidity, 0, 100)
|
|
198
195
|
await this.debugLog(`CurrentRelativeHumidity: ${this.HumiditySensor.CurrentRelativeHumidity}%`)
|
|
199
196
|
}
|
|
200
197
|
|
|
201
198
|
// Current Temperature
|
|
202
|
-
if (!this.device.
|
|
199
|
+
if (!(this.device as indoorOutdoorSensorConfig).hide_temperature && this.TemperatureSensor?.Service) {
|
|
203
200
|
const CELSIUS = this.serviceData.celsius < 0 ? 0 : this.serviceData.celsius > 100 ? 100 : this.serviceData.celsius
|
|
204
201
|
this.TemperatureSensor.CurrentTemperature = CELSIUS
|
|
205
202
|
await this.debugLog(`Temperature: ${this.TemperatureSensor.CurrentTemperature}°c`)
|
|
@@ -221,13 +218,13 @@ export class IOSensor extends deviceBase {
|
|
|
221
218
|
await this.debugLog(`StatusLowBattery: ${this.Battery.StatusLowBattery}`)
|
|
222
219
|
|
|
223
220
|
// CurrentRelativeHumidity
|
|
224
|
-
if (!this.device.
|
|
221
|
+
if (!(this.device as indoorOutdoorSensorConfig).hide_humidity && this.HumiditySensor?.Service) {
|
|
225
222
|
this.HumiditySensor.CurrentRelativeHumidity = this.deviceStatus.humidity
|
|
226
223
|
await this.debugLog(`CurrentRelativeHumidity: ${this.HumiditySensor.CurrentRelativeHumidity}%`)
|
|
227
224
|
}
|
|
228
225
|
|
|
229
226
|
// Current Temperature
|
|
230
|
-
if (!this.device.
|
|
227
|
+
if (!(this.device as indoorOutdoorSensorConfig).hide_temperature && this.TemperatureSensor?.Service) {
|
|
231
228
|
this.TemperatureSensor.CurrentTemperature = this.deviceStatus.temperature
|
|
232
229
|
await this.debugLog(`CurrentTemperature: ${this.TemperatureSensor.CurrentTemperature}°c`)
|
|
233
230
|
}
|
|
@@ -250,19 +247,19 @@ export class IOSensor extends deviceBase {
|
|
|
250
247
|
|
|
251
248
|
async parseStatusWebhook(): Promise<void> {
|
|
252
249
|
await this.debugLog('parseStatusWebhook')
|
|
253
|
-
await this.debugLog(`(scale, temperature, humidity) = Webhook:(${this.webhookContext.scale}, ${convertUnits(this.webhookContext.temperature, this.webhookContext.scale, this.device.
|
|
250
|
+
await this.debugLog(`(scale, temperature, humidity) = Webhook:(${this.webhookContext.scale}, ${convertUnits(this.webhookContext.temperature, this.webhookContext.scale, (this.device as indoorOutdoorSensorConfig).convertUnitTo)}, ${this.webhookContext.humidity}), current:(${this.TemperatureSensor?.CurrentTemperature}, ${this.HumiditySensor?.CurrentRelativeHumidity})`)
|
|
254
251
|
|
|
255
|
-
if (this.webhookContext.scale !== 'CELSIUS' && this.device.
|
|
252
|
+
if (this.webhookContext.scale !== 'CELSIUS' && (this.device as indoorOutdoorSensorConfig).convertUnitTo === undefined) {
|
|
256
253
|
await this.warnLog(`received a non-CELSIUS Webhook scale: ${this.webhookContext.scale}, Use the *convertUnitsTo* config under Hub settings, if displaying incorrectly in HomeKit.`)
|
|
257
254
|
}
|
|
258
255
|
// CurrentRelativeHumidity
|
|
259
|
-
if (this.device.
|
|
256
|
+
if ((this.device as indoorOutdoorSensorConfig).hide_humidity && this.HumiditySensor?.Service) {
|
|
260
257
|
this.HumiditySensor.CurrentRelativeHumidity = this.webhookContext.humidity
|
|
261
258
|
await this.debugLog(`CurrentRelativeHumidity: ${this.HumiditySensor.CurrentRelativeHumidity}%`)
|
|
262
259
|
}
|
|
263
260
|
// CurrentTemperature
|
|
264
|
-
if (this.device.
|
|
265
|
-
this.TemperatureSensor.CurrentTemperature = convertUnits(this.webhookContext.temperature, this.webhookContext.scale, this.device.
|
|
261
|
+
if ((this.device as indoorOutdoorSensorConfig).hide_temperature && this.TemperatureSensor?.Service) {
|
|
262
|
+
this.TemperatureSensor.CurrentTemperature = convertUnits(this.webhookContext.temperature, this.webhookContext.scale, (this.device as indoorOutdoorSensorConfig).convertUnitTo)
|
|
266
263
|
await this.debugLog(`CurrentTemperature: ${this.TemperatureSensor.CurrentTemperature}°c`)
|
|
267
264
|
}
|
|
268
265
|
}
|
|
@@ -285,22 +282,22 @@ export class IOSensor extends deviceBase {
|
|
|
285
282
|
|
|
286
283
|
async BLERefreshStatus(): Promise<void> {
|
|
287
284
|
await this.debugLog('BLERefreshStatus')
|
|
288
|
-
const
|
|
289
|
-
if (
|
|
290
|
-
await this.BLERefreshConnection(
|
|
285
|
+
const switchBotBLE = await this.switchbotBLE()
|
|
286
|
+
if (switchBotBLE === undefined) {
|
|
287
|
+
await this.BLERefreshConnection(switchBotBLE)
|
|
291
288
|
} else {
|
|
292
289
|
// Start to monitor advertisement packets
|
|
293
290
|
(async () => {
|
|
294
291
|
// Start to monitor advertisement packets
|
|
295
|
-
const serviceData = await this.monitorAdvertisementPackets(
|
|
292
|
+
const serviceData = await this.monitorAdvertisementPackets(switchBotBLE) as outdoorMeterServiceData
|
|
296
293
|
// Update HomeKit
|
|
297
294
|
if (serviceData.model === SwitchBotBLEModel.OutdoorMeter && serviceData.modelName === SwitchBotBLEModelName.OutdoorMeter) {
|
|
298
295
|
this.serviceData = serviceData
|
|
299
296
|
await this.BLEparseStatus()
|
|
300
297
|
await this.updateHomeKitCharacteristics()
|
|
301
298
|
} else {
|
|
302
|
-
await this.errorLog(`failed to get serviceData, serviceData: ${serviceData}`)
|
|
303
|
-
await this.BLERefreshConnection(
|
|
299
|
+
await this.errorLog(`failed to get serviceData, serviceData: ${JSON.stringify(serviceData)}`)
|
|
300
|
+
await this.BLERefreshConnection(switchBotBLE)
|
|
304
301
|
}
|
|
305
302
|
})()
|
|
306
303
|
}
|
|
@@ -321,7 +318,7 @@ export class IOSensor extends deviceBase {
|
|
|
321
318
|
await this.BLEparseStatus()
|
|
322
319
|
await this.updateHomeKitCharacteristics()
|
|
323
320
|
} catch (e: any) {
|
|
324
|
-
await this.errorLog(`failed to handle BLE. Received: ${JSON.stringify(context)} Error: ${e}`)
|
|
321
|
+
await this.errorLog(`failed to handle BLE. Received: ${JSON.stringify(context)} Error: ${e.message ?? e}`)
|
|
325
322
|
}
|
|
326
323
|
}
|
|
327
324
|
} catch (error) {
|
|
@@ -335,17 +332,17 @@ export class IOSensor extends deviceBase {
|
|
|
335
332
|
async openAPIRefreshStatus(): Promise<void> {
|
|
336
333
|
await this.debugLog('openAPIRefreshStatus')
|
|
337
334
|
try {
|
|
338
|
-
const { body
|
|
339
|
-
const deviceStatus: any = await body
|
|
340
|
-
await this.debugLog(`statusCode: ${statusCode}, deviceStatus: ${JSON.stringify(deviceStatus)}`)
|
|
341
|
-
if (await this.successfulStatusCodes(
|
|
342
|
-
await this.debugSuccessLog(`statusCode: ${statusCode}, deviceStatus: ${JSON.stringify(deviceStatus)}`)
|
|
335
|
+
const { body } = await this.deviceRefreshStatus()
|
|
336
|
+
const deviceStatus: any = await body
|
|
337
|
+
await this.debugLog(`statusCode: ${deviceStatus.statusCode}, deviceStatus: ${JSON.stringify(deviceStatus)}`)
|
|
338
|
+
if (await this.successfulStatusCodes(deviceStatus)) {
|
|
339
|
+
await this.debugSuccessLog(`statusCode: ${deviceStatus.statusCode}, deviceStatus: ${JSON.stringify(deviceStatus)}`)
|
|
343
340
|
this.deviceStatus = deviceStatus.body
|
|
344
341
|
await this.openAPIparseStatus()
|
|
345
342
|
await this.updateHomeKitCharacteristics()
|
|
346
343
|
} else {
|
|
347
|
-
await this.debugWarnLog(`statusCode: ${statusCode}, deviceStatus: ${JSON.stringify(deviceStatus)}`)
|
|
348
|
-
await this.debugWarnLog(
|
|
344
|
+
await this.debugWarnLog(`statusCode: ${deviceStatus.statusCode}, deviceStatus: ${JSON.stringify(deviceStatus)}`)
|
|
345
|
+
await this.debugWarnLog(deviceStatus)
|
|
349
346
|
}
|
|
350
347
|
} catch (e: any) {
|
|
351
348
|
await this.apiError(e)
|
|
@@ -363,7 +360,7 @@ export class IOSensor extends deviceBase {
|
|
|
363
360
|
await this.parseStatusWebhook()
|
|
364
361
|
await this.updateHomeKitCharacteristics()
|
|
365
362
|
} catch (e: any) {
|
|
366
|
-
await this.errorLog(`failed to handle webhook. Received: ${JSON.stringify(context)} Error: ${e}`)
|
|
363
|
+
await this.errorLog(`failed to handle webhook. Received: ${JSON.stringify(context)} Error: ${e.message ?? e}`)
|
|
367
364
|
}
|
|
368
365
|
}
|
|
369
366
|
} else {
|
|
@@ -376,11 +373,11 @@ export class IOSensor extends deviceBase {
|
|
|
376
373
|
*/
|
|
377
374
|
async updateHomeKitCharacteristics(): Promise<void> {
|
|
378
375
|
// CurrentRelativeHumidity
|
|
379
|
-
if (!this.device.
|
|
376
|
+
if (!(this.device as indoorOutdoorSensorConfig).hide_humidity && this.HumiditySensor?.Service) {
|
|
380
377
|
await this.updateCharacteristic(this.HumiditySensor.Service, this.hap.Characteristic.CurrentRelativeHumidity, this.HumiditySensor.CurrentRelativeHumidity, 'CurrentRelativeHumidity')
|
|
381
378
|
}
|
|
382
379
|
// CurrentTemperature
|
|
383
|
-
if (!this.device.
|
|
380
|
+
if (!(this.device as indoorOutdoorSensorConfig).hide_temperature && this.TemperatureSensor?.Service) {
|
|
384
381
|
await this.updateCharacteristic(this.TemperatureSensor.Service, this.hap.Characteristic.CurrentTemperature, this.TemperatureSensor.CurrentTemperature, 'CurrentTemperature')
|
|
385
382
|
}
|
|
386
383
|
// BatteryLevel
|
|
@@ -399,20 +396,20 @@ export class IOSensor extends deviceBase {
|
|
|
399
396
|
|
|
400
397
|
async offlineOff(): Promise<void> {
|
|
401
398
|
if (this.device.offline) {
|
|
402
|
-
if (!this.device.
|
|
399
|
+
if (!(this.device as indoorOutdoorSensorConfig).hide_humidity && this.HumiditySensor?.Service) {
|
|
403
400
|
this.HumiditySensor.Service.updateCharacteristic(this.hap.Characteristic.CurrentRelativeHumidity, 50)
|
|
404
401
|
}
|
|
405
|
-
if (!this.device.
|
|
402
|
+
if (!(this.device as indoorOutdoorSensorConfig).hide_temperature && this.TemperatureSensor?.Service) {
|
|
406
403
|
this.TemperatureSensor.Service.updateCharacteristic(this.hap.Characteristic.CurrentTemperature, 30)
|
|
407
404
|
}
|
|
408
405
|
}
|
|
409
406
|
}
|
|
410
407
|
|
|
411
408
|
async apiError(e: any): Promise<void> {
|
|
412
|
-
if (!this.device.
|
|
409
|
+
if (!(this.device as indoorOutdoorSensorConfig).hide_humidity && this.HumiditySensor?.Service) {
|
|
413
410
|
this.HumiditySensor.Service.updateCharacteristic(this.hap.Characteristic.CurrentRelativeHumidity, e)
|
|
414
411
|
}
|
|
415
|
-
if (!this.device.
|
|
412
|
+
if (!(this.device as indoorOutdoorSensorConfig).hide_temperature && this.TemperatureSensor?.Service) {
|
|
416
413
|
this.TemperatureSensor.Service.updateCharacteristic(this.hap.Characteristic.CurrentTemperature, e)
|
|
417
414
|
}
|
|
418
415
|
this.Battery.Service.updateCharacteristic(this.hap.Characteristic.BatteryLevel, e)
|