@switchbot/homebridge-switchbot 3.5.1-beta.0 → 3.5.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/README.md +16 -0
- package/dist/device/blindtilt.d.ts +15 -6
- package/dist/device/blindtilt.d.ts.map +1 -1
- package/dist/device/blindtilt.js +224 -370
- 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 +197 -221
- package/dist/device/bot.js.map +1 -1
- package/dist/device/ceilinglight.d.ts +10 -5
- package/dist/device/ceilinglight.d.ts.map +1 -1
- package/dist/device/ceilinglight.js +214 -292
- 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 +335 -421
- 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 +121 -200
- package/dist/device/contact.js.map +1 -1
- package/dist/device/curtain.d.ts +20 -7
- package/dist/device/curtain.d.ts.map +1 -1
- package/dist/device/curtain.js +229 -403
- package/dist/device/curtain.js.map +1 -1
- package/dist/device/device.d.ts +41 -22
- package/dist/device/device.d.ts.map +1 -1
- package/dist/device/device.js +212 -181
- 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 +204 -249
- 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 +107 -233
- 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 +193 -235
- 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 +92 -159
- 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 +288 -370
- 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 +172 -219
- 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 +94 -160
- 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 +95 -157
- 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 +85 -144
- 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 +100 -127
- 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 +172 -259
- 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 +106 -131
- 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 +2 -3
- 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 +2 -3
- 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 +2 -3
- 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 +2 -3
- package/dist/irdevice/fan.js.map +1 -1
- package/dist/irdevice/irdevice.d.ts +3 -1
- package/dist/irdevice/irdevice.d.ts.map +1 -1
- package/dist/irdevice/irdevice.js +5 -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 +2 -3
- 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 +2 -3
- 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 +2 -3
- 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 +2 -3
- 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 +2 -3
- package/dist/irdevice/waterheater.js.map +1 -1
- package/dist/platform.d.ts +14 -14
- package/dist/platform.d.ts.map +1 -1
- package/dist/platform.js +102 -86
- package/dist/platform.js.map +1 -1
- package/dist/settings.d.ts +49 -190
- 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 +11 -11
- package/src/device/blindtilt.ts +254 -376
- package/src/device/bot.ts +209 -224
- package/src/device/ceilinglight.ts +227 -297
- package/src/device/colorbulb.ts +345 -435
- package/src/device/contact.ts +139 -200
- package/src/device/curtain.ts +254 -414
- package/src/device/device.ts +221 -190
- package/src/device/fan.ts +222 -253
- package/src/device/hub.ts +127 -248
- package/src/device/humidifier.ts +217 -246
- package/src/device/iosensor.ts +115 -168
- package/src/device/lightstrip.ts +303 -380
- package/src/device/lock.ts +188 -224
- package/src/device/meter.ts +117 -179
- package/src/device/meterplus.ts +118 -176
- package/src/device/motion.ts +100 -146
- package/src/device/plug.ts +111 -131
- package/src/device/robotvacuumcleaner.ts +191 -258
- package/src/device/waterdetector.ts +124 -141
- package/src/irdevice/airconditioner.ts +4 -4
- package/src/irdevice/airpurifier.ts +4 -4
- package/src/irdevice/camera.ts +4 -4
- package/src/irdevice/fan.ts +4 -4
- package/src/irdevice/irdevice.ts +8 -2
- package/src/irdevice/light.ts +4 -4
- package/src/irdevice/other.ts +4 -4
- package/src/irdevice/tv.ts +4 -4
- package/src/irdevice/vacuumcleaner.ts +4 -4
- package/src/irdevice/waterheater.ts +4 -4
- package/src/platform.ts +104 -87
- package/src/settings.ts +30 -238
- 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,58 +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
|
-
this.apiError(e);
|
|
288
|
-
this.errorLog(
|
|
289
|
-
+ ` Connection, Error Message: ${JSON.stringify(e.message)}`);
|
|
303
|
+
await this.apiError(e);
|
|
304
|
+
await this.errorLog(`failed openAPIRefreshStatus with ${this.device.connectionType} Connection, Error Message: ${JSON.stringify(e.message)}`);
|
|
290
305
|
}
|
|
291
306
|
}
|
|
292
|
-
async registerWebhook(
|
|
293
|
-
if (device.webhook) {
|
|
294
|
-
this.debugLog(
|
|
295
|
-
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) => {
|
|
296
311
|
try {
|
|
297
|
-
this.debugLog(
|
|
298
|
-
|
|
299
|
-
|
|
300
|
-
const { CurrentTemperature } = this.TemperatureSensor || { CurrentTemperature: undefined };
|
|
301
|
-
this.debugLog(`${device.deviceType}: ${accessory.displayName} (temperature, humidity) = Webhook:(${convertUnits(temperature, context.scale, device.iosensor?.convertUnitTo)}, ${humidity}), current:(${CurrentTemperature}, ${CurrentRelativeHumidity})`);
|
|
302
|
-
this.HumidifierDehumidifier.CurrentRelativeHumidity = humidity;
|
|
303
|
-
if (!device.humidifier?.hide_temperature) {
|
|
304
|
-
this.TemperatureSensor.CurrentTemperature = convertUnits(temperature, context.scale, device.iosensor?.convertUnitTo);
|
|
305
|
-
}
|
|
306
|
-
this.updateHomeKitCharacteristics();
|
|
312
|
+
await this.debugLog(`received Webhook: ${JSON.stringify(context)}`);
|
|
313
|
+
await this.parseStatusWebhook(context);
|
|
314
|
+
await this.updateHomeKitCharacteristics();
|
|
307
315
|
}
|
|
308
316
|
catch (e) {
|
|
309
|
-
this.errorLog(
|
|
310
|
-
+ `failed to handle webhook. Received: ${JSON.stringify(context)} Error: ${e}`);
|
|
317
|
+
await this.errorLog(`failed to handle webhook. Received: ${JSON.stringify(context)} Error: ${e}`);
|
|
311
318
|
}
|
|
312
319
|
};
|
|
313
320
|
}
|
|
@@ -317,7 +324,7 @@ export class Humidifier extends deviceBase {
|
|
|
317
324
|
*/
|
|
318
325
|
async pushChanges() {
|
|
319
326
|
if (!this.device.enableCloudService && this.OpenAPI) {
|
|
320
|
-
this.errorLog(
|
|
327
|
+
await this.errorLog(`pushChanges enableCloudService: ${this.device.enableCloudService}`);
|
|
321
328
|
}
|
|
322
329
|
else if (this.BLE) {
|
|
323
330
|
await this.BLEpushChanges();
|
|
@@ -327,8 +334,7 @@ export class Humidifier extends deviceBase {
|
|
|
327
334
|
}
|
|
328
335
|
else {
|
|
329
336
|
await this.offlineOff();
|
|
330
|
-
this.debugWarnLog(
|
|
331
|
-
+ ` ${this.device.connectionType}, pushChanges will not happen.`);
|
|
337
|
+
await this.debugWarnLog(`Connection Type: ${this.device.connectionType}, pushChanges will not happen.`);
|
|
332
338
|
}
|
|
333
339
|
// Refresh the status from the API
|
|
334
340
|
interval(15000)
|
|
@@ -339,46 +345,58 @@ export class Humidifier extends deviceBase {
|
|
|
339
345
|
});
|
|
340
346
|
}
|
|
341
347
|
async BLEpushChanges() {
|
|
342
|
-
this.debugLog(
|
|
343
|
-
|
|
344
|
-
|
|
345
|
-
|
|
346
|
-
|
|
347
|
-
|
|
348
|
-
|
|
349
|
-
|
|
350
|
-
|
|
351
|
-
|
|
352
|
-
|
|
353
|
-
|
|
354
|
-
|
|
355
|
-
|
|
356
|
-
|
|
357
|
-
|
|
358
|
-
|
|
359
|
-
|
|
360
|
-
|
|
361
|
-
|
|
362
|
-
|
|
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
|
+
}
|
|
363
381
|
}
|
|
364
382
|
async openAPIpushChanges() {
|
|
365
|
-
this.debugLog(
|
|
366
|
-
if (this.HumidifierDehumidifier.TargetHumidifierDehumidifierState === this.hap.Characteristic.TargetHumidifierDehumidifierState.HUMIDIFIER
|
|
367
|
-
this.HumidifierDehumidifier.Active === this.hap.Characteristic.Active.ACTIVE)
|
|
368
|
-
|
|
369
|
-
|
|
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}!`);
|
|
370
388
|
const bodyChange = JSON.stringify({
|
|
371
389
|
command: 'setMode',
|
|
372
390
|
parameter: `${this.HumidifierDehumidifier.RelativeHumidityHumidifierThreshold}`,
|
|
373
391
|
commandType: 'command',
|
|
374
392
|
});
|
|
375
|
-
this.debugLog(
|
|
393
|
+
await this.debugLog(`SwitchBot OpenAPI bodyChange: ${JSON.stringify(bodyChange)}`);
|
|
376
394
|
try {
|
|
377
395
|
const { body, statusCode } = await this.pushChangeRequest(bodyChange);
|
|
378
396
|
const deviceStatus = await body.json();
|
|
379
|
-
await this.
|
|
380
|
-
if (
|
|
381
|
-
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)}`);
|
|
382
400
|
await this.updateHomeKitCharacteristics();
|
|
383
401
|
}
|
|
384
402
|
else {
|
|
@@ -387,14 +405,13 @@ export class Humidifier extends deviceBase {
|
|
|
387
405
|
}
|
|
388
406
|
}
|
|
389
407
|
catch (e) {
|
|
390
|
-
this.apiError(e);
|
|
391
|
-
this.errorLog(
|
|
392
|
-
+ ` 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)}`);
|
|
393
410
|
}
|
|
394
411
|
}
|
|
395
|
-
else if (this.HumidifierDehumidifier.TargetHumidifierDehumidifierState ===
|
|
396
|
-
this.hap.Characteristic.TargetHumidifierDehumidifierState.HUMIDIFIER_OR_DEHUMIDIFIER
|
|
397
|
-
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)) {
|
|
398
415
|
await this.pushAutoChanges();
|
|
399
416
|
}
|
|
400
417
|
else {
|
|
@@ -405,23 +422,23 @@ export class Humidifier extends deviceBase {
|
|
|
405
422
|
* Pushes the requested changes to the SwitchBot API
|
|
406
423
|
*/
|
|
407
424
|
async pushAutoChanges() {
|
|
408
|
-
this.debugLog(
|
|
409
|
-
if (this.HumidifierDehumidifier.TargetHumidifierDehumidifierState ===
|
|
410
|
-
this.hap.Characteristic.TargetHumidifierDehumidifierState.HUMIDIFIER_OR_DEHUMIDIFIER
|
|
411
|
-
this.HumidifierDehumidifier.Active === this.hap.Characteristic.Active.ACTIVE) {
|
|
412
|
-
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');
|
|
413
430
|
const bodyChange = JSON.stringify({
|
|
414
431
|
command: 'setMode',
|
|
415
432
|
parameter: 'auto',
|
|
416
433
|
commandType: 'command',
|
|
417
434
|
});
|
|
418
|
-
this.debugLog(
|
|
435
|
+
await this.debugLog(`pushAutoChanges, SwitchBot OpenAPI bodyChange: ${JSON.stringify(bodyChange)}`);
|
|
419
436
|
try {
|
|
420
437
|
const { body, statusCode } = await this.pushChangeRequest(bodyChange);
|
|
421
438
|
const deviceStatus = await body.json();
|
|
422
|
-
await this.
|
|
423
|
-
if (
|
|
424
|
-
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)}`);
|
|
425
442
|
await this.updateHomeKitCharacteristics();
|
|
426
443
|
}
|
|
427
444
|
else {
|
|
@@ -430,13 +447,12 @@ export class Humidifier extends deviceBase {
|
|
|
430
447
|
}
|
|
431
448
|
}
|
|
432
449
|
catch (e) {
|
|
433
|
-
this.apiError(e);
|
|
434
|
-
this.errorLog(
|
|
435
|
-
+ ` 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)}`);
|
|
436
452
|
}
|
|
437
453
|
}
|
|
438
454
|
else {
|
|
439
|
-
this.debugLog(
|
|
455
|
+
await this.debugLog('No changes (pushAutoChanges), TargetHumidifierDehumidifierState:'
|
|
440
456
|
+ ` ${this.HumidifierDehumidifier.TargetHumidifierDehumidifierState}, Active: ${this.HumidifierDehumidifier.Active}`);
|
|
441
457
|
}
|
|
442
458
|
}
|
|
@@ -444,21 +460,21 @@ export class Humidifier extends deviceBase {
|
|
|
444
460
|
* Pushes the requested changes to the SwitchBot API
|
|
445
461
|
*/
|
|
446
462
|
async pushActiveChanges() {
|
|
447
|
-
this.debugLog(
|
|
463
|
+
await this.debugLog('pushActiveChanges');
|
|
448
464
|
if (this.HumidifierDehumidifier.Active === this.hap.Characteristic.Active.INACTIVE) {
|
|
449
|
-
this.debugLog(
|
|
465
|
+
await this.debugLog('Pushing Off');
|
|
450
466
|
const bodyChange = JSON.stringify({
|
|
451
467
|
command: 'turnOff',
|
|
452
468
|
parameter: 'default',
|
|
453
469
|
commandType: 'command',
|
|
454
470
|
});
|
|
455
|
-
this.debugLog(
|
|
471
|
+
await this.debugLog(`pushActiveChanges, SwitchBot OpenAPI bodyChange: ${JSON.stringify(bodyChange)}`);
|
|
456
472
|
try {
|
|
457
473
|
const { body, statusCode } = await this.pushChangeRequest(bodyChange);
|
|
458
474
|
const deviceStatus = await body.json();
|
|
459
|
-
await this.
|
|
460
|
-
if (
|
|
461
|
-
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)}`);
|
|
462
478
|
await this.updateHomeKitCharacteristics();
|
|
463
479
|
}
|
|
464
480
|
else {
|
|
@@ -467,24 +483,23 @@ export class Humidifier extends deviceBase {
|
|
|
467
483
|
}
|
|
468
484
|
}
|
|
469
485
|
catch (e) {
|
|
470
|
-
this.apiError(e);
|
|
471
|
-
this.errorLog(
|
|
472
|
-
+ ` 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)}`);
|
|
473
488
|
}
|
|
474
489
|
}
|
|
475
490
|
else {
|
|
476
|
-
this.debugLog(
|
|
491
|
+
await this.debugLog(`No changes (pushActiveChanges), Active: ${this.HumidifierDehumidifier.Active}`);
|
|
477
492
|
}
|
|
478
493
|
}
|
|
479
494
|
/**
|
|
480
495
|
* Handle requests to set the "Active" characteristic
|
|
481
496
|
*/
|
|
482
497
|
async ActiveSet(value) {
|
|
483
|
-
if (this.HumidifierDehumidifier.Active
|
|
484
|
-
this.
|
|
498
|
+
if (this.HumidifierDehumidifier.Active !== this.accessory.context.Active) {
|
|
499
|
+
await this.infoLog(`Set Active: ${value}`);
|
|
485
500
|
}
|
|
486
501
|
else {
|
|
487
|
-
this.
|
|
502
|
+
await this.debugLog(`No Changes, Active: ${value}`);
|
|
488
503
|
}
|
|
489
504
|
this.HumidifierDehumidifier.Active = value;
|
|
490
505
|
this.doHumidifierUpdate.next();
|
|
@@ -494,10 +509,10 @@ export class Humidifier extends deviceBase {
|
|
|
494
509
|
*/
|
|
495
510
|
async TargetHumidifierDehumidifierStateSet(value) {
|
|
496
511
|
if (this.HumidifierDehumidifier.Active === this.hap.Characteristic.Active.ACTIVE) {
|
|
497
|
-
this.infoLog(
|
|
512
|
+
await this.infoLog(`Set TargetHumidifierDehumidifierState: ${value}`);
|
|
498
513
|
}
|
|
499
514
|
else {
|
|
500
|
-
this.debugLog(
|
|
515
|
+
await this.debugLog(`No Changes, TargetHumidifierDehumidifierState: ${value}`);
|
|
501
516
|
}
|
|
502
517
|
this.HumidifierDehumidifier.TargetHumidifierDehumidifierState = value;
|
|
503
518
|
this.doHumidifierUpdate.next();
|
|
@@ -507,109 +522,54 @@ export class Humidifier extends deviceBase {
|
|
|
507
522
|
*/
|
|
508
523
|
async RelativeHumidityHumidifierThresholdSet(value) {
|
|
509
524
|
if (this.HumidifierDehumidifier.Active === this.hap.Characteristic.Active.ACTIVE) {
|
|
510
|
-
this.infoLog(
|
|
525
|
+
await this.infoLog(`Set RelativeHumidityHumidifierThreshold: ${value}`);
|
|
511
526
|
}
|
|
512
527
|
else {
|
|
513
|
-
this.debugLog(
|
|
528
|
+
await this.debugLog(`No Changes, RelativeHumidityHumidifierThreshold: ${value}`);
|
|
514
529
|
}
|
|
515
|
-
|
|
530
|
+
// If the Humidifier is off, turn it on
|
|
516
531
|
if (this.HumidifierDehumidifier.Active === this.hap.Characteristic.Active.INACTIVE) {
|
|
517
532
|
this.HumidifierDehumidifier.Active = this.hap.Characteristic.Active.ACTIVE;
|
|
518
533
|
this.HumidifierDehumidifier.CurrentHumidifierDehumidifierState = this.hap.Characteristic.CurrentHumidifierDehumidifierState.IDLE;
|
|
519
534
|
}
|
|
535
|
+
this.HumidifierDehumidifier.RelativeHumidityHumidifierThreshold = value;
|
|
520
536
|
this.doHumidifierUpdate.next();
|
|
521
537
|
}
|
|
522
538
|
/**
|
|
523
539
|
* Updates the status for each of the HomeKit Characteristics
|
|
524
540
|
*/
|
|
525
541
|
async updateHomeKitCharacteristics() {
|
|
526
|
-
|
|
527
|
-
|
|
528
|
-
|
|
529
|
-
|
|
530
|
-
|
|
531
|
-
|
|
532
|
-
|
|
533
|
-
|
|
534
|
-
|
|
535
|
-
|
|
536
|
-
|
|
537
|
-
|
|
538
|
-
|
|
539
|
-
|
|
540
|
-
|
|
541
|
-
this.HumidifierDehumidifier.Service.updateCharacteristic(this.hap.Characteristic.WaterLevel, this.HumidifierDehumidifier.WaterLevel);
|
|
542
|
-
this.debugLog(`${this.device.deviceType}: ${this.accessory.displayName} updateCharacteristic`
|
|
543
|
-
+ ` WaterLevel: ${this.HumidifierDehumidifier.WaterLevel}`);
|
|
544
|
-
this.accessory.context.WaterLevel = this.HumidifierDehumidifier.WaterLevel;
|
|
545
|
-
}
|
|
546
|
-
}
|
|
547
|
-
if (this.HumidifierDehumidifier.CurrentHumidifierDehumidifierState === undefined) {
|
|
548
|
-
this.debugLog(`${this.device.deviceType}: ${this.accessory.displayName}`
|
|
549
|
-
+ ` CurrentHumidifierDehumidifierState: ${this.HumidifierDehumidifier.CurrentHumidifierDehumidifierState}`);
|
|
550
|
-
}
|
|
551
|
-
else {
|
|
552
|
-
this.HumidifierDehumidifier.Service.updateCharacteristic(this.hap.Characteristic.CurrentHumidifierDehumidifierState, this.HumidifierDehumidifier.CurrentHumidifierDehumidifierState);
|
|
553
|
-
this.debugLog(`${this.device.deviceType}: ${this.accessory.displayName} updateCharacteristic`
|
|
554
|
-
+ ` CurrentHumidifierDehumidifierState: ${this.HumidifierDehumidifier.CurrentHumidifierDehumidifierState}`);
|
|
555
|
-
this.accessory.context.CurrentHumidifierDehumidifierState = this.HumidifierDehumidifier.CurrentHumidifierDehumidifierState;
|
|
556
|
-
}
|
|
557
|
-
if (this.HumidifierDehumidifier.TargetHumidifierDehumidifierState === undefined) {
|
|
558
|
-
this.debugLog(`${this.device.deviceType}: ${this.accessory.displayName}`
|
|
559
|
-
+ ` TargetHumidifierDehumidifierState: ${this.HumidifierDehumidifier.TargetHumidifierDehumidifierState}`);
|
|
560
|
-
}
|
|
561
|
-
else {
|
|
562
|
-
this.HumidifierDehumidifier.Service.updateCharacteristic(this.hap.Characteristic.TargetHumidifierDehumidifierState, this.HumidifierDehumidifier.TargetHumidifierDehumidifierState);
|
|
563
|
-
this.debugLog(`${this.device.deviceType}: ${this.accessory.displayName} updateCharacteristic`
|
|
564
|
-
+ ` TargetHumidifierDehumidifierState: ${this.HumidifierDehumidifier.TargetHumidifierDehumidifierState}`);
|
|
565
|
-
this.accessory.context.TargetHumidifierDehumidifierState = this.HumidifierDehumidifier.TargetHumidifierDehumidifierState;
|
|
566
|
-
}
|
|
567
|
-
if (this.HumidifierDehumidifier.Active === undefined) {
|
|
568
|
-
this.debugLog(`${this.device.deviceType}: ${this.accessory.displayName} Active: ${this.HumidifierDehumidifier.Active}`);
|
|
569
|
-
}
|
|
570
|
-
else {
|
|
571
|
-
this.HumidifierDehumidifier.Service.updateCharacteristic(this.hap.Characteristic.Active, this.HumidifierDehumidifier.Active);
|
|
572
|
-
this.debugLog(`${this.device.deviceType}: ${this.accessory.displayName} updateCharacteristic Active: ${this.HumidifierDehumidifier.Active}`);
|
|
573
|
-
this.accessory.context.Active = this.HumidifierDehumidifier.Active;
|
|
574
|
-
}
|
|
575
|
-
if (this.HumidifierDehumidifier.RelativeHumidityHumidifierThreshold === undefined) {
|
|
576
|
-
this.debugLog(`${this.device.deviceType}: ${this.accessory.displayName}`
|
|
577
|
-
+ ` RelativeHumidityHumidifierThreshold: ${this.HumidifierDehumidifier.RelativeHumidityHumidifierThreshold}`);
|
|
578
|
-
}
|
|
579
|
-
else {
|
|
580
|
-
this.HumidifierDehumidifier.Service.updateCharacteristic(this.hap.Characteristic.RelativeHumidityHumidifierThreshold, this.HumidifierDehumidifier.RelativeHumidityHumidifierThreshold);
|
|
581
|
-
this.debugLog(`${this.device.deviceType}: ${this.accessory.displayName} updateCharacteristic`
|
|
582
|
-
+ ` RelativeHumidityHumidifierThreshold: ${this.HumidifierDehumidifier.RelativeHumidityHumidifierThreshold}`);
|
|
583
|
-
this.accessory.context.RelativeHumidityHumidifierThreshold = this.HumidifierDehumidifier.RelativeHumidityHumidifierThreshold;
|
|
584
|
-
}
|
|
585
|
-
if (!this.device.humidifier?.hide_temperature && !this.BLE) {
|
|
586
|
-
if (this.TemperatureSensor.CurrentTemperature === undefined) {
|
|
587
|
-
this.debugLog(`${this.device.deviceType}: ${this.accessory.displayName} CurrentTemperature: ${this.TemperatureSensor.CurrentTemperature}`);
|
|
588
|
-
}
|
|
589
|
-
else {
|
|
590
|
-
this.TemperatureSensor.Service.updateCharacteristic(this.hap.Characteristic.CurrentTemperature, this.TemperatureSensor.CurrentTemperature);
|
|
591
|
-
this.debugLog(`${this.device.deviceType}: ${this.accessory.displayName} updateCharacteristic`
|
|
592
|
-
+ ` CurrentTemperature: ${this.TemperatureSensor.CurrentTemperature}`);
|
|
593
|
-
this.accessory.context.CurrentTemperature = this.TemperatureSensor.CurrentTemperature;
|
|
594
|
-
}
|
|
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');
|
|
595
557
|
}
|
|
596
558
|
}
|
|
597
559
|
async BLEPushConnection() {
|
|
598
560
|
if (this.platform.config.credentials?.token && this.device.connectionType === 'BLE/OpenAPI') {
|
|
599
|
-
this.warnLog(
|
|
561
|
+
await this.warnLog('Using OpenAPI Connection to Push Changes');
|
|
600
562
|
await this.openAPIpushChanges();
|
|
601
563
|
}
|
|
602
564
|
}
|
|
603
565
|
async BLERefreshConnection(switchbot) {
|
|
604
|
-
this.errorLog(
|
|
605
|
-
+ ` ${JSON.stringify(switchbot)}`);
|
|
566
|
+
await this.errorLog(`wasn't able to establish BLE Connection, node-switchbot: ${JSON.stringify(switchbot)}`);
|
|
606
567
|
if (this.platform.config.credentials?.token && this.device.connectionType === 'BLE/OpenAPI') {
|
|
607
|
-
this.warnLog(
|
|
568
|
+
await this.warnLog('Using OpenAPI Connection to Refresh Status');
|
|
608
569
|
await this.openAPIRefreshStatus();
|
|
609
570
|
}
|
|
610
571
|
}
|
|
611
572
|
async offlineOff() {
|
|
612
|
-
this.debugWarnLog(`${this.device.deviceType}: ${this.accessory.displayName} offline: ${this.device.offline}`);
|
|
613
573
|
if (this.device.offline) {
|
|
614
574
|
this.HumidifierDehumidifier.Service.updateCharacteristic(this.hap.Characteristic.CurrentHumidifierDehumidifierState, this.hap.Characteristic.CurrentHumidifierDehumidifierState.INACTIVE);
|
|
615
575
|
this.HumidifierDehumidifier.Service.updateCharacteristic(this.hap.Characteristic.TargetHumidifierDehumidifierState, this.hap.Characteristic.TargetHumidifierDehumidifierState.HUMIDIFIER);
|
|
@@ -618,14 +578,12 @@ export class Humidifier extends deviceBase {
|
|
|
618
578
|
}
|
|
619
579
|
async apiError(e) {
|
|
620
580
|
this.HumidifierDehumidifier.Service.updateCharacteristic(this.hap.Characteristic.CurrentRelativeHumidity, e);
|
|
621
|
-
|
|
622
|
-
this.HumidifierDehumidifier.Service.updateCharacteristic(this.hap.Characteristic.WaterLevel, e);
|
|
623
|
-
}
|
|
581
|
+
this.HumidifierDehumidifier.Service.updateCharacteristic(this.hap.Characteristic.WaterLevel, e);
|
|
624
582
|
this.HumidifierDehumidifier.Service.updateCharacteristic(this.hap.Characteristic.CurrentHumidifierDehumidifierState, e);
|
|
625
583
|
this.HumidifierDehumidifier.Service.updateCharacteristic(this.hap.Characteristic.TargetHumidifierDehumidifierState, e);
|
|
626
584
|
this.HumidifierDehumidifier.Service.updateCharacteristic(this.hap.Characteristic.Active, e);
|
|
627
585
|
this.HumidifierDehumidifier.Service.updateCharacteristic(this.hap.Characteristic.RelativeHumidityHumidifierThreshold, e);
|
|
628
|
-
if (!this.device.humidifier?.hide_temperature &&
|
|
586
|
+
if (!this.device.humidifier?.hide_temperature && this.TemperatureSensor?.Service) {
|
|
629
587
|
this.TemperatureSensor.Service.updateCharacteristic(this.hap.Characteristic.CurrentTemperature, e);
|
|
630
588
|
}
|
|
631
589
|
}
|