@switchbot/homebridge-switchbot 3.5.1-beta.2 → 3.5.1-beta.3
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/dist/device/blindtilt.d.ts +15 -6
- package/dist/device/blindtilt.d.ts.map +1 -1
- package/dist/device/blindtilt.js +203 -255
- package/dist/device/blindtilt.js.map +1 -1
- package/dist/device/bot.d.ts +9 -4
- package/dist/device/bot.d.ts.map +1 -1
- package/dist/device/bot.js +196 -218
- package/dist/device/bot.js.map +1 -1
- package/dist/device/ceilinglight.d.ts +9 -4
- package/dist/device/ceilinglight.d.ts.map +1 -1
- package/dist/device/ceilinglight.js +202 -247
- package/dist/device/ceilinglight.js.map +1 -1
- package/dist/device/colorbulb.d.ts +10 -5
- package/dist/device/colorbulb.d.ts.map +1 -1
- package/dist/device/colorbulb.js +329 -378
- package/dist/device/colorbulb.js.map +1 -1
- package/dist/device/contact.d.ts +9 -4
- package/dist/device/contact.d.ts.map +1 -1
- package/dist/device/contact.js +99 -142
- package/dist/device/contact.js.map +1 -1
- package/dist/device/curtain.d.ts +19 -7
- package/dist/device/curtain.d.ts.map +1 -1
- package/dist/device/curtain.js +203 -264
- package/dist/device/curtain.js.map +1 -1
- package/dist/device/device.d.ts +28 -32
- package/dist/device/device.d.ts.map +1 -1
- package/dist/device/device.js +186 -225
- package/dist/device/device.js.map +1 -1
- package/dist/device/fan.d.ts +9 -4
- package/dist/device/fan.d.ts.map +1 -1
- package/dist/device/fan.js +198 -227
- package/dist/device/fan.js.map +1 -1
- package/dist/device/hub.d.ts +9 -5
- package/dist/device/hub.d.ts.map +1 -1
- package/dist/device/hub.js +106 -231
- package/dist/device/hub.js.map +1 -1
- package/dist/device/humidifier.d.ts +12 -4
- package/dist/device/humidifier.d.ts.map +1 -1
- package/dist/device/humidifier.js +192 -232
- package/dist/device/humidifier.js.map +1 -1
- package/dist/device/iosensor.d.ts +9 -4
- package/dist/device/iosensor.d.ts.map +1 -1
- package/dist/device/iosensor.js +91 -157
- package/dist/device/iosensor.js.map +1 -1
- package/dist/device/lightstrip.d.ts +10 -5
- package/dist/device/lightstrip.d.ts.map +1 -1
- package/dist/device/lightstrip.js +287 -367
- package/dist/device/lightstrip.js.map +1 -1
- package/dist/device/lock.d.ts +10 -5
- package/dist/device/lock.d.ts.map +1 -1
- package/dist/device/lock.js +171 -216
- package/dist/device/lock.js.map +1 -1
- package/dist/device/meter.d.ts +9 -4
- package/dist/device/meter.d.ts.map +1 -1
- package/dist/device/meter.js +93 -158
- package/dist/device/meter.js.map +1 -1
- package/dist/device/meterplus.d.ts +9 -4
- package/dist/device/meterplus.d.ts.map +1 -1
- package/dist/device/meterplus.js +94 -155
- package/dist/device/meterplus.js.map +1 -1
- package/dist/device/motion.d.ts +9 -4
- package/dist/device/motion.d.ts.map +1 -1
- package/dist/device/motion.js +84 -142
- package/dist/device/motion.js.map +1 -1
- package/dist/device/plug.d.ts +9 -4
- package/dist/device/plug.d.ts.map +1 -1
- package/dist/device/plug.js +99 -124
- package/dist/device/plug.js.map +1 -1
- package/dist/device/robotvacuumcleaner.d.ts +9 -6
- package/dist/device/robotvacuumcleaner.d.ts.map +1 -1
- package/dist/device/robotvacuumcleaner.js +170 -253
- package/dist/device/robotvacuumcleaner.js.map +1 -1
- package/dist/device/waterdetector.d.ts +12 -4
- package/dist/device/waterdetector.d.ts.map +1 -1
- package/dist/device/waterdetector.js +102 -128
- package/dist/device/waterdetector.js.map +1 -1
- package/dist/irdevice/airconditioner.d.ts +2 -1
- package/dist/irdevice/airconditioner.d.ts.map +1 -1
- package/dist/irdevice/airconditioner.js.map +1 -1
- package/dist/irdevice/airpurifier.d.ts +2 -1
- package/dist/irdevice/airpurifier.d.ts.map +1 -1
- package/dist/irdevice/airpurifier.js.map +1 -1
- package/dist/irdevice/camera.d.ts +2 -1
- package/dist/irdevice/camera.d.ts.map +1 -1
- package/dist/irdevice/camera.js.map +1 -1
- package/dist/irdevice/fan.d.ts +2 -1
- package/dist/irdevice/fan.d.ts.map +1 -1
- package/dist/irdevice/fan.js.map +1 -1
- package/dist/irdevice/irdevice.d.ts +2 -1
- package/dist/irdevice/irdevice.d.ts.map +1 -1
- package/dist/irdevice/irdevice.js +1 -1
- package/dist/irdevice/irdevice.js.map +1 -1
- package/dist/irdevice/light.d.ts +2 -1
- package/dist/irdevice/light.d.ts.map +1 -1
- package/dist/irdevice/light.js.map +1 -1
- package/dist/irdevice/other.d.ts +2 -1
- package/dist/irdevice/other.d.ts.map +1 -1
- package/dist/irdevice/other.js.map +1 -1
- package/dist/irdevice/tv.d.ts +2 -1
- package/dist/irdevice/tv.d.ts.map +1 -1
- package/dist/irdevice/tv.js.map +1 -1
- package/dist/irdevice/vacuumcleaner.d.ts +2 -1
- package/dist/irdevice/vacuumcleaner.d.ts.map +1 -1
- package/dist/irdevice/vacuumcleaner.js.map +1 -1
- package/dist/irdevice/waterheater.d.ts +2 -1
- package/dist/irdevice/waterheater.d.ts.map +1 -1
- package/dist/irdevice/waterheater.js.map +1 -1
- package/dist/platform.d.ts +5 -7
- package/dist/platform.d.ts.map +1 -1
- package/dist/platform.js +51 -34
- package/dist/platform.js.map +1 -1
- package/dist/settings.d.ts +49 -191
- package/dist/settings.d.ts.map +1 -1
- package/dist/settings.js +19 -0
- package/dist/settings.js.map +1 -1
- package/dist/types/bledevicestatus.d.ts +279 -0
- package/dist/types/bledevicestatus.d.ts.map +1 -0
- package/dist/types/bledevicestatus.js +2 -0
- package/dist/types/bledevicestatus.js.map +1 -0
- package/dist/types/devicelist.d.ts +89 -0
- package/dist/types/devicelist.d.ts.map +1 -0
- package/dist/types/devicelist.js +6 -0
- package/dist/types/devicelist.js.map +1 -0
- package/dist/types/deviceresponse.d.ts +13 -0
- package/dist/types/deviceresponse.d.ts.map +1 -0
- package/dist/types/deviceresponse.js +2 -0
- package/dist/types/deviceresponse.js.map +1 -0
- package/dist/types/devicestatus.d.ts +149 -0
- package/dist/types/devicestatus.d.ts.map +1 -0
- package/dist/types/devicestatus.js +3 -0
- package/dist/types/devicestatus.js.map +1 -0
- package/dist/types/devicewebhookstatus.d.ts +156 -0
- package/dist/types/devicewebhookstatus.d.ts.map +1 -0
- package/dist/types/devicewebhookstatus.js +2 -0
- package/dist/types/devicewebhookstatus.js.map +1 -0
- package/dist/types/irdevicelist.d.ts +10 -0
- package/dist/types/irdevicelist.d.ts.map +1 -0
- package/dist/types/irdevicelist.js +2 -0
- package/dist/types/irdevicelist.js.map +1 -0
- package/dist/types/pushbody.d.ts +6 -0
- package/dist/types/pushbody.d.ts.map +1 -0
- package/dist/types/pushbody.js +2 -0
- package/dist/types/pushbody.js.map +1 -0
- package/dist/utils.d.ts +25 -0
- package/dist/utils.d.ts.map +1 -1
- package/dist/utils.js +28 -0
- package/dist/utils.js.map +1 -1
- package/package.json +10 -10
- package/src/device/blindtilt.ts +223 -263
- package/src/device/bot.ts +208 -221
- package/src/device/ceilinglight.ts +210 -257
- package/src/device/colorbulb.ts +334 -397
- package/src/device/contact.ts +111 -146
- package/src/device/curtain.ts +220 -283
- package/src/device/device.ts +194 -245
- package/src/device/fan.ts +214 -230
- package/src/device/hub.ts +126 -246
- package/src/device/humidifier.ts +216 -243
- package/src/device/iosensor.ts +114 -166
- package/src/device/lightstrip.ts +302 -377
- package/src/device/lock.ts +187 -221
- package/src/device/meter.ts +116 -177
- package/src/device/meterplus.ts +117 -174
- package/src/device/motion.ts +99 -144
- package/src/device/plug.ts +110 -128
- package/src/device/robotvacuumcleaner.ts +189 -252
- package/src/device/waterdetector.ts +120 -138
- package/src/irdevice/airconditioner.ts +2 -1
- package/src/irdevice/airpurifier.ts +2 -1
- package/src/irdevice/camera.ts +2 -1
- package/src/irdevice/fan.ts +2 -1
- package/src/irdevice/irdevice.ts +3 -2
- package/src/irdevice/light.ts +2 -1
- package/src/irdevice/other.ts +2 -1
- package/src/irdevice/tv.ts +2 -1
- package/src/irdevice/vacuumcleaner.ts +2 -1
- package/src/irdevice/waterheater.ts +2 -1
- package/src/platform.ts +52 -34
- package/src/settings.ts +30 -239
- package/src/types/bledevicestatus.ts +305 -0
- package/src/types/devicelist.ts +124 -0
- package/src/types/deviceresponse.ts +15 -0
- package/src/types/devicestatus.ts +178 -0
- package/src/types/devicewebhookstatus.ts +196 -0
- package/src/types/irdevicelist.ts +15 -0
- package/src/types/pushbody.ts +9 -0
- package/src/utils.ts +33 -0
|
@@ -3,9 +3,9 @@
|
|
|
3
3
|
* humidifier.ts: @switchbot/homebridge-switchbot.
|
|
4
4
|
*/
|
|
5
5
|
import { deviceBase } from './device.js';
|
|
6
|
-
import { interval, Subject } from 'rxjs';
|
|
7
6
|
import { convertUnits } from '../utils.js';
|
|
8
|
-
import {
|
|
7
|
+
import { SwitchBotBLEModel, SwitchBotBLEModelName } from 'node-switchbot';
|
|
8
|
+
import { Subject, debounceTime, interval, skipWhile, take, tap } from 'rxjs';
|
|
9
9
|
/**
|
|
10
10
|
* Platform Accessory
|
|
11
11
|
* An instance of this class is created for each accessory your platform registers
|
|
@@ -108,14 +108,14 @@ export class Humidifier extends deviceBase {
|
|
|
108
108
|
this.refreshStatus();
|
|
109
109
|
// Retrieve initial values and updateHomekit
|
|
110
110
|
this.updateHomeKitCharacteristics();
|
|
111
|
+
//regisiter webhook event handler
|
|
112
|
+
this.registerWebhook();
|
|
111
113
|
// Start an update interval
|
|
112
114
|
interval(this.deviceRefreshRate * 1000)
|
|
113
115
|
.pipe(skipWhile(() => this.humidifierUpdateInProgress))
|
|
114
116
|
.subscribe(async () => {
|
|
115
117
|
await this.refreshStatus();
|
|
116
118
|
});
|
|
117
|
-
//regisiter webhook event handler
|
|
118
|
-
this.registerWebhook(accessory, device);
|
|
119
119
|
// Watch for Humidifier change events
|
|
120
120
|
// We put in a debounce of 100ms so we don't make duplicate calls
|
|
121
121
|
this.doHumidifierUpdate
|
|
@@ -127,45 +127,61 @@ export class Humidifier extends deviceBase {
|
|
|
127
127
|
await this.pushChanges();
|
|
128
128
|
}
|
|
129
129
|
catch (e) {
|
|
130
|
-
this.apiError(e);
|
|
131
|
-
this.errorLog(
|
|
132
|
-
+ ` Error Message: ${JSON.stringify(e.message)}`);
|
|
130
|
+
await this.apiError(e);
|
|
131
|
+
await this.errorLog(`failed pushChanges with ${device.connectionType} Connection, Error Message: ${JSON.stringify(e.message)}`);
|
|
133
132
|
}
|
|
134
133
|
this.humidifierUpdateInProgress = false;
|
|
135
134
|
});
|
|
136
135
|
}
|
|
137
136
|
async BLEparseStatus(serviceData) {
|
|
138
|
-
this.debugLog(
|
|
139
|
-
//
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
}
|
|
137
|
+
await this.debugLog('BLEparseStatus');
|
|
138
|
+
// Active
|
|
139
|
+
this.HumidifierDehumidifier.Active = serviceData.onState ? this.hap.Characteristic.Active.ACTIVE : this.hap.Characteristic.Active.INACTIVE;
|
|
140
|
+
await this.debugLog(`Active: ${this.HumidifierDehumidifier.Active}`);
|
|
143
141
|
// Current Relative Humidity
|
|
144
142
|
this.HumidifierDehumidifier.CurrentRelativeHumidity = serviceData.percentage;
|
|
145
|
-
this.debugLog(
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
143
|
+
await this.debugLog(`CurrentRelativeHumidity: ${this.HumidifierDehumidifier.CurrentRelativeHumidity}`);
|
|
144
|
+
// Target Humidifier Dehumidifier State
|
|
145
|
+
switch (serviceData.autoMode) {
|
|
146
|
+
case true:
|
|
147
|
+
this.HumidifierDehumidifier.TargetHumidifierDehumidifierState =
|
|
148
|
+
this.hap.Characteristic.TargetHumidifierDehumidifierState.HUMIDIFIER_OR_DEHUMIDIFIER;
|
|
149
|
+
this.HumidifierDehumidifier.CurrentHumidifierDehumidifierState = this.hap.Characteristic.CurrentHumidifierDehumidifierState.HUMIDIFYING;
|
|
150
|
+
this.HumidifierDehumidifier.RelativeHumidityHumidifierThreshold = this.HumidifierDehumidifier.CurrentRelativeHumidity;
|
|
151
|
+
break;
|
|
152
|
+
default:
|
|
153
|
+
this.HumidifierDehumidifier.TargetHumidifierDehumidifierState = this.hap.Characteristic.TargetHumidifierDehumidifierState.HUMIDIFIER;
|
|
154
|
+
this.HumidifierDehumidifier.RelativeHumidityHumidifierThreshold = serviceData.percentage > 100 ? 100 : serviceData.percentage;
|
|
155
|
+
if (this.HumidifierDehumidifier.CurrentRelativeHumidity > this.HumidifierDehumidifier.RelativeHumidityHumidifierThreshold) {
|
|
156
|
+
this.HumidifierDehumidifier.CurrentHumidifierDehumidifierState = this.hap.Characteristic.CurrentHumidifierDehumidifierState.IDLE;
|
|
157
|
+
}
|
|
158
|
+
else if (this.HumidifierDehumidifier.Active === this.hap.Characteristic.Active.INACTIVE) {
|
|
159
|
+
this.HumidifierDehumidifier.CurrentHumidifierDehumidifierState = this.hap.Characteristic.CurrentHumidifierDehumidifierState.INACTIVE;
|
|
160
|
+
}
|
|
161
|
+
else {
|
|
162
|
+
this.HumidifierDehumidifier.CurrentHumidifierDehumidifierState = this.hap.Characteristic.CurrentHumidifierDehumidifierState.HUMIDIFYING;
|
|
163
|
+
}
|
|
153
164
|
}
|
|
154
|
-
this.debugLog(
|
|
165
|
+
await this.debugLog(`TargetHumidifierDehumidifierState: ${this.HumidifierDehumidifier.TargetHumidifierDehumidifierState},`
|
|
166
|
+
+ ` RelativeHumidityHumidifierThreshold: ${this.HumidifierDehumidifier.RelativeHumidityHumidifierThreshold},`
|
|
167
|
+
+ ` CurrentHumidifierDehumidifierState: ${this.HumidifierDehumidifier.CurrentHumidifierDehumidifierState}`);
|
|
155
168
|
}
|
|
156
169
|
async openAPIparseStatus(deviceStatus) {
|
|
157
|
-
this.debugLog(
|
|
170
|
+
await this.debugLog('openAPIparseStatus');
|
|
171
|
+
// Active
|
|
172
|
+
this.HumidifierDehumidifier.Active = deviceStatus.power === 'on'
|
|
173
|
+
? this.hap.Characteristic.Active.ACTIVE : this.hap.Characteristic.Active.INACTIVE;
|
|
174
|
+
await this.debugLog(`Active: ${this.HumidifierDehumidifier.Active}`);
|
|
158
175
|
// Current Relative Humidity
|
|
159
|
-
this.HumidifierDehumidifier.CurrentRelativeHumidity = deviceStatus.
|
|
160
|
-
this.debugLog(
|
|
161
|
-
+ ` CurrentRelativeHumidity: ${this.HumidifierDehumidifier.CurrentRelativeHumidity}`);
|
|
176
|
+
this.HumidifierDehumidifier.CurrentRelativeHumidity = deviceStatus.temperature;
|
|
177
|
+
await this.debugLog(`CurrentRelativeHumidity: ${this.HumidifierDehumidifier.CurrentRelativeHumidity}`);
|
|
162
178
|
// Current Temperature
|
|
163
|
-
if (!this.device.humidifier?.hide_temperature) {
|
|
164
|
-
this.TemperatureSensor.CurrentTemperature = deviceStatus.
|
|
165
|
-
this.debugLog(
|
|
179
|
+
if (!this.device.humidifier?.hide_temperature && this.TemperatureSensor?.Service) {
|
|
180
|
+
this.TemperatureSensor.CurrentTemperature = deviceStatus.temperature;
|
|
181
|
+
await this.debugLog(`CurrentTemperature: ${this.TemperatureSensor.CurrentTemperature}`);
|
|
166
182
|
}
|
|
167
183
|
// Target Humidifier Dehumidifier State
|
|
168
|
-
switch (deviceStatus.
|
|
184
|
+
switch (deviceStatus.auto) {
|
|
169
185
|
case true:
|
|
170
186
|
this.HumidifierDehumidifier.TargetHumidifierDehumidifierState =
|
|
171
187
|
this.hap.Characteristic.TargetHumidifierDehumidifierState.HUMIDIFIER_OR_DEHUMIDIFIER;
|
|
@@ -174,12 +190,8 @@ export class Humidifier extends deviceBase {
|
|
|
174
190
|
break;
|
|
175
191
|
default:
|
|
176
192
|
this.HumidifierDehumidifier.TargetHumidifierDehumidifierState = this.hap.Characteristic.TargetHumidifierDehumidifierState.HUMIDIFIER;
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
}
|
|
180
|
-
else {
|
|
181
|
-
this.HumidifierDehumidifier.RelativeHumidityHumidifierThreshold = deviceStatus.body.nebulizationEfficiency;
|
|
182
|
-
}
|
|
193
|
+
this.HumidifierDehumidifier.RelativeHumidityHumidifierThreshold = deviceStatus.nebulizationEfficiency > 100
|
|
194
|
+
? 100 : deviceStatus.nebulizationEfficiency;
|
|
183
195
|
if (this.HumidifierDehumidifier.CurrentRelativeHumidity > this.HumidifierDehumidifier.RelativeHumidityHumidifierThreshold) {
|
|
184
196
|
this.HumidifierDehumidifier.CurrentHumidifierDehumidifierState = this.hap.Characteristic.CurrentHumidifierDehumidifierState.IDLE;
|
|
185
197
|
}
|
|
@@ -190,34 +202,22 @@ export class Humidifier extends deviceBase {
|
|
|
190
202
|
this.HumidifierDehumidifier.CurrentHumidifierDehumidifierState = this.hap.Characteristic.CurrentHumidifierDehumidifierState.HUMIDIFYING;
|
|
191
203
|
}
|
|
192
204
|
}
|
|
193
|
-
this.debugLog(
|
|
194
|
-
+ `
|
|
195
|
-
this.debugLog(`${this.device.deviceType}: ${this.accessory.displayName}`
|
|
196
|
-
+ ` RelativeHumidityHumidifierThreshold: ${this.HumidifierDehumidifier.RelativeHumidityHumidifierThreshold}`);
|
|
197
|
-
this.debugLog(`${this.device.deviceType}: ${this.accessory.displayName}`
|
|
205
|
+
await this.debugLog(`TargetHumidifierDehumidifierState: ${this.HumidifierDehumidifier.TargetHumidifierDehumidifierState},`
|
|
206
|
+
+ ` RelativeHumidityHumidifierThreshold: ${this.HumidifierDehumidifier.RelativeHumidityHumidifierThreshold},`
|
|
198
207
|
+ ` CurrentHumidifierDehumidifierState: ${this.HumidifierDehumidifier.CurrentHumidifierDehumidifierState}`);
|
|
199
|
-
// Active
|
|
200
|
-
switch (deviceStatus.body.power) {
|
|
201
|
-
case 'on':
|
|
202
|
-
this.HumidifierDehumidifier.Active = this.hap.Characteristic.Active.ACTIVE;
|
|
203
|
-
break;
|
|
204
|
-
default:
|
|
205
|
-
this.HumidifierDehumidifier.Active = this.hap.Characteristic.Active.INACTIVE;
|
|
206
|
-
}
|
|
207
|
-
this.debugLog(`${this.device.deviceType}: ${this.accessory.displayName} Active: ${this.HumidifierDehumidifier.Active}`);
|
|
208
208
|
// Water Level
|
|
209
|
-
if (deviceStatus.
|
|
209
|
+
if (deviceStatus.lackWater) {
|
|
210
210
|
this.HumidifierDehumidifier.WaterLevel = 0;
|
|
211
211
|
}
|
|
212
212
|
else {
|
|
213
213
|
this.HumidifierDehumidifier.WaterLevel = 100;
|
|
214
214
|
}
|
|
215
|
-
this.debugLog(
|
|
215
|
+
await this.debugLog(`WaterLevel: ${this.HumidifierDehumidifier.WaterLevel}`);
|
|
216
216
|
// Firmware Version
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
const deviceVersion = version
|
|
217
|
+
if (deviceStatus.version) {
|
|
218
|
+
const version = deviceStatus.version.toString();
|
|
219
|
+
await this.debugLog(`Firmware Version: ${version.replace(/^V|-.*$/g, '')}`);
|
|
220
|
+
const deviceVersion = version.replace(/^V|-.*$/g, '') ?? '0.0.0';
|
|
221
221
|
this.accessory
|
|
222
222
|
.getService(this.hap.Service.AccessoryInformation)
|
|
223
223
|
.setCharacteristic(this.hap.Characteristic.HardwareRevision, deviceVersion)
|
|
@@ -225,12 +225,28 @@ export class Humidifier extends deviceBase {
|
|
|
225
225
|
.getCharacteristic(this.hap.Characteristic.FirmwareRevision)
|
|
226
226
|
.updateValue(deviceVersion);
|
|
227
227
|
this.accessory.context.deviceVersion = deviceVersion;
|
|
228
|
-
this.debugSuccessLog(
|
|
228
|
+
await this.debugSuccessLog(`deviceVersion: ${this.accessory.context.deviceVersion}`);
|
|
229
|
+
}
|
|
230
|
+
}
|
|
231
|
+
async parseStatusWebhook(context) {
|
|
232
|
+
await this.debugLog('parseStatusWebhook');
|
|
233
|
+
await this.debugLog(`(temperature, humidity) = Webhook:(${convertUnits(context.temperature, context.scale, this.device.iosensor?.convertUnitTo)},`
|
|
234
|
+
+ ` ${context.humidity}), current:(${this.TemperatureSensor?.CurrentTemperature}, ${this.HumidifierDehumidifier.CurrentRelativeHumidity})`);
|
|
235
|
+
// CurrentRelativeHumidity
|
|
236
|
+
this.HumidifierDehumidifier.CurrentRelativeHumidity = context.humidity;
|
|
237
|
+
await this.debugLog(`CurrentRelativeHumidity: ${this.HumidifierDehumidifier.CurrentRelativeHumidity}`);
|
|
238
|
+
// CurrentTemperature
|
|
239
|
+
if (!this.device.humidifier?.hide_temperature && this.TemperatureSensor?.Service) {
|
|
240
|
+
this.TemperatureSensor.CurrentTemperature = convertUnits(context.temperature, context.scale, this.device.iosensor?.convertUnitTo);
|
|
241
|
+
await this.debugLog(`CurrentTemperature: ${this.TemperatureSensor.CurrentTemperature}`);
|
|
229
242
|
}
|
|
230
243
|
}
|
|
244
|
+
/**
|
|
245
|
+
* Asks the SwitchBot API for the latest device information
|
|
246
|
+
*/
|
|
231
247
|
async refreshStatus() {
|
|
232
248
|
if (!this.device.enableCloudService && this.OpenAPI) {
|
|
233
|
-
this.errorLog(
|
|
249
|
+
await this.errorLog(`refreshStatus enableCloudService: ${this.device.enableCloudService}`);
|
|
234
250
|
}
|
|
235
251
|
else if (this.BLE) {
|
|
236
252
|
await this.BLERefreshStatus();
|
|
@@ -240,12 +256,11 @@ export class Humidifier extends deviceBase {
|
|
|
240
256
|
}
|
|
241
257
|
else {
|
|
242
258
|
await this.offlineOff();
|
|
243
|
-
this.debugWarnLog(
|
|
244
|
-
+ ` ${this.device.connectionType}, refreshStatus will not happen.`);
|
|
259
|
+
await this.debugWarnLog(`Connection Type: ${this.device.connectionType}, refreshStatus will not happen.`);
|
|
245
260
|
}
|
|
246
261
|
}
|
|
247
262
|
async BLERefreshStatus() {
|
|
248
|
-
this.debugLog(
|
|
263
|
+
await this.debugLog('BLERefreshStatus');
|
|
249
264
|
const switchbot = await this.switchbotBLE();
|
|
250
265
|
if (switchbot === undefined) {
|
|
251
266
|
await this.BLERefreshConnection(switchbot);
|
|
@@ -256,57 +271,50 @@ export class Humidifier extends deviceBase {
|
|
|
256
271
|
// Start to monitor advertisement packets
|
|
257
272
|
const serviceData = await this.monitorAdvertisementPackets(switchbot);
|
|
258
273
|
// Update HomeKit
|
|
259
|
-
if (serviceData.model
|
|
274
|
+
if (serviceData.model === SwitchBotBLEModel.Humidifier && serviceData.modelName === SwitchBotBLEModelName.Humidifier) {
|
|
260
275
|
await this.BLEparseStatus(serviceData);
|
|
261
276
|
await this.updateHomeKitCharacteristics();
|
|
262
277
|
}
|
|
263
278
|
else {
|
|
264
|
-
this.errorLog(
|
|
279
|
+
await this.errorLog(`failed to get serviceData, serviceData: ${serviceData}`);
|
|
265
280
|
await this.BLERefreshConnection(switchbot);
|
|
266
281
|
}
|
|
267
282
|
})();
|
|
268
283
|
}
|
|
269
284
|
}
|
|
270
285
|
async openAPIRefreshStatus() {
|
|
271
|
-
this.debugLog(
|
|
286
|
+
await this.debugLog('openAPIRefreshStatus');
|
|
272
287
|
try {
|
|
273
288
|
const { body, statusCode } = await this.deviceRefreshStatus();
|
|
274
289
|
const deviceStatus = await body.json();
|
|
275
|
-
await this.
|
|
290
|
+
await this.debugLog(`statusCode: ${statusCode}, deviceStatus: ${JSON.stringify(deviceStatus)}`);
|
|
276
291
|
;
|
|
277
|
-
if (
|
|
278
|
-
await this.
|
|
279
|
-
await this.openAPIparseStatus(deviceStatus);
|
|
292
|
+
if (await this.successfulStatusCodes(statusCode, deviceStatus)) {
|
|
293
|
+
await this.debugSuccessLog(`statusCode: ${statusCode}, deviceStatus: ${JSON.stringify(deviceStatus)}`);
|
|
294
|
+
await this.openAPIparseStatus(deviceStatus.body);
|
|
280
295
|
await this.updateHomeKitCharacteristics();
|
|
281
296
|
}
|
|
282
297
|
else {
|
|
283
|
-
await this.
|
|
298
|
+
await this.debugWarnLog(`statusCode: ${statusCode}, deviceStatus: ${JSON.stringify(deviceStatus)}`);
|
|
299
|
+
await this.debugWarnLog(statusCode, deviceStatus);
|
|
284
300
|
}
|
|
285
301
|
}
|
|
286
302
|
catch (e) {
|
|
287
303
|
await this.apiError(e);
|
|
288
|
-
await this.
|
|
304
|
+
await this.errorLog(`failed openAPIRefreshStatus with ${this.device.connectionType} Connection, Error Message: ${JSON.stringify(e.message)}`);
|
|
289
305
|
}
|
|
290
306
|
}
|
|
291
|
-
async registerWebhook(
|
|
292
|
-
if (device.webhook) {
|
|
293
|
-
this.debugLog(
|
|
294
|
-
this.platform.webhookEventHandler[device.deviceId] = async (context) => {
|
|
307
|
+
async registerWebhook() {
|
|
308
|
+
if (this.device.webhook) {
|
|
309
|
+
await this.debugLog('is listening webhook.');
|
|
310
|
+
this.platform.webhookEventHandler[this.device.deviceId] = async (context) => {
|
|
295
311
|
try {
|
|
296
|
-
this.debugLog(
|
|
297
|
-
|
|
298
|
-
|
|
299
|
-
const { CurrentTemperature } = this.TemperatureSensor || { CurrentTemperature: undefined };
|
|
300
|
-
this.debugLog(`${device.deviceType}: ${accessory.displayName} (temperature, humidity) = Webhook:(${convertUnits(temperature, context.scale, device.iosensor?.convertUnitTo)}, ${humidity}), current:(${CurrentTemperature}, ${CurrentRelativeHumidity})`);
|
|
301
|
-
this.HumidifierDehumidifier.CurrentRelativeHumidity = humidity;
|
|
302
|
-
if (!device.humidifier?.hide_temperature) {
|
|
303
|
-
this.TemperatureSensor.CurrentTemperature = convertUnits(temperature, context.scale, device.iosensor?.convertUnitTo);
|
|
304
|
-
}
|
|
305
|
-
this.updateHomeKitCharacteristics();
|
|
312
|
+
await this.debugLog(`received Webhook: ${JSON.stringify(context)}`);
|
|
313
|
+
await this.parseStatusWebhook(context);
|
|
314
|
+
await this.updateHomeKitCharacteristics();
|
|
306
315
|
}
|
|
307
316
|
catch (e) {
|
|
308
|
-
this.errorLog(
|
|
309
|
-
+ `failed to handle webhook. Received: ${JSON.stringify(context)} Error: ${e}`);
|
|
317
|
+
await this.errorLog(`failed to handle webhook. Received: ${JSON.stringify(context)} Error: ${e}`);
|
|
310
318
|
}
|
|
311
319
|
};
|
|
312
320
|
}
|
|
@@ -316,7 +324,7 @@ export class Humidifier extends deviceBase {
|
|
|
316
324
|
*/
|
|
317
325
|
async pushChanges() {
|
|
318
326
|
if (!this.device.enableCloudService && this.OpenAPI) {
|
|
319
|
-
this.errorLog(
|
|
327
|
+
await this.errorLog(`pushChanges enableCloudService: ${this.device.enableCloudService}`);
|
|
320
328
|
}
|
|
321
329
|
else if (this.BLE) {
|
|
322
330
|
await this.BLEpushChanges();
|
|
@@ -326,7 +334,7 @@ export class Humidifier extends deviceBase {
|
|
|
326
334
|
}
|
|
327
335
|
else {
|
|
328
336
|
await this.offlineOff();
|
|
329
|
-
await this.
|
|
337
|
+
await this.debugWarnLog(`Connection Type: ${this.device.connectionType}, pushChanges will not happen.`);
|
|
330
338
|
}
|
|
331
339
|
// Refresh the status from the API
|
|
332
340
|
interval(15000)
|
|
@@ -337,46 +345,58 @@ export class Humidifier extends deviceBase {
|
|
|
337
345
|
});
|
|
338
346
|
}
|
|
339
347
|
async BLEpushChanges() {
|
|
340
|
-
this.debugLog(
|
|
341
|
-
|
|
342
|
-
|
|
343
|
-
|
|
344
|
-
|
|
345
|
-
|
|
346
|
-
|
|
347
|
-
|
|
348
|
-
|
|
349
|
-
|
|
350
|
-
|
|
351
|
-
|
|
352
|
-
|
|
353
|
-
|
|
354
|
-
|
|
355
|
-
|
|
356
|
-
|
|
357
|
-
|
|
358
|
-
|
|
359
|
-
|
|
360
|
-
|
|
348
|
+
await this.debugLog('BLEpushChanges');
|
|
349
|
+
if ((this.HumidifierDehumidifier.TargetHumidifierDehumidifierState === this.hap.Characteristic.TargetHumidifierDehumidifierState.HUMIDIFIER)
|
|
350
|
+
&& (this.HumidifierDehumidifier.Active === this.hap.Characteristic.Active.ACTIVE)
|
|
351
|
+
&& (this.HumidifierDehumidifier.RelativeHumidityHumidifierThreshold !== this.HumidifierDehumidifier.CurrentRelativeHumidity)) {
|
|
352
|
+
const switchbot = await this.platform.connectBLE(this.accessory, this.device);
|
|
353
|
+
await this.convertBLEAddress();
|
|
354
|
+
if (switchbot !== false) {
|
|
355
|
+
switchbot
|
|
356
|
+
.discover({ model: this.device.bleModel, quick: true, id: this.device.bleMac })
|
|
357
|
+
.then(async (device_list) => {
|
|
358
|
+
return await device_list[0].percentage(this.HumidifierDehumidifier.RelativeHumidityHumidifierThreshold);
|
|
359
|
+
})
|
|
360
|
+
.then(async () => {
|
|
361
|
+
await this.successLog(`RelativeHumidityHumidifierThreshold: ${this.HumidifierDehumidifier.RelativeHumidityHumidifierThreshold}`
|
|
362
|
+
+ ' sent over BLE, sent successfully');
|
|
363
|
+
await this.updateHomeKitCharacteristics();
|
|
364
|
+
})
|
|
365
|
+
.catch(async (e) => {
|
|
366
|
+
await this.apiError(e);
|
|
367
|
+
await this.errorLog(`failed BLEpushChanges with ${this.device.connectionType} Connection, Error Message: ${JSON.stringify(e.message)}`);
|
|
368
|
+
await this.BLEPushConnection();
|
|
369
|
+
});
|
|
370
|
+
}
|
|
371
|
+
else {
|
|
372
|
+
await this.errorLog(`wasn't able to establish BLE Connection, node-switchbot: ${switchbot}`);
|
|
373
|
+
await this.BLEPushConnection();
|
|
374
|
+
}
|
|
375
|
+
}
|
|
376
|
+
else {
|
|
377
|
+
await this.debugLog(`No changes (BLEpushChanges), Active: ${this.HumidifierDehumidifier.Active},`
|
|
378
|
+
+ ` RelativeHumidityHumidifierThreshold: ${this.HumidifierDehumidifier.RelativeHumidityHumidifierThreshold},`
|
|
379
|
+
+ ` CurrentRelativeHumidity: ${this.HumidifierDehumidifier.CurrentRelativeHumidity}`);
|
|
380
|
+
}
|
|
361
381
|
}
|
|
362
382
|
async openAPIpushChanges() {
|
|
363
|
-
this.debugLog(
|
|
364
|
-
if (this.HumidifierDehumidifier.TargetHumidifierDehumidifierState === this.hap.Characteristic.TargetHumidifierDehumidifierState.HUMIDIFIER
|
|
365
|
-
this.HumidifierDehumidifier.Active === this.hap.Characteristic.Active.ACTIVE)
|
|
366
|
-
|
|
367
|
-
|
|
383
|
+
await this.debugLog('openAPIpushChanges');
|
|
384
|
+
if ((this.HumidifierDehumidifier.TargetHumidifierDehumidifierState === this.hap.Characteristic.TargetHumidifierDehumidifierState.HUMIDIFIER)
|
|
385
|
+
&& (this.HumidifierDehumidifier.Active === this.hap.Characteristic.Active.ACTIVE)
|
|
386
|
+
&& (this.HumidifierDehumidifier.RelativeHumidityHumidifierThreshold !== this.HumidifierDehumidifier.CurrentRelativeHumidity)) {
|
|
387
|
+
await this.debugLog(`Auto Off, RelativeHumidityHumidifierThreshold: ${this.HumidifierDehumidifier.RelativeHumidityHumidifierThreshold}!`);
|
|
368
388
|
const bodyChange = JSON.stringify({
|
|
369
389
|
command: 'setMode',
|
|
370
390
|
parameter: `${this.HumidifierDehumidifier.RelativeHumidityHumidifierThreshold}`,
|
|
371
391
|
commandType: 'command',
|
|
372
392
|
});
|
|
373
|
-
this.debugLog(
|
|
393
|
+
await this.debugLog(`SwitchBot OpenAPI bodyChange: ${JSON.stringify(bodyChange)}`);
|
|
374
394
|
try {
|
|
375
395
|
const { body, statusCode } = await this.pushChangeRequest(bodyChange);
|
|
376
396
|
const deviceStatus = await body.json();
|
|
377
|
-
await this.
|
|
378
|
-
if (
|
|
379
|
-
await this.
|
|
397
|
+
await this.debugLog(`statusCode: ${statusCode}, deviceStatus: ${JSON.stringify(deviceStatus)}`);
|
|
398
|
+
if (await this.successfulStatusCodes(statusCode, deviceStatus)) {
|
|
399
|
+
await this.debugSuccessLog(`statusCode: ${statusCode}, deviceStatus: ${JSON.stringify(deviceStatus)}`);
|
|
380
400
|
await this.updateHomeKitCharacteristics();
|
|
381
401
|
}
|
|
382
402
|
else {
|
|
@@ -385,14 +405,13 @@ export class Humidifier extends deviceBase {
|
|
|
385
405
|
}
|
|
386
406
|
}
|
|
387
407
|
catch (e) {
|
|
388
|
-
this.apiError(e);
|
|
389
|
-
this.errorLog(
|
|
390
|
-
+ ` Connection, Error Message: ${JSON.stringify(e.message)}`);
|
|
408
|
+
await this.apiError(e);
|
|
409
|
+
await this.errorLog(`failed openAPIpushChanges with ${this.device.connectionType} Connection, Error Message: ${JSON.stringify(e.message)}`);
|
|
391
410
|
}
|
|
392
411
|
}
|
|
393
|
-
else if (this.HumidifierDehumidifier.TargetHumidifierDehumidifierState ===
|
|
394
|
-
this.hap.Characteristic.TargetHumidifierDehumidifierState.HUMIDIFIER_OR_DEHUMIDIFIER
|
|
395
|
-
this.HumidifierDehumidifier.Active === this.hap.Characteristic.Active.ACTIVE) {
|
|
412
|
+
else if ((this.HumidifierDehumidifier.TargetHumidifierDehumidifierState ===
|
|
413
|
+
this.hap.Characteristic.TargetHumidifierDehumidifierState.HUMIDIFIER_OR_DEHUMIDIFIER)
|
|
414
|
+
&& (this.HumidifierDehumidifier.Active === this.hap.Characteristic.Active.ACTIVE)) {
|
|
396
415
|
await this.pushAutoChanges();
|
|
397
416
|
}
|
|
398
417
|
else {
|
|
@@ -403,23 +422,23 @@ export class Humidifier extends deviceBase {
|
|
|
403
422
|
* Pushes the requested changes to the SwitchBot API
|
|
404
423
|
*/
|
|
405
424
|
async pushAutoChanges() {
|
|
406
|
-
this.debugLog(
|
|
407
|
-
if (this.HumidifierDehumidifier.TargetHumidifierDehumidifierState ===
|
|
408
|
-
this.hap.Characteristic.TargetHumidifierDehumidifierState.HUMIDIFIER_OR_DEHUMIDIFIER
|
|
409
|
-
this.HumidifierDehumidifier.Active === this.hap.Characteristic.Active.ACTIVE) {
|
|
410
|
-
this.debugLog(
|
|
425
|
+
this.debugLog('pushAutoChanges');
|
|
426
|
+
if ((this.HumidifierDehumidifier.TargetHumidifierDehumidifierState ===
|
|
427
|
+
this.hap.Characteristic.TargetHumidifierDehumidifierState.HUMIDIFIER_OR_DEHUMIDIFIER)
|
|
428
|
+
&& (this.HumidifierDehumidifier.Active === this.hap.Characteristic.Active.ACTIVE)) {
|
|
429
|
+
await this.debugLog('Pushing Auto');
|
|
411
430
|
const bodyChange = JSON.stringify({
|
|
412
431
|
command: 'setMode',
|
|
413
432
|
parameter: 'auto',
|
|
414
433
|
commandType: 'command',
|
|
415
434
|
});
|
|
416
|
-
this.debugLog(
|
|
435
|
+
await this.debugLog(`pushAutoChanges, SwitchBot OpenAPI bodyChange: ${JSON.stringify(bodyChange)}`);
|
|
417
436
|
try {
|
|
418
437
|
const { body, statusCode } = await this.pushChangeRequest(bodyChange);
|
|
419
438
|
const deviceStatus = await body.json();
|
|
420
|
-
await this.
|
|
421
|
-
if (
|
|
422
|
-
await this.
|
|
439
|
+
await this.debugLog(`statusCode: ${statusCode}, deviceStatus: ${JSON.stringify(deviceStatus)}`);
|
|
440
|
+
if (await this.successfulStatusCodes(statusCode, deviceStatus)) {
|
|
441
|
+
await this.debugSuccessLog(`statusCode: ${statusCode}, deviceStatus: ${JSON.stringify(deviceStatus)}`);
|
|
423
442
|
await this.updateHomeKitCharacteristics();
|
|
424
443
|
}
|
|
425
444
|
else {
|
|
@@ -428,13 +447,12 @@ export class Humidifier extends deviceBase {
|
|
|
428
447
|
}
|
|
429
448
|
}
|
|
430
449
|
catch (e) {
|
|
431
|
-
this.apiError(e);
|
|
432
|
-
this.errorLog(
|
|
433
|
-
+ ` Connection, Error Message: ${JSON.stringify(e.message)}`);
|
|
450
|
+
await this.apiError(e);
|
|
451
|
+
await this.errorLog(`failed pushAutoChanges with ${this.device.connectionType} Connection, Error Message: ${JSON.stringify(e.message)}`);
|
|
434
452
|
}
|
|
435
453
|
}
|
|
436
454
|
else {
|
|
437
|
-
this.debugLog(
|
|
455
|
+
await this.debugLog('No changes (pushAutoChanges), TargetHumidifierDehumidifierState:'
|
|
438
456
|
+ ` ${this.HumidifierDehumidifier.TargetHumidifierDehumidifierState}, Active: ${this.HumidifierDehumidifier.Active}`);
|
|
439
457
|
}
|
|
440
458
|
}
|
|
@@ -442,21 +460,21 @@ export class Humidifier extends deviceBase {
|
|
|
442
460
|
* Pushes the requested changes to the SwitchBot API
|
|
443
461
|
*/
|
|
444
462
|
async pushActiveChanges() {
|
|
445
|
-
this.debugLog(
|
|
463
|
+
await this.debugLog('pushActiveChanges');
|
|
446
464
|
if (this.HumidifierDehumidifier.Active === this.hap.Characteristic.Active.INACTIVE) {
|
|
447
|
-
this.debugLog(
|
|
465
|
+
await this.debugLog('Pushing Off');
|
|
448
466
|
const bodyChange = JSON.stringify({
|
|
449
467
|
command: 'turnOff',
|
|
450
468
|
parameter: 'default',
|
|
451
469
|
commandType: 'command',
|
|
452
470
|
});
|
|
453
|
-
this.debugLog(
|
|
471
|
+
await this.debugLog(`pushActiveChanges, SwitchBot OpenAPI bodyChange: ${JSON.stringify(bodyChange)}`);
|
|
454
472
|
try {
|
|
455
473
|
const { body, statusCode } = await this.pushChangeRequest(bodyChange);
|
|
456
474
|
const deviceStatus = await body.json();
|
|
457
|
-
await this.
|
|
458
|
-
if (
|
|
459
|
-
await this.
|
|
475
|
+
await this.debugLog(`statusCode: ${statusCode}, deviceStatus: ${JSON.stringify(deviceStatus)}`);
|
|
476
|
+
if (await this.successfulStatusCodes(statusCode, deviceStatus)) {
|
|
477
|
+
await this.debugSuccessLog(`statusCode: ${statusCode}, deviceStatus: ${JSON.stringify(deviceStatus)}`);
|
|
460
478
|
await this.updateHomeKitCharacteristics();
|
|
461
479
|
}
|
|
462
480
|
else {
|
|
@@ -465,24 +483,23 @@ export class Humidifier extends deviceBase {
|
|
|
465
483
|
}
|
|
466
484
|
}
|
|
467
485
|
catch (e) {
|
|
468
|
-
this.apiError(e);
|
|
469
|
-
this.errorLog(
|
|
470
|
-
+ ` Connection, Error Message: ${JSON.stringify(e.message)}`);
|
|
486
|
+
await this.apiError(e);
|
|
487
|
+
await this.errorLog(`failed pushActiveChanges with ${this.device.connectionType} Connection, Error Message: ${JSON.stringify(e.message)}`);
|
|
471
488
|
}
|
|
472
489
|
}
|
|
473
490
|
else {
|
|
474
|
-
this.debugLog(
|
|
491
|
+
await this.debugLog(`No changes (pushActiveChanges), Active: ${this.HumidifierDehumidifier.Active}`);
|
|
475
492
|
}
|
|
476
493
|
}
|
|
477
494
|
/**
|
|
478
495
|
* Handle requests to set the "Active" characteristic
|
|
479
496
|
*/
|
|
480
497
|
async ActiveSet(value) {
|
|
481
|
-
if (this.HumidifierDehumidifier.Active
|
|
482
|
-
this.
|
|
498
|
+
if (this.HumidifierDehumidifier.Active !== this.accessory.context.Active) {
|
|
499
|
+
await this.infoLog(`Set Active: ${value}`);
|
|
483
500
|
}
|
|
484
501
|
else {
|
|
485
|
-
this.
|
|
502
|
+
await this.debugLog(`No Changes, Active: ${value}`);
|
|
486
503
|
}
|
|
487
504
|
this.HumidifierDehumidifier.Active = value;
|
|
488
505
|
this.doHumidifierUpdate.next();
|
|
@@ -492,10 +509,10 @@ export class Humidifier extends deviceBase {
|
|
|
492
509
|
*/
|
|
493
510
|
async TargetHumidifierDehumidifierStateSet(value) {
|
|
494
511
|
if (this.HumidifierDehumidifier.Active === this.hap.Characteristic.Active.ACTIVE) {
|
|
495
|
-
this.infoLog(
|
|
512
|
+
await this.infoLog(`Set TargetHumidifierDehumidifierState: ${value}`);
|
|
496
513
|
}
|
|
497
514
|
else {
|
|
498
|
-
this.debugLog(
|
|
515
|
+
await this.debugLog(`No Changes, TargetHumidifierDehumidifierState: ${value}`);
|
|
499
516
|
}
|
|
500
517
|
this.HumidifierDehumidifier.TargetHumidifierDehumidifierState = value;
|
|
501
518
|
this.doHumidifierUpdate.next();
|
|
@@ -505,109 +522,54 @@ export class Humidifier extends deviceBase {
|
|
|
505
522
|
*/
|
|
506
523
|
async RelativeHumidityHumidifierThresholdSet(value) {
|
|
507
524
|
if (this.HumidifierDehumidifier.Active === this.hap.Characteristic.Active.ACTIVE) {
|
|
508
|
-
this.infoLog(
|
|
525
|
+
await this.infoLog(`Set RelativeHumidityHumidifierThreshold: ${value}`);
|
|
509
526
|
}
|
|
510
527
|
else {
|
|
511
|
-
this.debugLog(
|
|
528
|
+
await this.debugLog(`No Changes, RelativeHumidityHumidifierThreshold: ${value}`);
|
|
512
529
|
}
|
|
513
|
-
|
|
530
|
+
// If the Humidifier is off, turn it on
|
|
514
531
|
if (this.HumidifierDehumidifier.Active === this.hap.Characteristic.Active.INACTIVE) {
|
|
515
532
|
this.HumidifierDehumidifier.Active = this.hap.Characteristic.Active.ACTIVE;
|
|
516
533
|
this.HumidifierDehumidifier.CurrentHumidifierDehumidifierState = this.hap.Characteristic.CurrentHumidifierDehumidifierState.IDLE;
|
|
517
534
|
}
|
|
535
|
+
this.HumidifierDehumidifier.RelativeHumidityHumidifierThreshold = value;
|
|
518
536
|
this.doHumidifierUpdate.next();
|
|
519
537
|
}
|
|
520
538
|
/**
|
|
521
539
|
* Updates the status for each of the HomeKit Characteristics
|
|
522
540
|
*/
|
|
523
541
|
async updateHomeKitCharacteristics() {
|
|
524
|
-
|
|
525
|
-
|
|
526
|
-
|
|
527
|
-
|
|
528
|
-
|
|
529
|
-
|
|
530
|
-
|
|
531
|
-
|
|
532
|
-
|
|
533
|
-
|
|
534
|
-
|
|
535
|
-
|
|
536
|
-
|
|
537
|
-
|
|
538
|
-
|
|
539
|
-
this.HumidifierDehumidifier.Service.updateCharacteristic(this.hap.Characteristic.WaterLevel, this.HumidifierDehumidifier.WaterLevel);
|
|
540
|
-
this.debugLog(`${this.device.deviceType}: ${this.accessory.displayName} updateCharacteristic`
|
|
541
|
-
+ ` WaterLevel: ${this.HumidifierDehumidifier.WaterLevel}`);
|
|
542
|
-
this.accessory.context.WaterLevel = this.HumidifierDehumidifier.WaterLevel;
|
|
543
|
-
}
|
|
544
|
-
}
|
|
545
|
-
if (this.HumidifierDehumidifier.CurrentHumidifierDehumidifierState === undefined) {
|
|
546
|
-
this.debugLog(`${this.device.deviceType}: ${this.accessory.displayName}`
|
|
547
|
-
+ ` CurrentHumidifierDehumidifierState: ${this.HumidifierDehumidifier.CurrentHumidifierDehumidifierState}`);
|
|
548
|
-
}
|
|
549
|
-
else {
|
|
550
|
-
this.HumidifierDehumidifier.Service.updateCharacteristic(this.hap.Characteristic.CurrentHumidifierDehumidifierState, this.HumidifierDehumidifier.CurrentHumidifierDehumidifierState);
|
|
551
|
-
this.debugLog(`${this.device.deviceType}: ${this.accessory.displayName} updateCharacteristic`
|
|
552
|
-
+ ` CurrentHumidifierDehumidifierState: ${this.HumidifierDehumidifier.CurrentHumidifierDehumidifierState}`);
|
|
553
|
-
this.accessory.context.CurrentHumidifierDehumidifierState = this.HumidifierDehumidifier.CurrentHumidifierDehumidifierState;
|
|
554
|
-
}
|
|
555
|
-
if (this.HumidifierDehumidifier.TargetHumidifierDehumidifierState === undefined) {
|
|
556
|
-
this.debugLog(`${this.device.deviceType}: ${this.accessory.displayName}`
|
|
557
|
-
+ ` TargetHumidifierDehumidifierState: ${this.HumidifierDehumidifier.TargetHumidifierDehumidifierState}`);
|
|
558
|
-
}
|
|
559
|
-
else {
|
|
560
|
-
this.HumidifierDehumidifier.Service.updateCharacteristic(this.hap.Characteristic.TargetHumidifierDehumidifierState, this.HumidifierDehumidifier.TargetHumidifierDehumidifierState);
|
|
561
|
-
this.debugLog(`${this.device.deviceType}: ${this.accessory.displayName} updateCharacteristic`
|
|
562
|
-
+ ` TargetHumidifierDehumidifierState: ${this.HumidifierDehumidifier.TargetHumidifierDehumidifierState}`);
|
|
563
|
-
this.accessory.context.TargetHumidifierDehumidifierState = this.HumidifierDehumidifier.TargetHumidifierDehumidifierState;
|
|
564
|
-
}
|
|
565
|
-
if (this.HumidifierDehumidifier.Active === undefined) {
|
|
566
|
-
this.debugLog(`${this.device.deviceType}: ${this.accessory.displayName} Active: ${this.HumidifierDehumidifier.Active}`);
|
|
567
|
-
}
|
|
568
|
-
else {
|
|
569
|
-
this.HumidifierDehumidifier.Service.updateCharacteristic(this.hap.Characteristic.Active, this.HumidifierDehumidifier.Active);
|
|
570
|
-
this.debugLog(`${this.device.deviceType}: ${this.accessory.displayName} updateCharacteristic Active: ${this.HumidifierDehumidifier.Active}`);
|
|
571
|
-
this.accessory.context.Active = this.HumidifierDehumidifier.Active;
|
|
572
|
-
}
|
|
573
|
-
if (this.HumidifierDehumidifier.RelativeHumidityHumidifierThreshold === undefined) {
|
|
574
|
-
this.debugLog(`${this.device.deviceType}: ${this.accessory.displayName}`
|
|
575
|
-
+ ` RelativeHumidityHumidifierThreshold: ${this.HumidifierDehumidifier.RelativeHumidityHumidifierThreshold}`);
|
|
576
|
-
}
|
|
577
|
-
else {
|
|
578
|
-
this.HumidifierDehumidifier.Service.updateCharacteristic(this.hap.Characteristic.RelativeHumidityHumidifierThreshold, this.HumidifierDehumidifier.RelativeHumidityHumidifierThreshold);
|
|
579
|
-
this.debugLog(`${this.device.deviceType}: ${this.accessory.displayName} updateCharacteristic`
|
|
580
|
-
+ ` RelativeHumidityHumidifierThreshold: ${this.HumidifierDehumidifier.RelativeHumidityHumidifierThreshold}`);
|
|
581
|
-
this.accessory.context.RelativeHumidityHumidifierThreshold = this.HumidifierDehumidifier.RelativeHumidityHumidifierThreshold;
|
|
582
|
-
}
|
|
583
|
-
if (!this.device.humidifier?.hide_temperature && !this.BLE) {
|
|
584
|
-
if (this.TemperatureSensor.CurrentTemperature === undefined) {
|
|
585
|
-
this.debugLog(`${this.device.deviceType}: ${this.accessory.displayName} CurrentTemperature: ${this.TemperatureSensor.CurrentTemperature}`);
|
|
586
|
-
}
|
|
587
|
-
else {
|
|
588
|
-
this.TemperatureSensor.Service.updateCharacteristic(this.hap.Characteristic.CurrentTemperature, this.TemperatureSensor.CurrentTemperature);
|
|
589
|
-
this.debugLog(`${this.device.deviceType}: ${this.accessory.displayName} updateCharacteristic`
|
|
590
|
-
+ ` CurrentTemperature: ${this.TemperatureSensor.CurrentTemperature}`);
|
|
591
|
-
this.accessory.context.CurrentTemperature = this.TemperatureSensor.CurrentTemperature;
|
|
592
|
-
}
|
|
542
|
+
// CurrentRelativeHumidity
|
|
543
|
+
await this.updateCharacteristic(this.HumidifierDehumidifier.Service, this.hap.Characteristic.CurrentRelativeHumidity, this.HumidifierDehumidifier.CurrentRelativeHumidity, 'CurrentRelativeHumidity');
|
|
544
|
+
// WaterLevel
|
|
545
|
+
await this.updateCharacteristic(this.HumidifierDehumidifier.Service, this.hap.Characteristic.WaterLevel, this.HumidifierDehumidifier.WaterLevel, 'WaterLevel');
|
|
546
|
+
// CurrentHumidifierDehumidifierState
|
|
547
|
+
await this.updateCharacteristic(this.HumidifierDehumidifier.Service, this.hap.Characteristic.CurrentHumidifierDehumidifierState, this.HumidifierDehumidifier.CurrentHumidifierDehumidifierState, 'CurrentHumidifierDehumidifierState');
|
|
548
|
+
// TargetHumidifierDehumidifierState
|
|
549
|
+
await this.updateCharacteristic(this.HumidifierDehumidifier.Service, this.hap.Characteristic.TargetHumidifierDehumidifierState, this.HumidifierDehumidifier.TargetHumidifierDehumidifierState, 'TargetHumidifierDehumidifierState');
|
|
550
|
+
// Active
|
|
551
|
+
await this.updateCharacteristic(this.HumidifierDehumidifier.Service, this.hap.Characteristic.Active, this.HumidifierDehumidifier.Active, 'Active');
|
|
552
|
+
// RelativeHumidityHumidifierThreshold
|
|
553
|
+
await this.updateCharacteristic(this.HumidifierDehumidifier.Service, this.hap.Characteristic.RelativeHumidityHumidifierThreshold, this.HumidifierDehumidifier.RelativeHumidityHumidifierThreshold, 'RelativeHumidityHumidifierThreshold');
|
|
554
|
+
// CurrentTemperature
|
|
555
|
+
if (!this.device.humidifier?.hide_temperature && this.TemperatureSensor?.Service) {
|
|
556
|
+
await this.updateCharacteristic(this.TemperatureSensor.Service, this.hap.Characteristic.CurrentTemperature, this.TemperatureSensor.CurrentTemperature, 'CurrentTemperature');
|
|
593
557
|
}
|
|
594
558
|
}
|
|
595
559
|
async BLEPushConnection() {
|
|
596
560
|
if (this.platform.config.credentials?.token && this.device.connectionType === 'BLE/OpenAPI') {
|
|
597
|
-
this.warnLog(
|
|
561
|
+
await this.warnLog('Using OpenAPI Connection to Push Changes');
|
|
598
562
|
await this.openAPIpushChanges();
|
|
599
563
|
}
|
|
600
564
|
}
|
|
601
565
|
async BLERefreshConnection(switchbot) {
|
|
602
|
-
this.errorLog(
|
|
603
|
-
+ ` ${JSON.stringify(switchbot)}`);
|
|
566
|
+
await this.errorLog(`wasn't able to establish BLE Connection, node-switchbot: ${JSON.stringify(switchbot)}`);
|
|
604
567
|
if (this.platform.config.credentials?.token && this.device.connectionType === 'BLE/OpenAPI') {
|
|
605
|
-
this.warnLog(
|
|
568
|
+
await this.warnLog('Using OpenAPI Connection to Refresh Status');
|
|
606
569
|
await this.openAPIRefreshStatus();
|
|
607
570
|
}
|
|
608
571
|
}
|
|
609
572
|
async offlineOff() {
|
|
610
|
-
this.debugWarnLog(`${this.device.deviceType}: ${this.accessory.displayName} offline: ${this.device.offline}`);
|
|
611
573
|
if (this.device.offline) {
|
|
612
574
|
this.HumidifierDehumidifier.Service.updateCharacteristic(this.hap.Characteristic.CurrentHumidifierDehumidifierState, this.hap.Characteristic.CurrentHumidifierDehumidifierState.INACTIVE);
|
|
613
575
|
this.HumidifierDehumidifier.Service.updateCharacteristic(this.hap.Characteristic.TargetHumidifierDehumidifierState, this.hap.Characteristic.TargetHumidifierDehumidifierState.HUMIDIFIER);
|
|
@@ -616,14 +578,12 @@ export class Humidifier extends deviceBase {
|
|
|
616
578
|
}
|
|
617
579
|
async apiError(e) {
|
|
618
580
|
this.HumidifierDehumidifier.Service.updateCharacteristic(this.hap.Characteristic.CurrentRelativeHumidity, e);
|
|
619
|
-
|
|
620
|
-
this.HumidifierDehumidifier.Service.updateCharacteristic(this.hap.Characteristic.WaterLevel, e);
|
|
621
|
-
}
|
|
581
|
+
this.HumidifierDehumidifier.Service.updateCharacteristic(this.hap.Characteristic.WaterLevel, e);
|
|
622
582
|
this.HumidifierDehumidifier.Service.updateCharacteristic(this.hap.Characteristic.CurrentHumidifierDehumidifierState, e);
|
|
623
583
|
this.HumidifierDehumidifier.Service.updateCharacteristic(this.hap.Characteristic.TargetHumidifierDehumidifierState, e);
|
|
624
584
|
this.HumidifierDehumidifier.Service.updateCharacteristic(this.hap.Characteristic.Active, e);
|
|
625
585
|
this.HumidifierDehumidifier.Service.updateCharacteristic(this.hap.Characteristic.RelativeHumidityHumidifierThreshold, e);
|
|
626
|
-
if (!this.device.humidifier?.hide_temperature &&
|
|
586
|
+
if (!this.device.humidifier?.hide_temperature && this.TemperatureSensor?.Service) {
|
|
627
587
|
this.TemperatureSensor.Service.updateCharacteristic(this.hap.Characteristic.CurrentTemperature, e);
|
|
628
588
|
}
|
|
629
589
|
}
|