@switchbot/homebridge-switchbot 1.8.2 → 1.8.3-beta.0
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/.eslintrc +1 -1
- package/.vscode/extensions.json +5 -0
- package/.vscode/settings.json +15 -0
- package/dist/devices/bots.d.ts +34 -35
- package/dist/devices/bots.d.ts.map +1 -1
- package/dist/devices/bots.js +241 -184
- package/dist/devices/bots.js.map +1 -1
- package/dist/devices/colorbulb.d.ts +50 -50
- package/dist/devices/colorbulb.d.ts.map +1 -1
- package/dist/devices/colorbulb.js +145 -131
- package/dist/devices/colorbulb.js.map +1 -1
- package/dist/devices/contact.d.ts +27 -29
- package/dist/devices/contact.d.ts.map +1 -1
- package/dist/devices/contact.js +138 -115
- package/dist/devices/contact.js.map +1 -1
- package/dist/devices/curtains.d.ts +29 -31
- package/dist/devices/curtains.d.ts.map +1 -1
- package/dist/devices/curtains.js +211 -176
- package/dist/devices/curtains.js.map +1 -1
- package/dist/devices/humidifiers.d.ts +33 -33
- package/dist/devices/humidifiers.d.ts.map +1 -1
- package/dist/devices/humidifiers.js +214 -189
- package/dist/devices/humidifiers.js.map +1 -1
- package/dist/devices/meters.d.ts +30 -31
- package/dist/devices/meters.d.ts.map +1 -1
- package/dist/devices/meters.js +124 -100
- package/dist/devices/meters.js.map +1 -1
- package/dist/devices/motion.d.ts +25 -26
- package/dist/devices/motion.d.ts.map +1 -1
- package/dist/devices/motion.js +120 -102
- package/dist/devices/motion.js.map +1 -1
- package/dist/devices/plugs.d.ts +23 -23
- package/dist/devices/plugs.d.ts.map +1 -1
- package/dist/devices/plugs.js +81 -63
- package/dist/devices/plugs.js.map +1 -1
- package/dist/index.d.ts +2 -2
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +22 -3
- package/dist/index.js.map +1 -1
- package/dist/irdevices/airconditioners.d.ts +6 -6
- package/dist/irdevices/airconditioners.d.ts.map +1 -1
- package/dist/irdevices/airconditioners.js +105 -79
- package/dist/irdevices/airconditioners.js.map +1 -1
- package/dist/irdevices/airpurifiers.d.ts +5 -5
- package/dist/irdevices/airpurifiers.d.ts.map +1 -1
- package/dist/irdevices/airpurifiers.js +56 -42
- package/dist/irdevices/airpurifiers.js.map +1 -1
- package/dist/irdevices/cameras.d.ts +5 -5
- package/dist/irdevices/cameras.d.ts.map +1 -1
- package/dist/irdevices/cameras.js +31 -27
- package/dist/irdevices/cameras.js.map +1 -1
- package/dist/irdevices/fans.d.ts +5 -5
- package/dist/irdevices/fans.d.ts.map +1 -1
- package/dist/irdevices/fans.js +45 -38
- package/dist/irdevices/fans.js.map +1 -1
- package/dist/irdevices/lights.d.ts +5 -5
- package/dist/irdevices/lights.d.ts.map +1 -1
- package/dist/irdevices/lights.js +37 -33
- package/dist/irdevices/lights.js.map +1 -1
- package/dist/irdevices/others.d.ts +5 -5
- package/dist/irdevices/others.d.ts.map +1 -1
- package/dist/irdevices/others.js +34 -29
- package/dist/irdevices/others.js.map +1 -1
- package/dist/irdevices/tvs.d.ts +5 -5
- package/dist/irdevices/tvs.d.ts.map +1 -1
- package/dist/irdevices/tvs.js +91 -76
- package/dist/irdevices/tvs.js.map +1 -1
- package/dist/irdevices/vacuumcleaners.d.ts +5 -5
- package/dist/irdevices/vacuumcleaners.d.ts.map +1 -1
- package/dist/irdevices/vacuumcleaners.js +31 -27
- package/dist/irdevices/vacuumcleaners.js.map +1 -1
- package/dist/irdevices/waterheaters.d.ts +5 -5
- package/dist/irdevices/waterheaters.d.ts.map +1 -1
- package/dist/irdevices/waterheaters.js +31 -27
- package/dist/irdevices/waterheaters.js.map +1 -1
- package/dist/platform.d.ts +12 -12
- package/dist/platform.d.ts.map +1 -1
- package/dist/platform.js +241 -172
- package/dist/platform.js.map +1 -1
- package/dist/settings.d.ts +1 -1
- package/dist/settings.d.ts.map +1 -1
- package/dist/settings.js +4 -4
- package/dist/settings.js.map +1 -1
- package/package.json +72 -71
- package/src/devices/bots.ts +927 -442
- package/src/devices/colorbulb.ts +473 -246
- package/src/devices/contact.ts +381 -208
- package/src/devices/curtains.ts +613 -321
- package/src/devices/humidifiers.ts +594 -323
- package/src/devices/meters.ts +331 -186
- package/src/devices/motion.ts +327 -184
- package/src/devices/plugs.ts +175 -107
- package/src/index.ts +5 -5
- package/src/irdevices/airconditioners.ts +360 -149
- package/src/irdevices/airpurifiers.ts +178 -80
- package/src/irdevices/cameras.ts +109 -51
- package/src/irdevices/fans.ts +174 -77
- package/src/irdevices/lights.ts +110 -57
- package/src/irdevices/others.ts +137 -62
- package/src/irdevices/tvs.ts +249 -124
- package/src/irdevices/vacuumcleaners.ts +112 -52
- package/src/irdevices/waterheaters.ts +115 -53
- package/src/platform.ts +768 -357
- package/src/settings.ts +17 -23
|
@@ -1,9 +1,28 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } });
|
|
5
|
+
}) : (function(o, m, k, k2) {
|
|
6
|
+
if (k2 === undefined) k2 = k;
|
|
7
|
+
o[k2] = m[k];
|
|
8
|
+
}));
|
|
9
|
+
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
10
|
+
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
11
|
+
}) : function(o, v) {
|
|
12
|
+
o["default"] = v;
|
|
13
|
+
});
|
|
14
|
+
var __importStar = (this && this.__importStar) || function (mod) {
|
|
15
|
+
if (mod && mod.__esModule) return mod;
|
|
16
|
+
var result = {};
|
|
17
|
+
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
|
|
18
|
+
__setModuleDefault(result, mod);
|
|
19
|
+
return result;
|
|
20
|
+
};
|
|
2
21
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
22
|
exports.Humidifier = void 0;
|
|
4
|
-
const
|
|
5
|
-
const
|
|
6
|
-
const
|
|
23
|
+
const rxjs = __importStar(require("rxjs"));
|
|
24
|
+
const operators = __importStar(require("rxjs/operators"));
|
|
25
|
+
const settings = __importStar(require("../settings"));
|
|
7
26
|
/**
|
|
8
27
|
* Platform Accessory
|
|
9
28
|
* An instance of this class is created for each accessory your platform registers
|
|
@@ -20,31 +39,31 @@ class Humidifier {
|
|
|
20
39
|
this.refreshRate(device);
|
|
21
40
|
this.config(device);
|
|
22
41
|
this.CurrentRelativeHumidity = 0;
|
|
23
|
-
this.TargetHumidifierDehumidifierState =
|
|
24
|
-
|
|
42
|
+
this.TargetHumidifierDehumidifierState =
|
|
43
|
+
this.platform.Characteristic.TargetHumidifierDehumidifierState.HUMIDIFIER;
|
|
44
|
+
this.CurrentHumidifierDehumidifierState =
|
|
45
|
+
this.platform.Characteristic.CurrentHumidifierDehumidifierState.INACTIVE;
|
|
25
46
|
this.Active = this.platform.Characteristic.Active.ACTIVE;
|
|
26
47
|
this.RelativeHumidityHumidifierThreshold = 0;
|
|
27
48
|
this.CurrentTemperature = 0;
|
|
28
49
|
this.WaterLevel = 0;
|
|
29
|
-
// Humidifiers Config
|
|
30
|
-
this.debugLog(`Humidifier: ${this.accessory.displayName} Config: (ble: ${device.ble}, offline: ${device.offline}, hide_temperature: `
|
|
31
|
-
+ `${device.humidifier?.hide_temperature}, set_minStep: ${device.humidifier?.set_minStep})`);
|
|
32
50
|
// this is subject we use to track when we need to POST changes to the SwitchBot API
|
|
33
|
-
this.doHumidifierUpdate = new
|
|
51
|
+
this.doHumidifierUpdate = new rxjs.Subject();
|
|
34
52
|
this.humidifierUpdateInProgress = false;
|
|
35
53
|
// Retrieve initial values and updateHomekit
|
|
36
54
|
this.refreshStatus();
|
|
37
55
|
// set accessory information
|
|
38
56
|
accessory
|
|
39
57
|
.getService(this.platform.Service.AccessoryInformation)
|
|
40
|
-
.setCharacteristic(this.platform.Characteristic.Manufacturer,
|
|
41
|
-
.setCharacteristic(this.platform.Characteristic.Model,
|
|
58
|
+
.setCharacteristic(this.platform.Characteristic.Manufacturer, "SwitchBot")
|
|
59
|
+
.setCharacteristic(this.platform.Characteristic.Model, "SWITCHBOT-HUMIDIFIER-W0801800")
|
|
42
60
|
.setCharacteristic(this.platform.Characteristic.SerialNumber, device.deviceId);
|
|
43
61
|
// get the LightBulb service if it exists, otherwise create a new LightBulb service
|
|
44
62
|
// you can create multiple services for each accessory
|
|
45
63
|
(this.service =
|
|
46
64
|
accessory.getService(this.platform.Service.HumidifierDehumidifier) ||
|
|
47
|
-
accessory.addService(this.platform.Service.HumidifierDehumidifier)),
|
|
65
|
+
accessory.addService(this.platform.Service.HumidifierDehumidifier)),
|
|
66
|
+
`${accessory.displayName} Humidifier`;
|
|
48
67
|
// To avoid "Cannot add a Service with the same UUID another Service without also defining a unique 'subtype' property." error,
|
|
49
68
|
// when creating multiple services of the same type, you need to use the following syntax to specify a name and subtype id:
|
|
50
69
|
// accessory.getService('NAME') ?? accessory.addService(this.platform.Service.Lightbulb, 'NAME', 'USER_DEFINED_SUBTYPE');
|
|
@@ -64,7 +83,9 @@ class Humidifier {
|
|
|
64
83
|
validValues: [0, 1],
|
|
65
84
|
})
|
|
66
85
|
.onSet(this.handleTargetHumidifierDehumidifierStateSet.bind(this));
|
|
67
|
-
this.service
|
|
86
|
+
this.service
|
|
87
|
+
.getCharacteristic(this.platform.Characteristic.Active)
|
|
88
|
+
.onSet(this.handleActiveSet.bind(this));
|
|
68
89
|
this.service
|
|
69
90
|
.getCharacteristic(this.platform.Characteristic.RelativeHumidityHumidifierThreshold)
|
|
70
91
|
.setProps({
|
|
@@ -85,7 +106,8 @@ class Humidifier {
|
|
|
85
106
|
this.debugLog(`Humidifier: ${accessory.displayName} Add Temperature Sensor Service`);
|
|
86
107
|
(this.temperatureservice =
|
|
87
108
|
this.accessory.getService(this.platform.Service.TemperatureSensor) ||
|
|
88
|
-
this.accessory.addService(this.platform.Service.TemperatureSensor)),
|
|
109
|
+
this.accessory.addService(this.platform.Service.TemperatureSensor)),
|
|
110
|
+
`${accessory.displayName} Temperature Sensor`;
|
|
89
111
|
this.temperatureservice.setCharacteristic(this.platform.Characteristic.Name, `${accessory.displayName} Temperature Sensor`);
|
|
90
112
|
this.temperatureservice
|
|
91
113
|
.getCharacteristic(this.platform.Characteristic.CurrentTemperature)
|
|
@@ -105,30 +127,27 @@ class Humidifier {
|
|
|
105
127
|
// Retrieve initial values and updateHomekit
|
|
106
128
|
this.updateHomeKitCharacteristics();
|
|
107
129
|
// Start an update interval
|
|
108
|
-
|
|
109
|
-
.
|
|
130
|
+
rxjs
|
|
131
|
+
.interval(this.deviceRefreshRate * 1000)
|
|
132
|
+
.pipe(operators.skipWhile(() => this.humidifierUpdateInProgress))
|
|
110
133
|
.subscribe(() => {
|
|
111
134
|
this.refreshStatus();
|
|
112
135
|
});
|
|
113
136
|
// Watch for Humidifier change events
|
|
114
137
|
// We put in a debounce of 100ms so we don't make duplicate calls
|
|
115
138
|
this.doHumidifierUpdate
|
|
116
|
-
.pipe(
|
|
139
|
+
.pipe(operators.tap(() => {
|
|
117
140
|
this.humidifierUpdateInProgress = true;
|
|
118
|
-
}),
|
|
141
|
+
}), operators.debounceTime(this.platform.config.options.pushRate * 1000))
|
|
119
142
|
.subscribe(async () => {
|
|
120
143
|
try {
|
|
121
144
|
await this.pushChanges();
|
|
122
145
|
}
|
|
123
146
|
catch (e) {
|
|
124
147
|
this.errorLog(`Humidifier: ${this.accessory.displayName} failed pushChanges`);
|
|
125
|
-
if (this.deviceLogging
|
|
126
|
-
this.errorLog(`Humidifier: ${this.accessory.displayName} failed pushChanges,`
|
|
127
|
-
|
|
128
|
-
}
|
|
129
|
-
if (this.platform.debugMode) {
|
|
130
|
-
this.errorLog(`Humidifier: ${this.accessory.displayName} failed pushChanges,`
|
|
131
|
-
+ ` Error: ${JSON.stringify(e)}`);
|
|
148
|
+
if (this.deviceLogging.includes("debug")) {
|
|
149
|
+
this.errorLog(`Humidifier: ${this.accessory.displayName} failed pushChanges,` +
|
|
150
|
+
` Error Message: ${JSON.stringify(e.message)}`);
|
|
132
151
|
}
|
|
133
152
|
this.apiError(e);
|
|
134
153
|
}
|
|
@@ -174,35 +193,44 @@ class Humidifier {
|
|
|
174
193
|
// Target Humidifier Dehumidifier State
|
|
175
194
|
switch (this.auto) {
|
|
176
195
|
case true:
|
|
177
|
-
this.TargetHumidifierDehumidifierState =
|
|
178
|
-
|
|
179
|
-
this.
|
|
196
|
+
this.TargetHumidifierDehumidifierState =
|
|
197
|
+
this.platform.Characteristic.TargetHumidifierDehumidifierState.HUMIDIFIER_OR_DEHUMIDIFIER;
|
|
198
|
+
this.CurrentHumidifierDehumidifierState =
|
|
199
|
+
this.platform.Characteristic.CurrentHumidifierDehumidifierState.HUMIDIFYING;
|
|
200
|
+
this.RelativeHumidityHumidifierThreshold =
|
|
201
|
+
this.CurrentRelativeHumidity;
|
|
180
202
|
break;
|
|
181
203
|
default:
|
|
182
|
-
this.TargetHumidifierDehumidifierState =
|
|
204
|
+
this.TargetHumidifierDehumidifierState =
|
|
205
|
+
this.platform.Characteristic.TargetHumidifierDehumidifierState.HUMIDIFIER;
|
|
183
206
|
if (this.nebulizationEfficiency > 100) {
|
|
184
207
|
this.RelativeHumidityHumidifierThreshold = 100;
|
|
185
208
|
}
|
|
186
209
|
else {
|
|
187
|
-
this.RelativeHumidityHumidifierThreshold =
|
|
210
|
+
this.RelativeHumidityHumidifierThreshold =
|
|
211
|
+
this.nebulizationEfficiency;
|
|
188
212
|
}
|
|
189
|
-
if (this.CurrentRelativeHumidity >
|
|
190
|
-
this.
|
|
213
|
+
if (this.CurrentRelativeHumidity >
|
|
214
|
+
this.RelativeHumidityHumidifierThreshold) {
|
|
215
|
+
this.CurrentHumidifierDehumidifierState =
|
|
216
|
+
this.platform.Characteristic.CurrentHumidifierDehumidifierState.IDLE;
|
|
191
217
|
}
|
|
192
218
|
else if (this.Active === this.platform.Characteristic.Active.INACTIVE) {
|
|
193
|
-
this.CurrentHumidifierDehumidifierState =
|
|
219
|
+
this.CurrentHumidifierDehumidifierState =
|
|
220
|
+
this.platform.Characteristic.CurrentHumidifierDehumidifierState.INACTIVE;
|
|
194
221
|
}
|
|
195
222
|
else {
|
|
196
|
-
this.CurrentHumidifierDehumidifierState =
|
|
223
|
+
this.CurrentHumidifierDehumidifierState =
|
|
224
|
+
this.platform.Characteristic.CurrentHumidifierDehumidifierState.HUMIDIFYING;
|
|
197
225
|
}
|
|
198
226
|
}
|
|
199
227
|
this.debugLog(`Humidifier: ${this.accessory.displayName} TargetHumidifierDehumidifierState: ${this.TargetHumidifierDehumidifierState}`);
|
|
200
|
-
this.debugLog(`Humidifier: ${this.accessory.displayName}`
|
|
201
|
-
|
|
228
|
+
this.debugLog(`Humidifier: ${this.accessory.displayName}` +
|
|
229
|
+
` RelativeHumidityHumidifierThreshold: ${this.RelativeHumidityHumidifierThreshold}`);
|
|
202
230
|
this.debugLog(`Humidifier: ${this.accessory.displayName} CurrentHumidifierDehumidifierState: ${this.CurrentHumidifierDehumidifierState}`);
|
|
203
231
|
// Active
|
|
204
232
|
switch (this.power) {
|
|
205
|
-
case
|
|
233
|
+
case "on":
|
|
206
234
|
this.Active = this.platform.Characteristic.Active.ACTIVE;
|
|
207
235
|
break;
|
|
208
236
|
default:
|
|
@@ -234,85 +262,84 @@ class Humidifier {
|
|
|
234
262
|
this.debugLog(`Humidifier: ${this.accessory.displayName} BLE refreshStatus`);
|
|
235
263
|
const switchbot = await this.platform.connectBLE();
|
|
236
264
|
// Convert to BLE Address
|
|
237
|
-
this.device.bleMac =
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
265
|
+
this.device.bleMac = this.device
|
|
266
|
+
.deviceId.match(/.{1,2}/g)
|
|
267
|
+
.join(":")
|
|
268
|
+
.toLowerCase();
|
|
269
|
+
this.debugLog(`Humidifier: ${this.accessory.displayName} BLE Address: ${this.device.bleMac}`);
|
|
270
|
+
try {
|
|
271
|
+
await switchbot.discover({
|
|
272
|
+
model: "e",
|
|
273
|
+
quick: false,
|
|
274
|
+
});
|
|
275
|
+
// Start to monitor advertisement packets
|
|
276
|
+
await switchbot.startScan({
|
|
277
|
+
model: "e",
|
|
243
278
|
id: this.device.bleMac,
|
|
244
|
-
})
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
}
|
|
258
|
-
else {
|
|
259
|
-
this.connected = false;
|
|
260
|
-
this.debugLog(`Humidifier: ${this.accessory.displayName} connected: ${this.connected}`);
|
|
261
|
-
}
|
|
262
|
-
};
|
|
263
|
-
// Wait 2 seconds
|
|
264
|
-
return switchbot.wait(this.scanDuration * 1000);
|
|
265
|
-
}).then(async () => {
|
|
266
|
-
// Stop to monitor
|
|
267
|
-
switchbot.stopScan();
|
|
268
|
-
if (this.connected) {
|
|
269
|
-
this.parseStatus();
|
|
270
|
-
this.updateHomeKitCharacteristics();
|
|
279
|
+
});
|
|
280
|
+
// Set an event hander
|
|
281
|
+
switchbot.onadvertisement = (ad) => {
|
|
282
|
+
this.serviceData = ad.serviceData;
|
|
283
|
+
this.autoMode = ad.serviceData.autoMode;
|
|
284
|
+
this.onState = ad.serviceData.onState;
|
|
285
|
+
this.percentage = ad.serviceData.percentage;
|
|
286
|
+
this.debugLog(`Humidifier: ${this.accessory.displayName} serviceData: ${JSON.stringify(ad.serviceData)}`);
|
|
287
|
+
this.debugLog(`Humidifier: ${this.accessory.displayName} model: ${ad.serviceData.model}, modelName: ${ad.serviceData.modelName},` +
|
|
288
|
+
`autoMode: ${ad.serviceData.autoMode}, onState: ${ad.serviceData.onState}, percentage: ${ad.serviceData.percentage}`);
|
|
289
|
+
if (this.serviceData) {
|
|
290
|
+
this.connected = true;
|
|
291
|
+
this.debugLog(`Humidifier: ${this.accessory.displayName} connected: ${this.connected}`);
|
|
271
292
|
}
|
|
272
293
|
else {
|
|
273
|
-
|
|
274
|
-
|
|
275
|
-
}).catch(async (e) => {
|
|
276
|
-
this.errorLog(`Humidifier: ${this.accessory.displayName} failed refreshStatus with BLE Connection`);
|
|
277
|
-
if (this.deviceLogging === 'debug') {
|
|
278
|
-
this.errorLog(`Humidifier: ${this.accessory.displayName} failed refreshStatus with BLE Connection,`
|
|
279
|
-
+ ` Error Message: ${JSON.stringify(e.message)}`);
|
|
280
|
-
}
|
|
281
|
-
if (this.platform.debugMode) {
|
|
282
|
-
this.errorLog(`Humidifier: ${this.accessory.displayName} failed refreshStatus with BLE Connection,`
|
|
283
|
-
+ ` Error: ${JSON.stringify(e)}`);
|
|
294
|
+
this.connected = false;
|
|
295
|
+
this.debugLog(`Humidifier: ${this.accessory.displayName} connected: ${this.connected}`);
|
|
284
296
|
}
|
|
297
|
+
};
|
|
298
|
+
// Wait 2 seconds
|
|
299
|
+
await switchbot.wait(this.scanDuration * 1000);
|
|
300
|
+
// Stop to monitor
|
|
301
|
+
switchbot.stopScan();
|
|
302
|
+
if (this.connected) {
|
|
303
|
+
this.parseStatus();
|
|
304
|
+
this.updateHomeKitCharacteristics();
|
|
305
|
+
}
|
|
306
|
+
else {
|
|
307
|
+
this.errorLog(`Humidifier: ${this.accessory.displayName} wasn't able to establish BLE Connection`);
|
|
285
308
|
if (this.platform.config.credentials?.openToken) {
|
|
286
309
|
this.warnLog(`Humidifier: ${this.accessory.displayName} Using OpenAPI Connection`);
|
|
310
|
+
this.SwitchToOpenAPI = true;
|
|
287
311
|
await this.openAPIRefreshStatus();
|
|
288
312
|
}
|
|
289
|
-
|
|
290
|
-
});
|
|
291
|
-
}
|
|
292
|
-
else {
|
|
293
|
-
await this.BLEconnection(switchbot);
|
|
313
|
+
}
|
|
294
314
|
}
|
|
295
|
-
|
|
296
|
-
|
|
297
|
-
|
|
298
|
-
|
|
299
|
-
|
|
300
|
-
|
|
315
|
+
catch (e) {
|
|
316
|
+
this.errorLog(`Humidifier: ${this.accessory.displayName} failed refreshStatus with BLE Connection`);
|
|
317
|
+
if (this.deviceLogging.includes("debug")) {
|
|
318
|
+
this.errorLog(`Humidifier: ${this.accessory.displayName} failed refreshStatus with BLE Connection,` +
|
|
319
|
+
` Error Message: ${JSON.stringify(e.message)}`);
|
|
320
|
+
}
|
|
321
|
+
if (this.platform.config.credentials?.openToken) {
|
|
322
|
+
this.warnLog(`Humidifier: ${this.accessory.displayName} Using OpenAPI Connection`);
|
|
323
|
+
this.SwitchToOpenAPI = true;
|
|
324
|
+
await this.openAPIRefreshStatus();
|
|
325
|
+
}
|
|
326
|
+
this.apiError(e);
|
|
301
327
|
}
|
|
302
328
|
}
|
|
303
329
|
async openAPIRefreshStatus() {
|
|
304
330
|
if (this.platform.config.credentials?.openToken) {
|
|
305
331
|
this.debugLog(`Humidifier: ${this.accessory.displayName} OpenAPI refreshStatus`);
|
|
306
332
|
try {
|
|
307
|
-
this.deviceStatus = (await this.platform.axios.get(`${
|
|
308
|
-
if (this.deviceStatus.message ===
|
|
333
|
+
this.deviceStatus = (await this.platform.axios.get(`${settings.DeviceURL}/${this.device.deviceId}/status`)).data;
|
|
334
|
+
if (this.deviceStatus.message === "success") {
|
|
309
335
|
this.debugLog(`Humidifier: ${this.accessory.displayName} refreshStatus: ${JSON.stringify(this.deviceStatus)}`);
|
|
310
336
|
this.auto = this.deviceStatus.body.auto;
|
|
311
337
|
this.power = this.deviceStatus.body.power;
|
|
312
338
|
this.lackWater = this.deviceStatus.body.lackWater;
|
|
313
339
|
this.humidity = this.deviceStatus.body.humidity;
|
|
314
340
|
this.temperature = this.deviceStatus.body.temperature;
|
|
315
|
-
this.nebulizationEfficiency =
|
|
341
|
+
this.nebulizationEfficiency =
|
|
342
|
+
this.deviceStatus.body.nebulizationEfficiency;
|
|
316
343
|
this.parseStatus();
|
|
317
344
|
this.updateHomeKitCharacteristics();
|
|
318
345
|
}
|
|
@@ -322,13 +349,9 @@ class Humidifier {
|
|
|
322
349
|
}
|
|
323
350
|
catch (e) {
|
|
324
351
|
this.errorLog(`Humidifier: ${this.accessory.displayName} failed refreshStatus with OpenAPI Connection`);
|
|
325
|
-
if (this.deviceLogging
|
|
326
|
-
this.errorLog(`Humidifier: ${this.accessory.displayName} failed refreshStatus with OpenAPI Connection,`
|
|
327
|
-
|
|
328
|
-
}
|
|
329
|
-
if (this.platform.debugMode) {
|
|
330
|
-
this.errorLog(`Humidifier: ${this.accessory.displayName} failed refreshStatus with OpenAPI Connection,`
|
|
331
|
-
+ ` Error: ${JSON.stringify(e)}`);
|
|
352
|
+
if (this.deviceLogging.includes("debug")) {
|
|
353
|
+
this.errorLog(`Humidifier: ${this.accessory.displayName} failed refreshStatus with OpenAPI Connection,` +
|
|
354
|
+
` Error Message: ${JSON.stringify(e.message)}`);
|
|
332
355
|
}
|
|
333
356
|
this.apiError(e);
|
|
334
357
|
}
|
|
@@ -343,9 +366,10 @@ class Humidifier {
|
|
|
343
366
|
//} else {
|
|
344
367
|
await this.openAPIpushChanges();
|
|
345
368
|
//}
|
|
346
|
-
|
|
347
|
-
.
|
|
348
|
-
.pipe((
|
|
369
|
+
rxjs
|
|
370
|
+
.interval(5000)
|
|
371
|
+
.pipe(operators.skipWhile(() => this.humidifierUpdateInProgress))
|
|
372
|
+
.pipe(operators.take(1))
|
|
349
373
|
.subscribe(() => {
|
|
350
374
|
this.refreshStatus();
|
|
351
375
|
});
|
|
@@ -354,23 +378,26 @@ class Humidifier {
|
|
|
354
378
|
this.debugLog(`Humidifier: ${this.accessory.displayName} BLE pushChanges`);
|
|
355
379
|
const switchbot = await this.platform.connectBLE();
|
|
356
380
|
// Convert to BLE Address
|
|
357
|
-
this.device.bleMac =
|
|
358
|
-
|
|
381
|
+
this.device.bleMac = this.device
|
|
382
|
+
.deviceId.match(/.{1,2}/g)
|
|
383
|
+
.join(":")
|
|
384
|
+
.toLowerCase();
|
|
385
|
+
this.debugLog(`Humidifier: ${this.accessory.displayName} BLE Address: ${this.device.bleMac}`);
|
|
359
386
|
if (switchbot !== false) {
|
|
360
|
-
switchbot
|
|
387
|
+
switchbot
|
|
388
|
+
.discover({ model: "e", quick: true, id: this.device.bleMac })
|
|
389
|
+
.then((device_list) => {
|
|
361
390
|
this.infoLog(`${this.accessory.displayName} Target Position: ${this.Active}`);
|
|
362
391
|
return device_list[0].percentage(this.RelativeHumidityHumidifierThreshold);
|
|
363
|
-
})
|
|
392
|
+
})
|
|
393
|
+
.then(() => {
|
|
364
394
|
this.debugLog(`Humidifier: ${this.accessory.displayName} Done.`);
|
|
365
|
-
})
|
|
395
|
+
})
|
|
396
|
+
.catch(async (e) => {
|
|
366
397
|
this.errorLog(`Humidifier: ${this.accessory.displayName} failed pushChanges with BLE Connection`);
|
|
367
|
-
if (this.deviceLogging
|
|
368
|
-
this.errorLog(`Humidifier: ${this.accessory.displayName} failed pushChanges with BLE Connection,`
|
|
369
|
-
|
|
370
|
-
}
|
|
371
|
-
if (this.platform.debugMode) {
|
|
372
|
-
this.errorLog(`Humidifier: ${this.accessory.displayName} failed pushChanges with BLE Connection,`
|
|
373
|
-
+ ` Error: ${JSON.stringify(e)}`);
|
|
398
|
+
if (this.deviceLogging.includes("debug")) {
|
|
399
|
+
this.errorLog(`Humidifier: ${this.accessory.displayName} failed pushChanges with BLE Connection,` +
|
|
400
|
+
` Error Message: ${JSON.stringify(e.message)}`);
|
|
374
401
|
}
|
|
375
402
|
if (this.platform.config.credentials?.openToken) {
|
|
376
403
|
this.warnLog(`Humidifier: ${this.accessory.displayName} Using OpenAPI Connection`);
|
|
@@ -391,37 +418,35 @@ class Humidifier {
|
|
|
391
418
|
if (this.platform.config.credentials?.openToken) {
|
|
392
419
|
this.debugLog(`Humidifier: ${this.accessory.displayName} OpenAPI pushChanges`);
|
|
393
420
|
if (this.TargetHumidifierDehumidifierState ===
|
|
394
|
-
this.platform.Characteristic.TargetHumidifierDehumidifierState
|
|
421
|
+
this.platform.Characteristic.TargetHumidifierDehumidifierState
|
|
422
|
+
.HUMIDIFIER &&
|
|
395
423
|
this.Active === this.platform.Characteristic.Active.ACTIVE) {
|
|
396
424
|
try {
|
|
397
425
|
this.debugLog(`Pushing Manual: ${this.RelativeHumidityHumidifierThreshold}!`);
|
|
398
426
|
const payload = {
|
|
399
|
-
commandType:
|
|
400
|
-
command:
|
|
427
|
+
commandType: "command",
|
|
428
|
+
command: "setMode",
|
|
401
429
|
parameter: `${this.RelativeHumidityHumidifierThreshold}`,
|
|
402
430
|
};
|
|
403
|
-
this.infoLog(`Humidifier: ${this.accessory.displayName} Sending request to SwitchBot API. command: ${payload.command},`
|
|
404
|
-
|
|
431
|
+
this.infoLog(`Humidifier: ${this.accessory.displayName} Sending request to SwitchBot API. command: ${payload.command},` +
|
|
432
|
+
` parameter: ${payload.parameter}, commandType: ${payload.commandType}`);
|
|
405
433
|
// Make the API request
|
|
406
|
-
const push =
|
|
434
|
+
const push = await this.platform.axios.post(`${settings.DeviceURL}/${this.device.deviceId}/commands`, payload);
|
|
407
435
|
this.debugLog(`Humidifier: ${this.accessory.displayName} pushChanges: ${JSON.stringify(push.data)}`);
|
|
408
436
|
this.statusCode(push);
|
|
409
437
|
}
|
|
410
438
|
catch (e) {
|
|
411
439
|
this.errorLog(`Humidifier: ${this.accessory.displayName} failed pushChanges with OpenAPI Connection`);
|
|
412
|
-
if (this.deviceLogging
|
|
413
|
-
this.errorLog(`Humidifier: ${this.accessory.displayName} failed pushChanges with OpenAPI Connection,`
|
|
414
|
-
|
|
415
|
-
}
|
|
416
|
-
if (this.platform.debugMode) {
|
|
417
|
-
this.errorLog(`Humidifier: ${this.accessory.displayName} failed pushChanges with OpenAPI Connection,`
|
|
418
|
-
+ ` Error: ${JSON.stringify(e)}`);
|
|
440
|
+
if (this.deviceLogging.includes("debug")) {
|
|
441
|
+
this.errorLog(`Humidifier: ${this.accessory.displayName} failed pushChanges with OpenAPI Connection,` +
|
|
442
|
+
` Error Message: ${JSON.stringify(e.message)}`);
|
|
419
443
|
}
|
|
420
444
|
this.apiError(e);
|
|
421
445
|
}
|
|
422
446
|
}
|
|
423
447
|
else if (this.TargetHumidifierDehumidifierState ===
|
|
424
|
-
this.platform.Characteristic.TargetHumidifierDehumidifierState
|
|
448
|
+
this.platform.Characteristic.TargetHumidifierDehumidifierState
|
|
449
|
+
.HUMIDIFIER_OR_DEHUMIDIFIER &&
|
|
425
450
|
this.Active === this.platform.Characteristic.Active.ACTIVE) {
|
|
426
451
|
await this.pushAutoChanges();
|
|
427
452
|
}
|
|
@@ -436,31 +461,28 @@ class Humidifier {
|
|
|
436
461
|
async pushAutoChanges() {
|
|
437
462
|
try {
|
|
438
463
|
if (this.TargetHumidifierDehumidifierState ===
|
|
439
|
-
this.platform.Characteristic.TargetHumidifierDehumidifierState
|
|
464
|
+
this.platform.Characteristic.TargetHumidifierDehumidifierState
|
|
465
|
+
.HUMIDIFIER_OR_DEHUMIDIFIER &&
|
|
440
466
|
this.Active === this.platform.Characteristic.Active.ACTIVE) {
|
|
441
|
-
this.debugLog(
|
|
467
|
+
this.debugLog("Pushing Auto!");
|
|
442
468
|
const payload = {
|
|
443
|
-
commandType:
|
|
444
|
-
command:
|
|
445
|
-
parameter:
|
|
469
|
+
commandType: "command",
|
|
470
|
+
command: "setMode",
|
|
471
|
+
parameter: "auto",
|
|
446
472
|
};
|
|
447
|
-
this.infoLog(`Humidifier: ${this.accessory.displayName} Sending request to SwitchBot API. command: ${payload.command},`
|
|
448
|
-
|
|
473
|
+
this.infoLog(`Humidifier: ${this.accessory.displayName} Sending request to SwitchBot API. command: ${payload.command},` +
|
|
474
|
+
` parameter: ${payload.parameter}, commandType: ${payload.commandType}`);
|
|
449
475
|
// Make the API request
|
|
450
|
-
const push =
|
|
476
|
+
const push = await this.platform.axios.post(`${settings.DeviceURL}/${this.device.deviceId}/commands`, payload);
|
|
451
477
|
this.debugLog(`Humidifier: ${this.accessory.displayName} pushAutoChanges: ${JSON.stringify(push.data)}`);
|
|
452
478
|
this.statusCode(push);
|
|
453
479
|
}
|
|
454
480
|
}
|
|
455
481
|
catch (e) {
|
|
456
482
|
this.errorLog(`Humidifier: ${this.accessory.displayName} failed pushAutoChanges with OpenAPI Connection`);
|
|
457
|
-
if (this.deviceLogging
|
|
458
|
-
this.errorLog(`Humidifier: ${this.accessory.displayName} failed pushAutoChanges with OpenAPI Connection,`
|
|
459
|
-
|
|
460
|
-
}
|
|
461
|
-
if (this.platform.debugMode) {
|
|
462
|
-
this.errorLog(`Humidifier: ${this.accessory.displayName} failed pushAutoChanges with OpenAPI Connection,`
|
|
463
|
-
+ ` Error: ${JSON.stringify(e)}`);
|
|
483
|
+
if (this.deviceLogging.includes("debug")) {
|
|
484
|
+
this.errorLog(`Humidifier: ${this.accessory.displayName} failed pushAutoChanges with OpenAPI Connection,` +
|
|
485
|
+
` Error Message: ${JSON.stringify(e.message)}`);
|
|
464
486
|
}
|
|
465
487
|
this.apiError(e);
|
|
466
488
|
}
|
|
@@ -471,29 +493,25 @@ class Humidifier {
|
|
|
471
493
|
async pushActiveChanges() {
|
|
472
494
|
try {
|
|
473
495
|
if (this.Active === this.platform.Characteristic.Active.INACTIVE) {
|
|
474
|
-
this.debugLog(
|
|
496
|
+
this.debugLog("Pushing Off!");
|
|
475
497
|
const payload = {
|
|
476
|
-
commandType:
|
|
477
|
-
command:
|
|
478
|
-
parameter:
|
|
498
|
+
commandType: "command",
|
|
499
|
+
command: "turnOff",
|
|
500
|
+
parameter: "default",
|
|
479
501
|
};
|
|
480
|
-
this.infoLog(`Humidifier: ${this.accessory.displayName} Sending request to SwitchBot API. command: ${payload.command},`
|
|
481
|
-
|
|
502
|
+
this.infoLog(`Humidifier: ${this.accessory.displayName} Sending request to SwitchBot API. command: ${payload.command},` +
|
|
503
|
+
` parameter: ${payload.parameter}, commandType: ${payload.commandType}`);
|
|
482
504
|
// Make the API request
|
|
483
|
-
const push =
|
|
505
|
+
const push = await this.platform.axios.post(`${settings.DeviceURL}/${this.device.deviceId}/commands`, payload);
|
|
484
506
|
this.debugLog(`Humidifier: ${this.accessory.displayName} pushActiveChanges: ${JSON.stringify(push.data)}`);
|
|
485
507
|
this.statusCode(push);
|
|
486
508
|
}
|
|
487
509
|
}
|
|
488
510
|
catch (e) {
|
|
489
511
|
this.errorLog(`Humidifier: ${this.accessory.displayName} failed pushActiveChanges with OpenAPI Connection`);
|
|
490
|
-
if (this.deviceLogging
|
|
491
|
-
this.errorLog(`Humidifier: ${this.accessory.displayName} failed pushActiveChanges with OpenAPI Connection,`
|
|
492
|
-
|
|
493
|
-
}
|
|
494
|
-
if (this.platform.debugMode) {
|
|
495
|
-
this.errorLog(`Humidifier: ${this.accessory.displayName} failed pushActiveChanges with OpenAPI Connection,`
|
|
496
|
-
+ ` Error: ${JSON.stringify(e)}`);
|
|
512
|
+
if (this.deviceLogging.includes("debug")) {
|
|
513
|
+
this.errorLog(`Humidifier: ${this.accessory.displayName} failed pushActiveChanges with OpenAPI Connection,` +
|
|
514
|
+
` Error Message: ${JSON.stringify(e.message)}`);
|
|
497
515
|
}
|
|
498
516
|
this.apiError(e);
|
|
499
517
|
}
|
|
@@ -507,8 +525,8 @@ class Humidifier {
|
|
|
507
525
|
}
|
|
508
526
|
else {
|
|
509
527
|
this.service.updateCharacteristic(this.platform.Characteristic.CurrentRelativeHumidity, this.CurrentRelativeHumidity);
|
|
510
|
-
this.debugLog(`Humidifier: ${this.accessory.displayName}`
|
|
511
|
-
|
|
528
|
+
this.debugLog(`Humidifier: ${this.accessory.displayName}` +
|
|
529
|
+
` updateCharacteristic CurrentRelativeHumidity: ${this.CurrentRelativeHumidity}`);
|
|
512
530
|
}
|
|
513
531
|
if (!this.device.ble) {
|
|
514
532
|
if (this.WaterLevel === undefined) {
|
|
@@ -524,16 +542,16 @@ class Humidifier {
|
|
|
524
542
|
}
|
|
525
543
|
else {
|
|
526
544
|
this.service.updateCharacteristic(this.platform.Characteristic.CurrentHumidifierDehumidifierState, this.CurrentHumidifierDehumidifierState);
|
|
527
|
-
this.debugLog(`Humidifier: ${this.accessory.displayName}`
|
|
528
|
-
|
|
545
|
+
this.debugLog(`Humidifier: ${this.accessory.displayName}` +
|
|
546
|
+
` updateCharacteristic CurrentHumidifierDehumidifierState: ${this.CurrentHumidifierDehumidifierState}`);
|
|
529
547
|
}
|
|
530
548
|
if (this.TargetHumidifierDehumidifierState === undefined) {
|
|
531
549
|
this.debugLog(`Humidifier: ${this.accessory.displayName} TargetHumidifierDehumidifierState: ${this.TargetHumidifierDehumidifierState}`);
|
|
532
550
|
}
|
|
533
551
|
else {
|
|
534
552
|
this.service.updateCharacteristic(this.platform.Characteristic.TargetHumidifierDehumidifierState, this.TargetHumidifierDehumidifierState);
|
|
535
|
-
this.debugLog(`Humidifier: ${this.accessory.displayName}`
|
|
536
|
-
|
|
553
|
+
this.debugLog(`Humidifier: ${this.accessory.displayName}` +
|
|
554
|
+
` updateCharacteristic TargetHumidifierDehumidifierState: ${this.TargetHumidifierDehumidifierState}`);
|
|
537
555
|
}
|
|
538
556
|
if (this.Active === undefined) {
|
|
539
557
|
this.debugLog(`Humidifier: ${this.accessory.displayName} Active: ${this.Active}`);
|
|
@@ -543,13 +561,13 @@ class Humidifier {
|
|
|
543
561
|
this.debugLog(`Humidifier: ${this.accessory.displayName} updateCharacteristic Active: ${this.Active}`);
|
|
544
562
|
}
|
|
545
563
|
if (this.RelativeHumidityHumidifierThreshold === undefined) {
|
|
546
|
-
this.debugLog(`Humidifier: ${this.accessory.displayName}`
|
|
547
|
-
|
|
564
|
+
this.debugLog(`Humidifier: ${this.accessory.displayName}` +
|
|
565
|
+
` RelativeHumidityHumidifierThreshold: ${this.RelativeHumidityHumidifierThreshold}`);
|
|
548
566
|
}
|
|
549
567
|
else {
|
|
550
568
|
this.service.updateCharacteristic(this.platform.Characteristic.RelativeHumidityHumidifierThreshold, this.RelativeHumidityHumidifierThreshold);
|
|
551
|
-
this.debugLog(`Humidifier: ${this.accessory.displayName}`
|
|
552
|
-
|
|
569
|
+
this.debugLog(`Humidifier: ${this.accessory.displayName}` +
|
|
570
|
+
` updateCharacteristic RelativeHumidityHumidifierThreshold: ${this.RelativeHumidityHumidifierThreshold}`);
|
|
553
571
|
}
|
|
554
572
|
if (!this.device.humidifier?.hide_temperature && !this.device.ble) {
|
|
555
573
|
if (this.CurrentTemperature === undefined) {
|
|
@@ -595,8 +613,8 @@ class Humidifier {
|
|
|
595
613
|
this.offlineOff();
|
|
596
614
|
break;
|
|
597
615
|
case 190:
|
|
598
|
-
this.errorLog(`Humidifier: ${this.accessory.displayName} Device internal error due to device states not synchronized with server,`
|
|
599
|
-
|
|
616
|
+
this.errorLog(`Humidifier: ${this.accessory.displayName} Device internal error due to device states not synchronized with server,` +
|
|
617
|
+
` Or command: ${JSON.stringify(push.data)} format is invalid`);
|
|
600
618
|
break;
|
|
601
619
|
case 100:
|
|
602
620
|
this.debugLog(`Humidifier: ${this.accessory.displayName} Command successfully sent.`);
|
|
@@ -608,7 +626,9 @@ class Humidifier {
|
|
|
608
626
|
offlineOff() {
|
|
609
627
|
if (this.device.offline) {
|
|
610
628
|
this.Active = this.platform.Characteristic.Active.INACTIVE;
|
|
611
|
-
this.service
|
|
629
|
+
this.service
|
|
630
|
+
.getCharacteristic(this.platform.Characteristic.Active)
|
|
631
|
+
.updateValue(this.Active);
|
|
612
632
|
}
|
|
613
633
|
}
|
|
614
634
|
/**
|
|
@@ -635,7 +655,8 @@ class Humidifier {
|
|
|
635
655
|
this.RelativeHumidityHumidifierThreshold = value;
|
|
636
656
|
if (this.Active === this.platform.Characteristic.Active.INACTIVE) {
|
|
637
657
|
this.Active = this.platform.Characteristic.Active.ACTIVE;
|
|
638
|
-
this.CurrentHumidifierDehumidifierState =
|
|
658
|
+
this.CurrentHumidifierDehumidifierState =
|
|
659
|
+
this.platform.Characteristic.CurrentHumidifierDehumidifierState.IDLE;
|
|
639
660
|
}
|
|
640
661
|
this.doHumidifierUpdate.next();
|
|
641
662
|
}
|
|
@@ -645,16 +666,16 @@ class Humidifier {
|
|
|
645
666
|
config = device.humidifier;
|
|
646
667
|
}
|
|
647
668
|
if (device.ble !== undefined) {
|
|
648
|
-
config[
|
|
669
|
+
config["ble"] = device.ble;
|
|
649
670
|
}
|
|
650
671
|
if (device.logging !== undefined) {
|
|
651
|
-
config[
|
|
672
|
+
config["logging"] = device.logging;
|
|
652
673
|
}
|
|
653
674
|
if (device.refreshRate !== undefined) {
|
|
654
|
-
config[
|
|
675
|
+
config["refreshRate"] = device.refreshRate;
|
|
655
676
|
}
|
|
656
677
|
if (device.scanDuration !== undefined) {
|
|
657
|
-
config[
|
|
678
|
+
config["scanDuration"] = device.scanDuration;
|
|
658
679
|
}
|
|
659
680
|
if (Object.entries(config).length !== 0) {
|
|
660
681
|
this.warnLog(`Humidifier: ${this.accessory.displayName} Config: ${JSON.stringify(config)}`);
|
|
@@ -662,17 +683,20 @@ class Humidifier {
|
|
|
662
683
|
}
|
|
663
684
|
refreshRate(device) {
|
|
664
685
|
if (device.refreshRate) {
|
|
665
|
-
this.deviceRefreshRate = this.accessory.context.refreshRate =
|
|
686
|
+
this.deviceRefreshRate = this.accessory.context.refreshRate =
|
|
687
|
+
device.refreshRate;
|
|
666
688
|
this.debugLog(`Humidifier: ${this.accessory.displayName} Using Device Config refreshRate: ${this.deviceRefreshRate}`);
|
|
667
689
|
}
|
|
668
690
|
else if (this.platform.config.options.refreshRate) {
|
|
669
|
-
this.deviceRefreshRate = this.accessory.context.refreshRate =
|
|
691
|
+
this.deviceRefreshRate = this.accessory.context.refreshRate =
|
|
692
|
+
this.platform.config.options.refreshRate;
|
|
670
693
|
this.debugLog(`Humidifier: ${this.accessory.displayName} Using Platform Config refreshRate: ${this.deviceRefreshRate}`);
|
|
671
694
|
}
|
|
672
695
|
}
|
|
673
696
|
scan(device) {
|
|
674
697
|
if (device.scanDuration) {
|
|
675
|
-
this.scanDuration = this.accessory.context.scanDuration =
|
|
698
|
+
this.scanDuration = this.accessory.context.scanDuration =
|
|
699
|
+
device.scanDuration;
|
|
676
700
|
if (device.ble) {
|
|
677
701
|
this.debugLog(`Humidifier: ${this.accessory.displayName} Using Device Config scanDuration: ${this.scanDuration}`);
|
|
678
702
|
}
|
|
@@ -686,7 +710,7 @@ class Humidifier {
|
|
|
686
710
|
}
|
|
687
711
|
logs(device) {
|
|
688
712
|
if (this.platform.debugMode) {
|
|
689
|
-
this.deviceLogging = this.accessory.context.logging =
|
|
713
|
+
this.deviceLogging = this.accessory.context.logging = "debugMode";
|
|
690
714
|
this.debugLog(`Humidifier: ${this.accessory.displayName} Using Debug Mode Logging: ${this.deviceLogging}`);
|
|
691
715
|
}
|
|
692
716
|
else if (device.logging) {
|
|
@@ -694,11 +718,12 @@ class Humidifier {
|
|
|
694
718
|
this.debugLog(`Humidifier: ${this.accessory.displayName} Using Device Config Logging: ${this.deviceLogging}`);
|
|
695
719
|
}
|
|
696
720
|
else if (this.platform.config.options?.logging) {
|
|
697
|
-
this.deviceLogging = this.accessory.context.logging =
|
|
721
|
+
this.deviceLogging = this.accessory.context.logging =
|
|
722
|
+
this.platform.config.options?.logging;
|
|
698
723
|
this.debugLog(`Humidifier: ${this.accessory.displayName} Using Platform Config Logging: ${this.deviceLogging}`);
|
|
699
724
|
}
|
|
700
725
|
else {
|
|
701
|
-
this.deviceLogging = this.accessory.context.logging =
|
|
726
|
+
this.deviceLogging = this.accessory.context.logging = "standard";
|
|
702
727
|
this.debugLog(`Humidifier: ${this.accessory.displayName} Logging Not Set, Using: ${this.deviceLogging}`);
|
|
703
728
|
}
|
|
704
729
|
}
|
|
@@ -712,8 +737,8 @@ class Humidifier {
|
|
|
712
737
|
return this.set_minStep;
|
|
713
738
|
}
|
|
714
739
|
/**
|
|
715
|
-
|
|
716
|
-
|
|
740
|
+
* Logging for Device
|
|
741
|
+
*/
|
|
717
742
|
infoLog(...log) {
|
|
718
743
|
if (this.enablingDeviceLogging()) {
|
|
719
744
|
this.platform.log.info(String(...log));
|
|
@@ -731,8 +756,8 @@ class Humidifier {
|
|
|
731
756
|
}
|
|
732
757
|
debugLog(...log) {
|
|
733
758
|
if (this.enablingDeviceLogging()) {
|
|
734
|
-
if (this.deviceLogging ===
|
|
735
|
-
this.platform.log.info(
|
|
759
|
+
if (this.deviceLogging === "debug") {
|
|
760
|
+
this.platform.log.info("[DEBUG]", String(...log));
|
|
736
761
|
}
|
|
737
762
|
else {
|
|
738
763
|
this.platform.log.debug(String(...log));
|
|
@@ -740,7 +765,7 @@ class Humidifier {
|
|
|
740
765
|
}
|
|
741
766
|
}
|
|
742
767
|
enablingDeviceLogging() {
|
|
743
|
-
return this.deviceLogging
|
|
768
|
+
return (this.deviceLogging.includes("debug") || this.deviceLogging === "standard");
|
|
744
769
|
}
|
|
745
770
|
}
|
|
746
771
|
exports.Humidifier = Humidifier;
|