@switchbot/homebridge-switchbot 2.14.1-beta.0 → 3.0.0-beta.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.github/{npm-version-script.js → npm-version-script.cjs} +1 -1
- package/.github/workflows/dependabot.yml +10 -11
- package/CHANGELOG.md +11 -2
- package/LICENSE +1 -1
- package/dist/device/blindtilt.d.ts +10 -6
- package/dist/device/blindtilt.d.ts.map +1 -1
- package/dist/device/blindtilt.js +152 -91
- package/dist/device/blindtilt.js.map +1 -1
- package/dist/device/bot.d.ts +10 -6
- package/dist/device/bot.d.ts.map +1 -1
- package/dist/device/bot.js +234 -184
- package/dist/device/bot.js.map +1 -1
- package/dist/device/ceilinglight.d.ts +10 -6
- package/dist/device/ceilinglight.d.ts.map +1 -1
- package/dist/device/ceilinglight.js +110 -64
- package/dist/device/ceilinglight.js.map +1 -1
- package/dist/device/colorbulb.d.ts +10 -6
- package/dist/device/colorbulb.d.ts.map +1 -1
- package/dist/device/colorbulb.js +121 -69
- package/dist/device/colorbulb.js.map +1 -1
- package/dist/device/contact.d.ts +10 -6
- package/dist/device/contact.d.ts.map +1 -1
- package/dist/device/contact.js +111 -66
- package/dist/device/contact.js.map +1 -1
- package/dist/device/curtain.d.ts +10 -6
- package/dist/device/curtain.d.ts.map +1 -1
- package/dist/device/curtain.js +165 -107
- package/dist/device/curtain.js.map +1 -1
- package/dist/device/hub.d.ts +10 -6
- package/dist/device/hub.d.ts.map +1 -1
- package/dist/device/hub.js +88 -51
- package/dist/device/hub.js.map +1 -1
- package/dist/device/humidifier.d.ts +10 -6
- package/dist/device/humidifier.d.ts.map +1 -1
- package/dist/device/humidifier.js +133 -90
- package/dist/device/humidifier.js.map +1 -1
- package/dist/device/iosensor.d.ts +10 -6
- package/dist/device/iosensor.d.ts.map +1 -1
- package/dist/device/iosensor.js +109 -66
- package/dist/device/iosensor.js.map +1 -1
- package/dist/device/lightstrip.d.ts +10 -6
- package/dist/device/lightstrip.d.ts.map +1 -1
- package/dist/device/lightstrip.js +110 -65
- package/dist/device/lightstrip.js.map +1 -1
- package/dist/device/lock.d.ts +11 -7
- package/dist/device/lock.d.ts.map +1 -1
- package/dist/device/lock.js +125 -84
- package/dist/device/lock.js.map +1 -1
- package/dist/device/meter.d.ts +10 -6
- package/dist/device/meter.d.ts.map +1 -1
- package/dist/device/meter.js +103 -63
- package/dist/device/meter.js.map +1 -1
- package/dist/device/meterplus.d.ts +10 -6
- package/dist/device/meterplus.d.ts.map +1 -1
- package/dist/device/meterplus.js +103 -63
- package/dist/device/meterplus.js.map +1 -1
- package/dist/device/motion.d.ts +10 -6
- package/dist/device/motion.d.ts.map +1 -1
- package/dist/device/motion.js +95 -54
- package/dist/device/motion.js.map +1 -1
- package/dist/device/plug.d.ts +10 -6
- package/dist/device/plug.d.ts.map +1 -1
- package/dist/device/plug.js +68 -40
- package/dist/device/plug.js.map +1 -1
- package/dist/device/robotvacuumcleaner.d.ts +10 -6
- package/dist/device/robotvacuumcleaner.d.ts.map +1 -1
- package/dist/device/robotvacuumcleaner.js +86 -52
- package/dist/device/robotvacuumcleaner.js.map +1 -1
- package/dist/homebridge-ui/server.js +5 -10
- package/dist/homebridge-ui/server.js.map +1 -1
- package/dist/index.d.ts +1 -4
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +9 -5
- package/dist/index.js.map +1 -1
- package/dist/irdevice/airconditioner.d.ts +9 -5
- package/dist/irdevice/airconditioner.d.ts.map +1 -1
- package/dist/irdevice/airconditioner.js +105 -71
- package/dist/irdevice/airconditioner.js.map +1 -1
- package/dist/irdevice/airpurifier.d.ts +9 -5
- package/dist/irdevice/airpurifier.d.ts.map +1 -1
- package/dist/irdevice/airpurifier.js +78 -46
- package/dist/irdevice/airpurifier.js.map +1 -1
- package/dist/irdevice/camera.d.ts +9 -5
- package/dist/irdevice/camera.d.ts.map +1 -1
- package/dist/irdevice/camera.js +41 -25
- package/dist/irdevice/camera.js.map +1 -1
- package/dist/irdevice/fan.d.ts +9 -5
- package/dist/irdevice/fan.d.ts.map +1 -1
- package/dist/irdevice/fan.js +62 -39
- package/dist/irdevice/fan.js.map +1 -1
- package/dist/irdevice/light.d.ts +9 -5
- package/dist/irdevice/light.d.ts.map +1 -1
- package/dist/irdevice/light.js +67 -45
- package/dist/irdevice/light.js.map +1 -1
- package/dist/irdevice/other.d.ts +9 -5
- package/dist/irdevice/other.d.ts.map +1 -1
- package/dist/irdevice/other.js +176 -150
- package/dist/irdevice/other.js.map +1 -1
- package/dist/irdevice/tv.d.ts +9 -5
- package/dist/irdevice/tv.d.ts.map +1 -1
- package/dist/irdevice/tv.js +81 -62
- package/dist/irdevice/tv.js.map +1 -1
- package/dist/irdevice/vacuumcleaner.d.ts +9 -5
- package/dist/irdevice/vacuumcleaner.d.ts.map +1 -1
- package/dist/irdevice/vacuumcleaner.js +41 -25
- package/dist/irdevice/vacuumcleaner.js.map +1 -1
- package/dist/irdevice/waterheater.d.ts +9 -5
- package/dist/irdevice/waterheater.d.ts.map +1 -1
- package/dist/irdevice/waterheater.js +48 -32
- package/dist/irdevice/waterheater.js.map +1 -1
- package/dist/platform.d.ts +8 -9
- package/dist/platform.d.ts.map +1 -1
- package/dist/platform.js +151 -162
- package/dist/platform.js.map +1 -1
- package/dist/settings.js +7 -14
- package/dist/settings.js.map +1 -1
- package/dist/utils.js +1 -5
- package/dist/utils.js.map +1 -1
- package/package.json +20 -9
- package/src/device/blindtilt.ts +84 -72
- package/src/device/bot.ts +191 -180
- package/src/device/ceilinglight.ts +57 -44
- package/src/device/colorbulb.ts +53 -40
- package/src/device/contact.ts +71 -60
- package/src/device/curtain.ts +98 -86
- package/src/device/hub.ts +57 -45
- package/src/device/humidifier.ts +88 -77
- package/src/device/iosensor.ts +67 -55
- package/src/device/lightstrip.ts +56 -43
- package/src/device/lock.ts +91 -81
- package/src/device/meter.ts +63 -51
- package/src/device/meterplus.ts +67 -55
- package/src/device/motion.ts +58 -47
- package/src/device/plug.ts +38 -27
- package/src/device/robotvacuumcleaner.ts +49 -38
- package/src/index.ts +10 -7
- package/src/irdevice/airconditioner.ts +71 -63
- package/src/irdevice/airpurifier.ts +48 -40
- package/src/irdevice/camera.ts +28 -20
- package/src/irdevice/fan.ts +42 -34
- package/src/irdevice/light.ts +48 -40
- package/src/irdevice/other.ts +164 -156
- package/src/irdevice/tv.ts +66 -58
- package/src/irdevice/vacuumcleaner.ts +28 -20
- package/src/irdevice/waterheater.ts +35 -27
- package/src/platform.ts +65 -47
- package/tsconfig.json +11 -13
package/src/device/humidifier.ts
CHANGED
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
import { request } from 'undici';
|
|
2
|
-
import { sleep } from '../utils';
|
|
2
|
+
import { sleep } from '../utils.js';
|
|
3
3
|
import { interval, Subject } from 'rxjs';
|
|
4
|
-
import { SwitchBotPlatform } from '../platform';
|
|
4
|
+
import { SwitchBotPlatform } from '../platform.js';
|
|
5
5
|
import { debounceTime, skipWhile, take, tap } from 'rxjs/operators';
|
|
6
|
-
import { Service, PlatformAccessory, CharacteristicValue } from 'homebridge';
|
|
7
|
-
import { device, devicesConfig, serviceData, ad, deviceStatus, Devices } from '../settings';
|
|
6
|
+
import { Service, PlatformAccessory, CharacteristicValue, API, Logging, HAP } from 'homebridge';
|
|
7
|
+
import { device, devicesConfig, serviceData, ad, deviceStatus, Devices, SwitchBotPlatformConfig } from '../settings.js';
|
|
8
8
|
|
|
9
9
|
/**
|
|
10
10
|
* Platform Accessory
|
|
@@ -12,6 +12,10 @@ import { device, devicesConfig, serviceData, ad, deviceStatus, Devices } from '.
|
|
|
12
12
|
* Each accessory may expose multiple services of different service types.
|
|
13
13
|
*/
|
|
14
14
|
export class Humidifier {
|
|
15
|
+
public readonly api: API;
|
|
16
|
+
public readonly log: Logging;
|
|
17
|
+
public readonly config!: SwitchBotPlatformConfig;
|
|
18
|
+
protected readonly hap: HAP;
|
|
15
19
|
// Services
|
|
16
20
|
humidifierService: Service;
|
|
17
21
|
temperatureservice?: Service;
|
|
@@ -52,20 +56,27 @@ export class Humidifier {
|
|
|
52
56
|
doHumidifierUpdate!: Subject<void>;
|
|
53
57
|
|
|
54
58
|
// Connection
|
|
55
|
-
private readonly
|
|
56
|
-
private readonly
|
|
59
|
+
private readonly OpenAPI: boolean;
|
|
60
|
+
private readonly BLE: boolean;
|
|
57
61
|
|
|
58
62
|
constructor(
|
|
59
63
|
private readonly platform: SwitchBotPlatform,
|
|
60
64
|
private accessory: PlatformAccessory,
|
|
61
65
|
public device: device & devicesConfig,
|
|
62
66
|
) {
|
|
67
|
+
this.api = this.platform.api;
|
|
68
|
+
this.log = this.platform.log;
|
|
69
|
+
this.config = this.platform.config;
|
|
70
|
+
this.hap = this.api.hap;
|
|
71
|
+
// Connection
|
|
72
|
+
this.BLE = this.device.connectionType === 'BLE' || this.device.connectionType === 'BLE/OpenAPI';
|
|
73
|
+
this.OpenAPI = this.device.connectionType === 'OpenAPI' || this.device.connectionType === 'BLE/OpenAPI';
|
|
63
74
|
// default placeholders
|
|
64
|
-
this.
|
|
75
|
+
this.deviceLogs(device);
|
|
65
76
|
this.scan(device);
|
|
66
77
|
this.refreshRate(device);
|
|
67
78
|
this.context();
|
|
68
|
-
this.
|
|
79
|
+
this.deviceConfig(device);
|
|
69
80
|
|
|
70
81
|
// this is subject we use to track when we need to POST changes to the SwitchBot API
|
|
71
82
|
this.doHumidifierUpdate = new Subject();
|
|
@@ -76,21 +87,21 @@ export class Humidifier {
|
|
|
76
87
|
|
|
77
88
|
// set accessory information
|
|
78
89
|
accessory
|
|
79
|
-
.getService(this.
|
|
80
|
-
.setCharacteristic(this.
|
|
81
|
-
.setCharacteristic(this.
|
|
82
|
-
.setCharacteristic(this.
|
|
83
|
-
.setCharacteristic(this.
|
|
90
|
+
.getService(this.hap.Service.AccessoryInformation)!
|
|
91
|
+
.setCharacteristic(this.hap.Characteristic.Manufacturer, 'SwitchBot')
|
|
92
|
+
.setCharacteristic(this.hap.Characteristic.Model, 'W0801800')
|
|
93
|
+
.setCharacteristic(this.hap.Characteristic.SerialNumber, device.deviceId)
|
|
94
|
+
.setCharacteristic(this.hap.Characteristic.FirmwareRevision, accessory.context.FirmwareRevision);
|
|
84
95
|
|
|
85
96
|
// get the service if it exists, otherwise create a new service
|
|
86
97
|
// you can create multiple services for each accessory
|
|
87
98
|
const humidifierService = `${accessory.displayName} Humidifier`;
|
|
88
|
-
(this.humidifierService = accessory.getService(this.
|
|
89
|
-
|| accessory.addService(this.
|
|
99
|
+
(this.humidifierService = accessory.getService(this.hap.Service.HumidifierDehumidifier)
|
|
100
|
+
|| accessory.addService(this.hap.Service.HumidifierDehumidifier)), humidifierService;
|
|
90
101
|
|
|
91
|
-
this.humidifierService.setCharacteristic(this.
|
|
92
|
-
if (!this.humidifierService.testCharacteristic(this.
|
|
93
|
-
this.humidifierService.addCharacteristic(this.
|
|
102
|
+
this.humidifierService.setCharacteristic(this.hap.Characteristic.Name, accessory.displayName);
|
|
103
|
+
if (!this.humidifierService.testCharacteristic(this.hap.Characteristic.ConfiguredName)) {
|
|
104
|
+
this.humidifierService.addCharacteristic(this.hap.Characteristic.ConfiguredName, accessory.displayName);
|
|
94
105
|
}
|
|
95
106
|
|
|
96
107
|
// each service must implement at-minimum the "required characteristics" for the given service type
|
|
@@ -98,12 +109,12 @@ export class Humidifier {
|
|
|
98
109
|
|
|
99
110
|
// create handlers for required characteristics
|
|
100
111
|
this.humidifierService.setCharacteristic(
|
|
101
|
-
this.
|
|
112
|
+
this.hap.Characteristic.CurrentHumidifierDehumidifierState,
|
|
102
113
|
this.CurrentHumidifierDehumidifierState,
|
|
103
114
|
);
|
|
104
115
|
|
|
105
116
|
this.humidifierService
|
|
106
|
-
.getCharacteristic(this.
|
|
117
|
+
.getCharacteristic(this.hap.Characteristic.TargetHumidifierDehumidifierState)
|
|
107
118
|
.setProps({
|
|
108
119
|
validValueRanges: [0, 1],
|
|
109
120
|
minValue: 0,
|
|
@@ -112,10 +123,10 @@ export class Humidifier {
|
|
|
112
123
|
})
|
|
113
124
|
.onSet(this.TargetHumidifierDehumidifierStateSet.bind(this));
|
|
114
125
|
|
|
115
|
-
this.humidifierService.getCharacteristic(this.
|
|
126
|
+
this.humidifierService.getCharacteristic(this.hap.Characteristic.Active).onSet(this.ActiveSet.bind(this));
|
|
116
127
|
|
|
117
128
|
this.humidifierService
|
|
118
|
-
.getCharacteristic(this.
|
|
129
|
+
.getCharacteristic(this.hap.Characteristic.RelativeHumidityHumidifierThreshold)
|
|
119
130
|
.setProps({
|
|
120
131
|
validValueRanges: [0, 100],
|
|
121
132
|
minValue: 0,
|
|
@@ -127,20 +138,20 @@ export class Humidifier {
|
|
|
127
138
|
// Temperature Sensor Service
|
|
128
139
|
if (device.humidifier?.hide_temperature || this.BLE) {
|
|
129
140
|
this.debugLog(`${this.device.deviceType}: ${accessory.displayName} Removing Temperature Sensor Service`);
|
|
130
|
-
this.temperatureservice = this.accessory.getService(this.
|
|
141
|
+
this.temperatureservice = this.accessory.getService(this.hap.Service.TemperatureSensor);
|
|
131
142
|
accessory.removeService(this.temperatureservice!);
|
|
132
143
|
} else if (!this.temperatureservice && !this.BLE) {
|
|
133
144
|
this.debugLog(`${this.device.deviceType}: ${accessory.displayName} Add Temperature Sensor Service`);
|
|
134
145
|
const temperatureservice = `${accessory.displayName} Temperature Sensor`;
|
|
135
|
-
(this.temperatureservice = this.accessory.getService(this.
|
|
136
|
-
|| this.accessory.addService(this.
|
|
146
|
+
(this.temperatureservice = this.accessory.getService(this.hap.Service.TemperatureSensor)
|
|
147
|
+
|| this.accessory.addService(this.hap.Service.TemperatureSensor)), temperatureservice;
|
|
137
148
|
|
|
138
|
-
this.temperatureservice.setCharacteristic(this.
|
|
139
|
-
if (!this.temperatureservice.testCharacteristic(this.
|
|
140
|
-
this.temperatureservice.addCharacteristic(this.
|
|
149
|
+
this.temperatureservice.setCharacteristic(this.hap.Characteristic.Name, `${accessory.displayName} Temperature Sensor`);
|
|
150
|
+
if (!this.temperatureservice.testCharacteristic(this.hap.Characteristic.ConfiguredName)) {
|
|
151
|
+
this.temperatureservice.addCharacteristic(this.hap.Characteristic.ConfiguredName, `${accessory.displayName} Temperature Sensor`);
|
|
141
152
|
}
|
|
142
153
|
this.temperatureservice
|
|
143
|
-
.getCharacteristic(this.
|
|
154
|
+
.getCharacteristic(this.hap.Characteristic.CurrentTemperature)
|
|
144
155
|
.setProps({
|
|
145
156
|
validValueRanges: [-273.15, 100],
|
|
146
157
|
minValue: -273.15,
|
|
@@ -174,16 +185,16 @@ export class Humidifier {
|
|
|
174
185
|
const { temperature, humidity } = context;
|
|
175
186
|
const { CurrentTemperature, CurrentRelativeHumidity } = this;
|
|
176
187
|
this.debugLog(`${this.device.deviceType}: ${this.accessory.displayName} ` +
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
188
|
+
'(temperature, humidity) = ' +
|
|
189
|
+
`Webhook:(${temperature}, ${humidity}), ` +
|
|
190
|
+
`current:(${CurrentTemperature}, ${CurrentRelativeHumidity})`);
|
|
180
191
|
this.CurrentRelativeHumidity = humidity;
|
|
181
192
|
this.CurrentTemperature = temperature;
|
|
182
193
|
this.updateHomeKitCharacteristics();
|
|
183
194
|
}
|
|
184
195
|
} catch (e: any) {
|
|
185
196
|
this.errorLog(`${this.device.deviceType}: ${this.accessory.displayName} `
|
|
186
|
-
|
|
197
|
+
+ `failed to handle webhook. Received: ${JSON.stringify(context)} Error: ${e}`);
|
|
187
198
|
}
|
|
188
199
|
};
|
|
189
200
|
}
|
|
@@ -236,9 +247,9 @@ export class Humidifier {
|
|
|
236
247
|
this.debugLog(`${this.device.deviceType}: ${this.accessory.displayName} CurrentRelativeHumidity: ${this.CurrentRelativeHumidity}`);
|
|
237
248
|
// Active
|
|
238
249
|
if (this.onState) {
|
|
239
|
-
this.Active = this.
|
|
250
|
+
this.Active = this.hap.Characteristic.Active.ACTIVE;
|
|
240
251
|
} else {
|
|
241
|
-
this.Active = this.
|
|
252
|
+
this.Active = this.hap.Characteristic.Active.INACTIVE;
|
|
242
253
|
}
|
|
243
254
|
this.debugLog(`${this.device.deviceType}: ${this.accessory.displayName} Active: ${this.Active}`);
|
|
244
255
|
}
|
|
@@ -256,23 +267,23 @@ export class Humidifier {
|
|
|
256
267
|
// Target Humidifier Dehumidifier State
|
|
257
268
|
switch (this.OpenAPI_CurrentHumidifierDehumidifierState) {
|
|
258
269
|
case true:
|
|
259
|
-
this.TargetHumidifierDehumidifierState = this.
|
|
260
|
-
this.CurrentHumidifierDehumidifierState = this.
|
|
270
|
+
this.TargetHumidifierDehumidifierState = this.hap.Characteristic.TargetHumidifierDehumidifierState.HUMIDIFIER_OR_DEHUMIDIFIER;
|
|
271
|
+
this.CurrentHumidifierDehumidifierState = this.hap.Characteristic.CurrentHumidifierDehumidifierState.HUMIDIFYING;
|
|
261
272
|
this.RelativeHumidityHumidifierThreshold = this.CurrentRelativeHumidity;
|
|
262
273
|
break;
|
|
263
274
|
default:
|
|
264
|
-
this.TargetHumidifierDehumidifierState = this.
|
|
275
|
+
this.TargetHumidifierDehumidifierState = this.hap.Characteristic.TargetHumidifierDehumidifierState.HUMIDIFIER;
|
|
265
276
|
if (this.OpenAPI_RelativeHumidityHumidifierThreshold! > 100) {
|
|
266
277
|
this.RelativeHumidityHumidifierThreshold = 100;
|
|
267
278
|
} else {
|
|
268
279
|
this.RelativeHumidityHumidifierThreshold = this.OpenAPI_RelativeHumidityHumidifierThreshold!;
|
|
269
280
|
}
|
|
270
281
|
if (this.CurrentRelativeHumidity > this.RelativeHumidityHumidifierThreshold) {
|
|
271
|
-
this.CurrentHumidifierDehumidifierState = this.
|
|
272
|
-
} else if (this.Active === this.
|
|
273
|
-
this.CurrentHumidifierDehumidifierState = this.
|
|
282
|
+
this.CurrentHumidifierDehumidifierState = this.hap.Characteristic.CurrentHumidifierDehumidifierState.IDLE;
|
|
283
|
+
} else if (this.Active === this.hap.Characteristic.Active.INACTIVE) {
|
|
284
|
+
this.CurrentHumidifierDehumidifierState = this.hap.Characteristic.CurrentHumidifierDehumidifierState.INACTIVE;
|
|
274
285
|
} else {
|
|
275
|
-
this.CurrentHumidifierDehumidifierState = this.
|
|
286
|
+
this.CurrentHumidifierDehumidifierState = this.hap.Characteristic.CurrentHumidifierDehumidifierState.HUMIDIFYING;
|
|
276
287
|
}
|
|
277
288
|
}
|
|
278
289
|
this.debugLog(
|
|
@@ -288,10 +299,10 @@ export class Humidifier {
|
|
|
288
299
|
// Active
|
|
289
300
|
switch (this.OpenAPI_Active) {
|
|
290
301
|
case 'on':
|
|
291
|
-
this.Active = this.
|
|
302
|
+
this.Active = this.hap.Characteristic.Active.ACTIVE;
|
|
292
303
|
break;
|
|
293
304
|
default:
|
|
294
|
-
this.Active = this.
|
|
305
|
+
this.Active = this.hap.Characteristic.Active.INACTIVE;
|
|
295
306
|
}
|
|
296
307
|
this.debugLog(`${this.device.deviceType}: ${this.accessory.displayName} Active: ${this.Active}`);
|
|
297
308
|
// Water Level
|
|
@@ -484,8 +495,8 @@ export class Humidifier {
|
|
|
484
495
|
async openAPIpushChanges(): Promise<void> {
|
|
485
496
|
this.debugLog(`${this.device.deviceType}: ${this.accessory.displayName} openAPIpushChanges`);
|
|
486
497
|
if (
|
|
487
|
-
this.TargetHumidifierDehumidifierState === this.
|
|
488
|
-
this.Active === this.
|
|
498
|
+
this.TargetHumidifierDehumidifierState === this.hap.Characteristic.TargetHumidifierDehumidifierState.HUMIDIFIER &&
|
|
499
|
+
this.Active === this.hap.Characteristic.Active.ACTIVE
|
|
489
500
|
) {
|
|
490
501
|
this.debugLog(`${this.device.deviceType}: ${this.accessory.displayName} Pushing Manual: ${this.RelativeHumidityHumidifierThreshold}!`);
|
|
491
502
|
const bodyChange = JSON.stringify({
|
|
@@ -522,8 +533,8 @@ export class Humidifier {
|
|
|
522
533
|
);
|
|
523
534
|
}
|
|
524
535
|
} else if (
|
|
525
|
-
this.TargetHumidifierDehumidifierState === this.
|
|
526
|
-
this.Active === this.
|
|
536
|
+
this.TargetHumidifierDehumidifierState === this.hap.Characteristic.TargetHumidifierDehumidifierState.HUMIDIFIER_OR_DEHUMIDIFIER &&
|
|
537
|
+
this.Active === this.hap.Characteristic.Active.ACTIVE
|
|
527
538
|
) {
|
|
528
539
|
await this.pushAutoChanges();
|
|
529
540
|
} else {
|
|
@@ -537,8 +548,8 @@ export class Humidifier {
|
|
|
537
548
|
async pushAutoChanges(): Promise<void> {
|
|
538
549
|
this.debugLog(`${this.device.deviceType}: ${this.accessory.displayName} pushAutoChanges`);
|
|
539
550
|
if (
|
|
540
|
-
this.TargetHumidifierDehumidifierState === this.
|
|
541
|
-
this.Active === this.
|
|
551
|
+
this.TargetHumidifierDehumidifierState === this.hap.Characteristic.TargetHumidifierDehumidifierState.HUMIDIFIER_OR_DEHUMIDIFIER &&
|
|
552
|
+
this.Active === this.hap.Characteristic.Active.ACTIVE
|
|
542
553
|
) {
|
|
543
554
|
this.debugLog(`${this.device.deviceType}: ${this.accessory.displayName} Pushing Auto`);
|
|
544
555
|
const bodyChange = JSON.stringify({
|
|
@@ -587,7 +598,7 @@ export class Humidifier {
|
|
|
587
598
|
*/
|
|
588
599
|
async pushActiveChanges(): Promise<void> {
|
|
589
600
|
this.debugLog(`${this.device.deviceType}: ${this.accessory.displayName} pushActiveChanges`);
|
|
590
|
-
if (this.Active === this.
|
|
601
|
+
if (this.Active === this.hap.Characteristic.Active.INACTIVE) {
|
|
591
602
|
this.debugLog(`${this.device.deviceType}: ${this.accessory.displayName} Pushing Off`);
|
|
592
603
|
const bodyChange = JSON.stringify({
|
|
593
604
|
command: 'turnOff',
|
|
@@ -645,7 +656,7 @@ export class Humidifier {
|
|
|
645
656
|
* Handle requests to set the "Target Humidifier Dehumidifier State" characteristic
|
|
646
657
|
*/
|
|
647
658
|
async TargetHumidifierDehumidifierStateSet(value: CharacteristicValue): Promise<void> {
|
|
648
|
-
if (this.Active === this.
|
|
659
|
+
if (this.Active === this.hap.Characteristic.Active.ACTIVE) {
|
|
649
660
|
this.infoLog(`${this.device.deviceType}: ${this.accessory.displayName} Set TargetHumidifierDehumidifierState: ${value}`);
|
|
650
661
|
} else {
|
|
651
662
|
this.debugLog(`${this.device.deviceType}: ${this.accessory.displayName} Set TargetHumidifierDehumidifierState: ${value}`);
|
|
@@ -659,16 +670,16 @@ export class Humidifier {
|
|
|
659
670
|
* Handle requests to set the "Relative Humidity Humidifier Threshold" characteristic
|
|
660
671
|
*/
|
|
661
672
|
async RelativeHumidityHumidifierThresholdSet(value: CharacteristicValue): Promise<void> {
|
|
662
|
-
if (this.Active === this.
|
|
673
|
+
if (this.Active === this.hap.Characteristic.Active.ACTIVE) {
|
|
663
674
|
this.infoLog(`${this.device.deviceType}: ${this.accessory.displayName} Set RelativeHumidityHumidifierThreshold: ${value}`);
|
|
664
675
|
} else {
|
|
665
676
|
this.debugLog(`${this.device.deviceType}: ${this.accessory.displayName} Set RelativeHumidityHumidifierThreshold: ${value}`);
|
|
666
677
|
}
|
|
667
678
|
|
|
668
679
|
this.RelativeHumidityHumidifierThreshold = value;
|
|
669
|
-
if (this.Active === this.
|
|
670
|
-
this.Active = this.
|
|
671
|
-
this.CurrentHumidifierDehumidifierState = this.
|
|
680
|
+
if (this.Active === this.hap.Characteristic.Active.INACTIVE) {
|
|
681
|
+
this.Active = this.hap.Characteristic.Active.ACTIVE;
|
|
682
|
+
this.CurrentHumidifierDehumidifierState = this.hap.Characteristic.CurrentHumidifierDehumidifierState.IDLE;
|
|
672
683
|
}
|
|
673
684
|
this.doHumidifierUpdate.next();
|
|
674
685
|
}
|
|
@@ -680,7 +691,7 @@ export class Humidifier {
|
|
|
680
691
|
if (this.CurrentRelativeHumidity === undefined) {
|
|
681
692
|
this.debugLog(`${this.device.deviceType}: ${this.accessory.displayName} CurrentRelativeHumidity: ${this.CurrentRelativeHumidity}`);
|
|
682
693
|
} else {
|
|
683
|
-
this.humidifierService.updateCharacteristic(this.
|
|
694
|
+
this.humidifierService.updateCharacteristic(this.hap.Characteristic.CurrentRelativeHumidity, this.CurrentRelativeHumidity);
|
|
684
695
|
this.debugLog(
|
|
685
696
|
`${this.device.deviceType}: ${this.accessory.displayName}` + ` updateCharacteristic CurrentRelativeHumidity: ${this.CurrentRelativeHumidity}`,
|
|
686
697
|
);
|
|
@@ -690,7 +701,7 @@ export class Humidifier {
|
|
|
690
701
|
if (this.WaterLevel === undefined) {
|
|
691
702
|
this.debugLog(`${this.device.deviceType}: ${this.accessory.displayName} WaterLevel: ${this.WaterLevel}`);
|
|
692
703
|
} else {
|
|
693
|
-
this.humidifierService.updateCharacteristic(this.
|
|
704
|
+
this.humidifierService.updateCharacteristic(this.hap.Characteristic.WaterLevel, this.WaterLevel);
|
|
694
705
|
this.debugLog(`${this.device.deviceType}: ${this.accessory.displayName} updateCharacteristic WaterLevel: ${this.WaterLevel}`);
|
|
695
706
|
this.accessory.context.WaterLevel = this.WaterLevel;
|
|
696
707
|
}
|
|
@@ -702,7 +713,7 @@ export class Humidifier {
|
|
|
702
713
|
);
|
|
703
714
|
} else {
|
|
704
715
|
this.humidifierService.updateCharacteristic(
|
|
705
|
-
this.
|
|
716
|
+
this.hap.Characteristic.CurrentHumidifierDehumidifierState,
|
|
706
717
|
this.CurrentHumidifierDehumidifierState,
|
|
707
718
|
);
|
|
708
719
|
this.debugLog(
|
|
@@ -717,7 +728,7 @@ export class Humidifier {
|
|
|
717
728
|
);
|
|
718
729
|
} else {
|
|
719
730
|
this.humidifierService.updateCharacteristic(
|
|
720
|
-
this.
|
|
731
|
+
this.hap.Characteristic.TargetHumidifierDehumidifierState,
|
|
721
732
|
this.TargetHumidifierDehumidifierState,
|
|
722
733
|
);
|
|
723
734
|
this.debugLog(
|
|
@@ -729,7 +740,7 @@ export class Humidifier {
|
|
|
729
740
|
if (this.Active === undefined) {
|
|
730
741
|
this.debugLog(`${this.device.deviceType}: ${this.accessory.displayName} Active: ${this.Active}`);
|
|
731
742
|
} else {
|
|
732
|
-
this.humidifierService.updateCharacteristic(this.
|
|
743
|
+
this.humidifierService.updateCharacteristic(this.hap.Characteristic.Active, this.Active);
|
|
733
744
|
this.debugLog(`${this.device.deviceType}: ${this.accessory.displayName} updateCharacteristic Active: ${this.Active}`);
|
|
734
745
|
this.accessory.context.Active = this.Active;
|
|
735
746
|
}
|
|
@@ -740,7 +751,7 @@ export class Humidifier {
|
|
|
740
751
|
);
|
|
741
752
|
} else {
|
|
742
753
|
this.humidifierService.updateCharacteristic(
|
|
743
|
-
this.
|
|
754
|
+
this.hap.Characteristic.RelativeHumidityHumidifierThreshold,
|
|
744
755
|
this.RelativeHumidityHumidifierThreshold,
|
|
745
756
|
);
|
|
746
757
|
this.debugLog(
|
|
@@ -753,7 +764,7 @@ export class Humidifier {
|
|
|
753
764
|
if (this.CurrentTemperature === undefined) {
|
|
754
765
|
this.debugLog(`${this.device.deviceType}: ${this.accessory.displayName} CurrentTemperature: ${this.CurrentTemperature}`);
|
|
755
766
|
} else {
|
|
756
|
-
this.temperatureservice?.updateCharacteristic(this.
|
|
767
|
+
this.temperatureservice?.updateCharacteristic(this.hap.Characteristic.CurrentTemperature, this.CurrentTemperature);
|
|
757
768
|
this.debugLog(`${this.device.deviceType}: ${this.accessory.displayName} updateCharacteristic CurrentTemperature: ${this.CurrentTemperature}`);
|
|
758
769
|
this.accessory.context.CurrentTemperature = this.CurrentTemperature;
|
|
759
770
|
}
|
|
@@ -880,22 +891,22 @@ export class Humidifier {
|
|
|
880
891
|
}
|
|
881
892
|
|
|
882
893
|
async apiError(e: any): Promise<void> {
|
|
883
|
-
this.humidifierService.updateCharacteristic(this.
|
|
894
|
+
this.humidifierService.updateCharacteristic(this.hap.Characteristic.CurrentRelativeHumidity, e);
|
|
884
895
|
if (!this.BLE) {
|
|
885
|
-
this.humidifierService.updateCharacteristic(this.
|
|
896
|
+
this.humidifierService.updateCharacteristic(this.hap.Characteristic.WaterLevel, e);
|
|
886
897
|
}
|
|
887
|
-
this.humidifierService.updateCharacteristic(this.
|
|
888
|
-
this.humidifierService.updateCharacteristic(this.
|
|
889
|
-
this.humidifierService.updateCharacteristic(this.
|
|
890
|
-
this.humidifierService.updateCharacteristic(this.
|
|
898
|
+
this.humidifierService.updateCharacteristic(this.hap.Characteristic.CurrentHumidifierDehumidifierState, e);
|
|
899
|
+
this.humidifierService.updateCharacteristic(this.hap.Characteristic.TargetHumidifierDehumidifierState, e);
|
|
900
|
+
this.humidifierService.updateCharacteristic(this.hap.Characteristic.Active, e);
|
|
901
|
+
this.humidifierService.updateCharacteristic(this.hap.Characteristic.RelativeHumidityHumidifierThreshold, e);
|
|
891
902
|
if (!this.device.humidifier?.hide_temperature && !this.BLE) {
|
|
892
|
-
this.temperatureservice?.updateCharacteristic(this.
|
|
903
|
+
this.temperatureservice?.updateCharacteristic(this.hap.Characteristic.CurrentTemperature, e);
|
|
893
904
|
}
|
|
894
905
|
}
|
|
895
906
|
|
|
896
907
|
async context() {
|
|
897
908
|
if (this.Active === undefined) {
|
|
898
|
-
this.Active = this.
|
|
909
|
+
this.Active = this.hap.Characteristic.Active.ACTIVE;
|
|
899
910
|
} else {
|
|
900
911
|
this.Active = this.accessory.context.Active;
|
|
901
912
|
}
|
|
@@ -910,16 +921,16 @@ export class Humidifier {
|
|
|
910
921
|
this.CurrentRelativeHumidity = this.accessory.context.CurrentRelativeHumidity;
|
|
911
922
|
}
|
|
912
923
|
if (this.TargetHumidifierDehumidifierState === undefined) {
|
|
913
|
-
this.TargetHumidifierDehumidifierState = this.
|
|
924
|
+
this.TargetHumidifierDehumidifierState = this.hap.Characteristic.TargetHumidifierDehumidifierState.HUMIDIFIER;
|
|
914
925
|
} else if (this.accessory.context.TargetHumidifierDehumidifierState === undefined) {
|
|
915
|
-
this.TargetHumidifierDehumidifierState = this.
|
|
926
|
+
this.TargetHumidifierDehumidifierState = this.hap.Characteristic.TargetHumidifierDehumidifierState.HUMIDIFIER;
|
|
916
927
|
} else {
|
|
917
928
|
this.TargetHumidifierDehumidifierState = this.accessory.context.TargetHumidifierDehumidifierState;
|
|
918
929
|
}
|
|
919
930
|
if (this.CurrentHumidifierDehumidifierState === undefined) {
|
|
920
|
-
this.CurrentHumidifierDehumidifierState = this.
|
|
931
|
+
this.CurrentHumidifierDehumidifierState = this.hap.Characteristic.CurrentHumidifierDehumidifierState.INACTIVE;
|
|
921
932
|
} else if (this.accessory.context.CurrentHumidifierDehumidifierState === undefined) {
|
|
922
|
-
this.CurrentHumidifierDehumidifierState = this.
|
|
933
|
+
this.CurrentHumidifierDehumidifierState = this.hap.Characteristic.CurrentHumidifierDehumidifierState.INACTIVE;
|
|
923
934
|
} else {
|
|
924
935
|
this.CurrentHumidifierDehumidifierState = this.accessory.context.CurrentHumidifierDehumidifierState;
|
|
925
936
|
}
|
|
@@ -949,7 +960,7 @@ export class Humidifier {
|
|
|
949
960
|
}
|
|
950
961
|
}
|
|
951
962
|
|
|
952
|
-
async
|
|
963
|
+
async deviceConfig(device: device & devicesConfig): Promise<void> {
|
|
953
964
|
let config = {};
|
|
954
965
|
if (device.humidifier) {
|
|
955
966
|
config = device.humidifier;
|
|
@@ -977,7 +988,7 @@ export class Humidifier {
|
|
|
977
988
|
}
|
|
978
989
|
}
|
|
979
990
|
|
|
980
|
-
async
|
|
991
|
+
async deviceLogs(device: device & devicesConfig): Promise<void> {
|
|
981
992
|
if (this.platform.debugMode) {
|
|
982
993
|
this.deviceLogging = this.accessory.context.logging = 'debugMode';
|
|
983
994
|
this.debugLog(`${this.device.deviceType}: ${this.accessory.displayName} Using Debug Mode Logging: ${this.deviceLogging}`);
|