homebridge-tsvesync 1.0.69 → 1.0.70
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/.clinerules +10 -0
- package/dist/accessories/air-purifier.accessory.d.ts +9 -0
- package/dist/accessories/air-purifier.accessory.d.ts.map +1 -1
- package/dist/accessories/air-purifier.accessory.js +189 -50
- package/dist/accessories/air-purifier.accessory.js.map +1 -1
- package/dist/accessories/humidifier.accessory.d.ts.map +1 -1
- package/dist/accessories/humidifier.accessory.js +121 -21
- package/dist/accessories/humidifier.accessory.js.map +1 -1
- package/package.json +2 -2
- package/src/accessories/air-purifier.accessory.ts +209 -40
- package/src/accessories/humidifier.accessory.ts +138 -23
package/.clinerules
CHANGED
|
@@ -39,6 +39,15 @@
|
|
|
39
39
|
- Redact sensitive information in logs
|
|
40
40
|
- Include operation context in log messages
|
|
41
41
|
|
|
42
|
+
### File Editing Practices
|
|
43
|
+
- Always commit working code before making significant changes
|
|
44
|
+
- Make small, incremental changes rather than large rewrites
|
|
45
|
+
- Initialize all properties in constructors with default values
|
|
46
|
+
- Be cautious when modifying interface definitions
|
|
47
|
+
- Validate type casting with explicit checks
|
|
48
|
+
- Use version control for recovery if files become corrupted
|
|
49
|
+
- See memory-bank/file-editing-guidelines.md for detailed guidelines
|
|
50
|
+
|
|
42
51
|
## Implementation Patterns
|
|
43
52
|
|
|
44
53
|
### Device Handling
|
|
@@ -133,3 +142,4 @@
|
|
|
133
142
|
- State synchronization delays during high activity
|
|
134
143
|
- Token refresh failures during network interruptions
|
|
135
144
|
- Mapping complex device modes to HomeKit characteristics
|
|
145
|
+
- File corruption during complex edits (see file-editing-guidelines.md)
|
|
@@ -5,6 +5,7 @@ import { DeviceCapabilities, VeSyncAirPurifier } from '../types/device.types';
|
|
|
5
5
|
export declare class AirPurifierAccessory extends BaseAccessory {
|
|
6
6
|
private readonly capabilities;
|
|
7
7
|
protected readonly device: VeSyncAirPurifier;
|
|
8
|
+
private isLVSeries;
|
|
8
9
|
constructor(platform: TSVESyncPlatform, accessory: PlatformAccessory, device: VeSyncAirPurifier);
|
|
9
10
|
/**
|
|
10
11
|
* Set up the air purifier service
|
|
@@ -18,6 +19,14 @@ export declare class AirPurifierAccessory extends BaseAccessory {
|
|
|
18
19
|
* Update device states based on the latest details
|
|
19
20
|
*/
|
|
20
21
|
protected updateDeviceSpecificStates(details: any): Promise<void>;
|
|
22
|
+
/**
|
|
23
|
+
* Get target state (AUTO = 0, MANUAL = 1)
|
|
24
|
+
*/
|
|
25
|
+
private getTargetState;
|
|
26
|
+
/**
|
|
27
|
+
* Set target state (AUTO = 0, MANUAL = 1)
|
|
28
|
+
*/
|
|
29
|
+
private setTargetState;
|
|
21
30
|
/**
|
|
22
31
|
* Handle set rotation speed
|
|
23
32
|
*/
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"air-purifier.accessory.d.ts","sourceRoot":"","sources":["../../src/accessories/air-purifier.accessory.ts"],"names":[],"mappings":"AAAA,OAAO,EAAuB,iBAAiB,EAAE,MAAM,YAAY,CAAC;AACpE,OAAO,EAAE,aAAa,EAAE,MAAM,kBAAkB,CAAC;AACjD,OAAO,EAAE,gBAAgB,EAAE,MAAM,aAAa,CAAC;AAC/C,OAAO,EAAE,kBAAkB,EAAE,iBAAiB,EAAE,MAAM,uBAAuB,CAAC;
|
|
1
|
+
{"version":3,"file":"air-purifier.accessory.d.ts","sourceRoot":"","sources":["../../src/accessories/air-purifier.accessory.ts"],"names":[],"mappings":"AAAA,OAAO,EAAuB,iBAAiB,EAAE,MAAM,YAAY,CAAC;AACpE,OAAO,EAAE,aAAa,EAAE,MAAM,kBAAkB,CAAC;AACjD,OAAO,EAAE,gBAAgB,EAAE,MAAM,aAAa,CAAC;AAC/C,OAAO,EAAE,kBAAkB,EAAE,iBAAiB,EAAE,MAAM,uBAAuB,CAAC;AA0B9E,qBAAa,oBAAqB,SAAQ,aAAa;IACrD,OAAO,CAAC,QAAQ,CAAC,YAAY,CAAqB;IAClD,SAAS,CAAC,QAAQ,CAAC,MAAM,EAAE,iBAAiB,CAAC;IAC7C,OAAO,CAAC,UAAU,CAAU;gBAG1B,QAAQ,EAAE,gBAAgB,EAC1B,SAAS,EAAE,iBAAiB,EAC5B,MAAM,EAAE,iBAAiB;IAe3B;;OAEG;IACH,SAAS,CAAC,YAAY,IAAI,IAAI;IAiC9B;;OAEG;IACH,SAAS,CAAC,qBAAqB,IAAI,kBAAkB;IAcrD;;OAEG;cACa,0BAA0B,CAAC,OAAO,EAAE,GAAG,GAAG,OAAO,CAAC,IAAI,CAAC;IAoDvE;;OAEG;YACW,cAAc;IAK5B;;OAEG;YACW,cAAc;IAmC5B;;OAEG;YACW,sBAAsB;YAyEtB,SAAS;YAIT,SAAS;YAmBT,gBAAgB;CA6B/B"}
|
|
@@ -4,9 +4,16 @@ exports.AirPurifierAccessory = void 0;
|
|
|
4
4
|
const base_accessory_1 = require("./base.accessory");
|
|
5
5
|
class AirPurifierAccessory extends base_accessory_1.BaseAccessory {
|
|
6
6
|
constructor(platform, accessory, device) {
|
|
7
|
+
var _a;
|
|
7
8
|
super(platform, accessory, device);
|
|
8
9
|
this.device = device;
|
|
9
10
|
this.capabilities = this.getDeviceCapabilities();
|
|
11
|
+
// Detect if this is an LV-series device (LV-PUR131S or LV-RH131S)
|
|
12
|
+
const extendedDevice = this.device;
|
|
13
|
+
this.isLVSeries = ((_a = extendedDevice.deviceType) === null || _a === void 0 ? void 0 : _a.startsWith('LV-')) || false;
|
|
14
|
+
if (this.isLVSeries) {
|
|
15
|
+
this.platform.log.debug(`Detected LV-series device: ${this.device.deviceName} (${extendedDevice.deviceType})`);
|
|
16
|
+
}
|
|
10
17
|
}
|
|
11
18
|
/**
|
|
12
19
|
* Set up the air purifier service
|
|
@@ -17,6 +24,8 @@ class AirPurifierAccessory extends base_accessory_1.BaseAccessory {
|
|
|
17
24
|
this.accessory.addService(this.platform.Service.AirPurifier);
|
|
18
25
|
// Set up required characteristics
|
|
19
26
|
this.setupCharacteristic(this.platform.Characteristic.Active, this.getActive.bind(this), this.setActive.bind(this));
|
|
27
|
+
// Set up target state characteristic for mode mapping
|
|
28
|
+
this.setupCharacteristic(this.platform.Characteristic.TargetAirPurifierState, this.getTargetState.bind(this), this.setTargetState.bind(this));
|
|
20
29
|
// Set up speed control
|
|
21
30
|
this.setupCharacteristic(this.platform.Characteristic.RotationSpeed, this.getRotationSpeed.bind(this), this.handleSetRotationSpeed.bind(this));
|
|
22
31
|
// Add Name characteristic
|
|
@@ -47,60 +56,175 @@ class AirPurifierAccessory extends base_accessory_1.BaseAccessory {
|
|
|
47
56
|
this.service.updateCharacteristic(this.platform.Characteristic.Active, isOn ? 1 : 0);
|
|
48
57
|
// Update current state (INACTIVE = 0, IDLE = 1, PURIFYING_AIR = 2)
|
|
49
58
|
this.service.updateCharacteristic(this.platform.Characteristic.CurrentAirPurifierState, isOn ? 2 : 0);
|
|
59
|
+
// Get the extended device to access mode information
|
|
60
|
+
const extendedDevice = this.device;
|
|
50
61
|
// Update target state (AUTO = 0, MANUAL = 1)
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
62
|
+
// If mode is available, use it to determine target state
|
|
63
|
+
let targetState = 1; // Default to MANUAL
|
|
64
|
+
if (extendedDevice.mode) {
|
|
65
|
+
targetState = extendedDevice.mode === 'auto' ? 0 : 1;
|
|
66
|
+
}
|
|
67
|
+
this.service.updateCharacteristic(this.platform.Characteristic.TargetAirPurifierState, targetState);
|
|
68
|
+
// Update rotation speed
|
|
54
69
|
let rotationSpeed = 0;
|
|
55
70
|
if (isOn && details.speed !== undefined) {
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
71
|
+
if (this.isLVSeries) {
|
|
72
|
+
// For LV-series devices, speed is limited to 1-3
|
|
73
|
+
// Convert device speed (1-3) to HomeKit percentage (0-100)
|
|
74
|
+
switch (details.speed) {
|
|
75
|
+
case 1:
|
|
76
|
+
rotationSpeed = 33;
|
|
77
|
+
break; // Low
|
|
78
|
+
case 2:
|
|
79
|
+
rotationSpeed = 66;
|
|
80
|
+
break; // Medium
|
|
81
|
+
case 3:
|
|
82
|
+
rotationSpeed = 100;
|
|
83
|
+
break; // High
|
|
84
|
+
}
|
|
85
|
+
}
|
|
86
|
+
else {
|
|
87
|
+
// For standard devices, speed can be 1-5
|
|
88
|
+
// Convert device speed (1-5) to HomeKit percentage (0-100)
|
|
89
|
+
switch (details.speed) {
|
|
90
|
+
case 1:
|
|
91
|
+
rotationSpeed = 20;
|
|
92
|
+
break; // Sleep
|
|
93
|
+
case 2:
|
|
94
|
+
rotationSpeed = 40;
|
|
95
|
+
break; // Low
|
|
96
|
+
case 3:
|
|
97
|
+
rotationSpeed = 60;
|
|
98
|
+
break; // Medium
|
|
99
|
+
case 4:
|
|
100
|
+
rotationSpeed = 80;
|
|
101
|
+
break; // High
|
|
102
|
+
case 5:
|
|
103
|
+
rotationSpeed = 100;
|
|
104
|
+
break; // Turbo
|
|
105
|
+
}
|
|
72
106
|
}
|
|
73
107
|
}
|
|
74
108
|
this.service.updateCharacteristic(this.platform.Characteristic.RotationSpeed, rotationSpeed);
|
|
75
109
|
}
|
|
76
110
|
/**
|
|
77
|
-
*
|
|
111
|
+
* Get target state (AUTO = 0, MANUAL = 1)
|
|
78
112
|
*/
|
|
79
|
-
async
|
|
80
|
-
const
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
113
|
+
async getTargetState() {
|
|
114
|
+
const extendedDevice = this.device;
|
|
115
|
+
return extendedDevice.mode === 'auto' ? 0 : 1;
|
|
116
|
+
}
|
|
117
|
+
/**
|
|
118
|
+
* Set target state (AUTO = 0, MANUAL = 1)
|
|
119
|
+
*/
|
|
120
|
+
async setTargetState(value) {
|
|
121
|
+
try {
|
|
122
|
+
const targetState = value;
|
|
123
|
+
const extendedDevice = this.device;
|
|
124
|
+
// Map HomeKit target states to device modes
|
|
125
|
+
const mode = targetState === 0 ? 'auto' : 'manual';
|
|
126
|
+
this.platform.log.debug(`Setting mode to ${mode} for device: ${this.device.deviceName}`);
|
|
127
|
+
let success = false;
|
|
128
|
+
// Use the appropriate method to set the mode
|
|
129
|
+
if (targetState === 0 && typeof extendedDevice.autoMode === 'function') {
|
|
130
|
+
success = await extendedDevice.autoMode();
|
|
131
|
+
}
|
|
132
|
+
else if (targetState === 1 && typeof extendedDevice.manualMode === 'function') {
|
|
133
|
+
success = await extendedDevice.manualMode();
|
|
134
|
+
}
|
|
135
|
+
else if (typeof extendedDevice.setMode === 'function') {
|
|
136
|
+
success = await extendedDevice.setMode(mode);
|
|
137
|
+
}
|
|
138
|
+
else if (typeof this.device.setMode === 'function') {
|
|
139
|
+
success = await this.device.setMode(mode);
|
|
140
|
+
}
|
|
141
|
+
else {
|
|
142
|
+
throw new Error('Device API does not support mode setting operations');
|
|
143
|
+
}
|
|
144
|
+
if (!success) {
|
|
145
|
+
throw new Error(`Failed to set mode to ${mode}`);
|
|
146
|
+
}
|
|
147
|
+
// Update device state and characteristics
|
|
148
|
+
await this.updateDeviceSpecificStates(this.device);
|
|
93
149
|
}
|
|
94
|
-
|
|
95
|
-
|
|
150
|
+
catch (error) {
|
|
151
|
+
this.handleDeviceError('set target state', error);
|
|
96
152
|
}
|
|
97
|
-
|
|
98
|
-
|
|
153
|
+
}
|
|
154
|
+
/**
|
|
155
|
+
* Handle set rotation speed
|
|
156
|
+
*/
|
|
157
|
+
async handleSetRotationSpeed(value) {
|
|
158
|
+
try {
|
|
159
|
+
const percentage = value;
|
|
160
|
+
this.platform.log.debug(`Setting rotation speed to ${percentage}% for device: ${this.device.deviceName}`);
|
|
161
|
+
if (percentage === 0) {
|
|
162
|
+
// Turn off the device instead of setting speed to 0
|
|
163
|
+
this.platform.log.debug(`Turning off device ${this.device.deviceName} due to 0% rotation speed`);
|
|
164
|
+
const success = await this.device.turnOff();
|
|
165
|
+
if (!success) {
|
|
166
|
+
throw new Error('Failed to turn off device');
|
|
167
|
+
}
|
|
168
|
+
return;
|
|
169
|
+
}
|
|
170
|
+
const extendedDevice = this.device;
|
|
171
|
+
// For LV-series devices, ensure the device is in manual mode before changing fan speed
|
|
172
|
+
if (this.isLVSeries && extendedDevice.mode !== 'manual') {
|
|
173
|
+
this.platform.log.debug(`Setting device to manual mode before changing fan speed: ${this.device.deviceName}`);
|
|
174
|
+
// Use the appropriate method to set manual mode
|
|
175
|
+
if (typeof extendedDevice.manualMode === 'function') {
|
|
176
|
+
const modeSuccess = await extendedDevice.manualMode();
|
|
177
|
+
this.platform.log.debug(`Set manual mode result: ${modeSuccess ? 'success' : 'failed'}`);
|
|
178
|
+
}
|
|
179
|
+
else if (typeof extendedDevice.setMode === 'function') {
|
|
180
|
+
const modeSuccess = await extendedDevice.setMode('manual');
|
|
181
|
+
this.platform.log.debug(`Set manual mode result: ${modeSuccess ? 'success' : 'failed'}`);
|
|
182
|
+
}
|
|
183
|
+
}
|
|
184
|
+
let speed;
|
|
185
|
+
if (this.isLVSeries) {
|
|
186
|
+
// For LV-series devices, speed is limited to 1-3
|
|
187
|
+
// Convert HomeKit percentage (0-100) to device speed (1-3)
|
|
188
|
+
if (percentage <= 33) {
|
|
189
|
+
speed = 1; // Low
|
|
190
|
+
}
|
|
191
|
+
else if (percentage <= 66) {
|
|
192
|
+
speed = 2; // Medium
|
|
193
|
+
}
|
|
194
|
+
else {
|
|
195
|
+
speed = 3; // High
|
|
196
|
+
}
|
|
197
|
+
}
|
|
198
|
+
else {
|
|
199
|
+
// For standard devices, speed can be 1-5
|
|
200
|
+
// Convert HomeKit percentage (0-100) to device speed (1-5)
|
|
201
|
+
if (percentage <= 20) {
|
|
202
|
+
speed = 1; // Sleep
|
|
203
|
+
}
|
|
204
|
+
else if (percentage <= 40) {
|
|
205
|
+
speed = 2; // Low
|
|
206
|
+
}
|
|
207
|
+
else if (percentage <= 60) {
|
|
208
|
+
speed = 3; // Medium
|
|
209
|
+
}
|
|
210
|
+
else if (percentage <= 80) {
|
|
211
|
+
speed = 4; // High
|
|
212
|
+
}
|
|
213
|
+
else {
|
|
214
|
+
speed = 5; // Turbo
|
|
215
|
+
}
|
|
216
|
+
}
|
|
217
|
+
this.platform.log.debug(`Setting fan speed to ${speed} for device: ${this.device.deviceName}`);
|
|
218
|
+
const success = await this.device.changeFanSpeed(speed);
|
|
219
|
+
if (!success) {
|
|
220
|
+
throw new Error(`Failed to set speed to ${speed}`);
|
|
221
|
+
}
|
|
222
|
+
// Update device state and characteristics
|
|
223
|
+
await this.updateDeviceSpecificStates(this.device);
|
|
99
224
|
}
|
|
100
|
-
|
|
101
|
-
speed
|
|
225
|
+
catch (error) {
|
|
226
|
+
this.handleDeviceError('set rotation speed', error);
|
|
102
227
|
}
|
|
103
|
-
await this.device.changeFanSpeed(speed);
|
|
104
228
|
}
|
|
105
229
|
async getActive() {
|
|
106
230
|
return this.device.deviceStatus === 'on' ? 1 : 0;
|
|
@@ -108,6 +232,7 @@ class AirPurifierAccessory extends base_accessory_1.BaseAccessory {
|
|
|
108
232
|
async setActive(value) {
|
|
109
233
|
try {
|
|
110
234
|
const isOn = value === 1;
|
|
235
|
+
this.platform.log.debug(`Setting device ${this.device.deviceName} to ${isOn ? 'on' : 'off'}`);
|
|
111
236
|
const success = isOn ? await this.device.turnOn() : await this.device.turnOff();
|
|
112
237
|
if (!success) {
|
|
113
238
|
throw new Error(`Failed to turn ${isOn ? 'on' : 'off'} device`);
|
|
@@ -124,15 +249,29 @@ class AirPurifierAccessory extends base_accessory_1.BaseAccessory {
|
|
|
124
249
|
if (this.device.speed === undefined || this.device.speed === null) {
|
|
125
250
|
return 0;
|
|
126
251
|
}
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
252
|
+
if (this.isLVSeries) {
|
|
253
|
+
// For LV-series devices, speed is limited to 1-3
|
|
254
|
+
// Convert device speed (1-3) to HomeKit percentage (0-100)
|
|
255
|
+
switch (this.device.speed) {
|
|
256
|
+
case 0: return 0; // Off
|
|
257
|
+
case 1: return 33; // Low
|
|
258
|
+
case 2: return 66; // Medium
|
|
259
|
+
case 3: return 100; // High
|
|
260
|
+
default: return 0;
|
|
261
|
+
}
|
|
262
|
+
}
|
|
263
|
+
else {
|
|
264
|
+
// For standard devices, speed can be 1-5
|
|
265
|
+
// Convert device speed (1-5) to HomeKit percentage (0-100)
|
|
266
|
+
switch (this.device.speed) {
|
|
267
|
+
case 0: return 0; // Off
|
|
268
|
+
case 1: return 20; // Sleep
|
|
269
|
+
case 2: return 40; // Low
|
|
270
|
+
case 3: return 60; // Medium
|
|
271
|
+
case 4: return 80; // High
|
|
272
|
+
case 5: return 100; // Turbo
|
|
273
|
+
default: return 0;
|
|
274
|
+
}
|
|
136
275
|
}
|
|
137
276
|
}
|
|
138
277
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"air-purifier.accessory.js","sourceRoot":"","sources":["../../src/accessories/air-purifier.accessory.ts"],"names":[],"mappings":";;;AACA,qDAAiD;
|
|
1
|
+
{"version":3,"file":"air-purifier.accessory.js","sourceRoot":"","sources":["../../src/accessories/air-purifier.accessory.ts"],"names":[],"mappings":";;;AACA,qDAAiD;AA4BjD,MAAa,oBAAqB,SAAQ,8BAAa;IAKrD,YACE,QAA0B,EAC1B,SAA4B,EAC5B,MAAyB;;QAEzB,KAAK,CAAC,QAAQ,EAAE,SAAS,EAAE,MAAM,CAAC,CAAC;QACnC,IAAI,CAAC,MAAM,GAAG,MAAM,CAAC;QACrB,IAAI,CAAC,YAAY,G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C,CAAC,OAAO,EAAE,CAAC,CAAE,SAAS;gBAC7B,KAAK,CAAC,CAAC,CAAC,OAAO,EAAE,CAAC,CAAE,OAAO;gBAC3B,KAAK,CAAC,CAAC,CAAC,OAAO,GAAG,CAAC,CAAC,QAAQ;gBAC5B,OAAO,CAAC,CAAC,OAAO,CAAC,CAAC;aACnB;SACF;IACH,CAAC;CACF;AAjTD,oDAiTC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"humidifier.accessory.d.ts","sourceRoot":"","sources":["../../src/accessories/humidifier.accessory.ts"],"names":[],"mappings":"AAAA,OAAO,EAAuB,iBAAiB,EAAW,MAAM,YAAY,CAAC;AAC7E,OAAO,EAAE,aAAa,EAAE,MAAM,kBAAkB,CAAC;AACjD,OAAO,EAAE,gBAAgB,EAAE,MAAM,aAAa,CAAC;AAC/C,OAAO,EAAE,kBAAkB,EAAE,gBAAgB,EAAE,MAAM,uBAAuB,CAAC;
|
|
1
|
+
{"version":3,"file":"humidifier.accessory.d.ts","sourceRoot":"","sources":["../../src/accessories/humidifier.accessory.ts"],"names":[],"mappings":"AAAA,OAAO,EAAuB,iBAAiB,EAAW,MAAM,YAAY,CAAC;AAC7E,OAAO,EAAE,aAAa,EAAE,MAAM,kBAAkB,CAAC;AACjD,OAAO,EAAE,gBAAgB,EAAE,MAAM,aAAa,CAAC;AAC/C,OAAO,EAAE,kBAAkB,EAAE,gBAAgB,EAAE,MAAM,uBAAuB,CAAC;AAuD7E,qBAAa,mBAAoB,SAAQ,aAAa;IACpD,SAAS,CAAC,QAAQ,CAAC,MAAM,EAAE,gBAAgB,CAAC;IAC5C,OAAO,CAAC,YAAY,CAAqB;IACzC,OAAO,CAAC,cAAc,CAAU;IAChC,OAAO,CAAC,YAAY,CAAC,CAAU;gBAG7B,QAAQ,EAAE,gBAAgB,EAC1B,SAAS,EAAE,iBAAiB,EAC5B,MAAM,EAAE,gBAAgB;IA0B1B;;OAEG;IACH,OAAO,CAAC,kBAAkB;IAa1B,SAAS,CAAC,YAAY,IAAI,IAAI;IAqH9B;;OAEG;IACH,OAAO,CAAC,sBAAsB;IA0B9B;;OAEG;YACW,eAAe;IAO7B;;OAEG;YACW,eAAe;IAoB7B;;OAEG;YACW,uBAAuB;IAMrC;;OAEG;YACW,uBAAuB;IAmBrC;;OAEG;cACa,0BAA0B,CAAC,OAAO,EAAE,GAAG,GAAG,OAAO,CAAC,IAAI,CAAC;IA2NvE,SAAS,CAAC,qBAAqB,IAAI,kBAAkB;YAcvC,SAAS;YA4BT,SAAS;YAqJT,gBAAgB;YAqBhB,cAAc;YA4Jd,sBAAsB;IA0EpC;;OAEG;IACH;;OAEG;YACW,iBAAiB;IAsB/B;;OAEG;YACW,iBAAiB;IAkE/B,OAAO,CAAC,gCAAgC;CAWzC"}
|
|
@@ -43,6 +43,12 @@ class HumidifierAccessory extends base_accessory_1.BaseAccessory {
|
|
|
43
43
|
// Get or create the humidifier service
|
|
44
44
|
this.service = this.accessory.getService(this.platform.Service.HumidifierDehumidifier) ||
|
|
45
45
|
this.accessory.addService(this.platform.Service.HumidifierDehumidifier);
|
|
46
|
+
// Initialize all characteristics with explicit values
|
|
47
|
+
this.service.updateCharacteristic(this.platform.Characteristic.CurrentRelativeHumidity, 40);
|
|
48
|
+
this.service.updateCharacteristic(this.platform.Characteristic.RelativeHumidityHumidifierThreshold, 60);
|
|
49
|
+
this.service.updateCharacteristic(this.platform.Characteristic.CurrentHumidifierDehumidifierState, 1);
|
|
50
|
+
this.service.updateCharacteristic(this.platform.Characteristic.TargetHumidifierDehumidifierState, 1);
|
|
51
|
+
this.platform.log.debug('Initialized humidifier characteristics with explicit values');
|
|
46
52
|
// Set up required characteristics
|
|
47
53
|
this.setupCharacteristic(this.platform.Characteristic.Active, this.getActive.bind(this), this.setActive.bind(this));
|
|
48
54
|
// Set up target state characteristic for mode mapping
|
|
@@ -72,8 +78,25 @@ class HumidifierAccessory extends base_accessory_1.BaseAccessory {
|
|
|
72
78
|
if (!this.service.testCharacteristic(this.platform.Characteristic.RelativeHumidityHumidifierThreshold)) {
|
|
73
79
|
this.service.addCharacteristic(this.platform.Characteristic.RelativeHumidityHumidifierThreshold);
|
|
74
80
|
}
|
|
81
|
+
// Configure the target humidity characteristic with proper properties
|
|
82
|
+
const targetHumidityChar = this.service.getCharacteristic(this.platform.Characteristic.RelativeHumidityHumidifierThreshold);
|
|
83
|
+
targetHumidityChar.setProps({
|
|
84
|
+
minValue: 30,
|
|
85
|
+
maxValue: 80,
|
|
86
|
+
minStep: 1
|
|
87
|
+
});
|
|
88
|
+
// Set an initial value to ensure the characteristic is not blank
|
|
89
|
+
targetHumidityChar.updateValue(45);
|
|
90
|
+
this.platform.log.debug(`Configured RelativeHumidityHumidifierThreshold characteristic with initial value 45%`);
|
|
75
91
|
// Set up handlers for target humidity
|
|
76
92
|
this.setupCharacteristic(this.platform.Characteristic.RelativeHumidityHumidifierThreshold, this.getTargetHumidity.bind(this), this.setTargetHumidity.bind(this));
|
|
93
|
+
// Immediately get and set the actual target humidity to ensure it's displayed correctly
|
|
94
|
+
this.getTargetHumidity().then(targetHumidity => {
|
|
95
|
+
this.platform.log.debug(`Initial target humidity value: ${targetHumidity}%`);
|
|
96
|
+
targetHumidityChar.updateValue(targetHumidity);
|
|
97
|
+
}).catch(error => {
|
|
98
|
+
this.platform.log.warn(`Failed to get initial target humidity: ${error}`);
|
|
99
|
+
});
|
|
77
100
|
}
|
|
78
101
|
// Add Water Level characteristic if supported (mapping inferred from water_lacks/water_tank_lifted)
|
|
79
102
|
if (this.capabilities && this.capabilities.hasWaterLevel) {
|
|
@@ -167,7 +190,7 @@ class HumidifierAccessory extends base_accessory_1.BaseAccessory {
|
|
|
167
190
|
* Update device states based on the latest details
|
|
168
191
|
*/
|
|
169
192
|
async updateDeviceSpecificStates(details) {
|
|
170
|
-
var _a, _b;
|
|
193
|
+
var _a, _b, _c, _d, _e, _f;
|
|
171
194
|
// Log the relevant details for debugging without using JSON.stringify on the entire object
|
|
172
195
|
this.platform.log.debug(`Updating device states for ${this.device.deviceName}`);
|
|
173
196
|
// Cast to extended device type
|
|
@@ -206,14 +229,32 @@ class HumidifierAccessory extends base_accessory_1.BaseAccessory {
|
|
|
206
229
|
// Mapping:
|
|
207
230
|
// - If not active -> INACTIVE (0)
|
|
208
231
|
// - If active and mode is 'manual' -> HUMIDIFYING (2)
|
|
209
|
-
// - If active and mode is 'auto' or 'sleep' ->
|
|
232
|
+
// - If active and mode is 'auto' or 'sleep' -> Check if we need to be humidifying
|
|
210
233
|
let currentState = 0; // Default to INACTIVE
|
|
211
234
|
if (isActive) {
|
|
212
235
|
if (extendedDevice.mode === 'manual') {
|
|
213
|
-
currentState = 2; // HUMIDIFYING
|
|
236
|
+
currentState = 2; // HUMIDIFYING - will show "Rising to X%"
|
|
214
237
|
}
|
|
215
238
|
else if (extendedDevice.mode === 'auto' || extendedDevice.mode === 'sleep') {
|
|
216
|
-
|
|
239
|
+
// Get current humidity reading (actual humidity in the room)
|
|
240
|
+
const currentHumidity = extendedDevice.currentHumidity !== undefined ?
|
|
241
|
+
extendedDevice.currentHumidity :
|
|
242
|
+
((_a = extendedDevice.details) === null || _a === void 0 ? void 0 : _a.current_humidity) ||
|
|
243
|
+
0;
|
|
244
|
+
// Get target humidity (humidity setting)
|
|
245
|
+
const targetHumidity = extendedDevice.humidity ||
|
|
246
|
+
((_b = extendedDevice.configuration) === null || _b === void 0 ? void 0 : _b.auto_target_humidity) ||
|
|
247
|
+
((_c = extendedDevice.details) === null || _c === void 0 ? void 0 : _c.target_humidity) ||
|
|
248
|
+
45; // Default to 45% if not available
|
|
249
|
+
// In auto mode, check if we need to be humidifying
|
|
250
|
+
if (currentHumidity < targetHumidity) {
|
|
251
|
+
currentState = 2; // HUMIDIFYING - will show "Rising to X%"
|
|
252
|
+
this.platform.log.debug(`Auto mode: Current humidity ${currentHumidity}% is below target ${targetHumidity}%, setting state to HUMIDIFYING`);
|
|
253
|
+
}
|
|
254
|
+
else {
|
|
255
|
+
currentState = 1; // IDLE - will show "Set to X%"
|
|
256
|
+
this.platform.log.debug(`Auto mode: Current humidity ${currentHumidity}% has reached target ${targetHumidity}%, setting state to IDLE`);
|
|
257
|
+
}
|
|
217
258
|
}
|
|
218
259
|
}
|
|
219
260
|
this.service.updateCharacteristic(this.platform.Characteristic.CurrentHumidifierDehumidifierState, currentState);
|
|
@@ -303,12 +344,21 @@ class HumidifierAccessory extends base_accessory_1.BaseAccessory {
|
|
|
303
344
|
this.platform.log.debug(`Setting rotation speed to ${rotationSpeed}% for device: ${this.device.deviceName}`);
|
|
304
345
|
this.service.updateCharacteristic(this.platform.Characteristic.RotationSpeed, rotationSpeed);
|
|
305
346
|
// Update relative humidity if supported
|
|
306
|
-
if (this.capabilities && this.capabilities.hasHumidity
|
|
307
|
-
|
|
308
|
-
|
|
309
|
-
|
|
310
|
-
((
|
|
311
|
-
|
|
347
|
+
if (this.capabilities && this.capabilities.hasHumidity) {
|
|
348
|
+
// Get current humidity reading (actual humidity in the room)
|
|
349
|
+
const currentHumidity = extendedDevice.currentHumidity !== undefined ?
|
|
350
|
+
extendedDevice.currentHumidity :
|
|
351
|
+
((_d = extendedDevice.details) === null || _d === void 0 ? void 0 : _d.current_humidity) ||
|
|
352
|
+
0;
|
|
353
|
+
// Update current humidity characteristic if we have a valid reading
|
|
354
|
+
if (currentHumidity > 0) {
|
|
355
|
+
this.service.updateCharacteristic(this.platform.Characteristic.CurrentRelativeHumidity, currentHumidity);
|
|
356
|
+
}
|
|
357
|
+
// Get target humidity (humidity setting)
|
|
358
|
+
// According to API docs, humidifier.humidity returns auto_target_humidity from configuration
|
|
359
|
+
const targetHumidity = extendedDevice.humidity ||
|
|
360
|
+
((_e = extendedDevice.configuration) === null || _e === void 0 ? void 0 : _e.auto_target_humidity) ||
|
|
361
|
+
((_f = extendedDevice.details) === null || _f === void 0 ? void 0 : _f.target_humidity) ||
|
|
312
362
|
45; // Default to 45% if not available
|
|
313
363
|
if (this.service.testCharacteristic(this.platform.Characteristic.RelativeHumidityHumidifierThreshold)) {
|
|
314
364
|
this.service.updateCharacteristic(this.platform.Characteristic.RelativeHumidityHumidifierThreshold, targetHumidity);
|
|
@@ -375,6 +425,7 @@ class HumidifierAccessory extends base_accessory_1.BaseAccessory {
|
|
|
375
425
|
return isActive ? 1 : 0;
|
|
376
426
|
}
|
|
377
427
|
async setActive(value) {
|
|
428
|
+
var _a, _b, _c;
|
|
378
429
|
try {
|
|
379
430
|
const isOn = value === 1;
|
|
380
431
|
this.platform.log.debug(`Setting device ${this.device.deviceName} to ${isOn ? 'on' : 'off'}`);
|
|
@@ -455,9 +506,33 @@ class HumidifierAccessory extends base_accessory_1.BaseAccessory {
|
|
|
455
506
|
// Always update HomeKit with the actual device state, not the requested state
|
|
456
507
|
this.service.updateCharacteristic(this.platform.Characteristic.Active, actuallyOn ? 1 : 0);
|
|
457
508
|
// Update current state based on the actual state and mode
|
|
458
|
-
|
|
459
|
-
|
|
460
|
-
|
|
509
|
+
let currentState = 0; // Default to INACTIVE
|
|
510
|
+
if (actuallyOn) {
|
|
511
|
+
if (extendedDevice.mode === 'manual') {
|
|
512
|
+
currentState = 2; // HUMIDIFYING - will show "Rising to X%"
|
|
513
|
+
}
|
|
514
|
+
else if (extendedDevice.mode === 'auto' || extendedDevice.mode === 'sleep') {
|
|
515
|
+
// Get current humidity reading (actual humidity in the room)
|
|
516
|
+
const currentHumidity = extendedDevice.currentHumidity !== undefined ?
|
|
517
|
+
extendedDevice.currentHumidity :
|
|
518
|
+
((_a = extendedDevice.details) === null || _a === void 0 ? void 0 : _a.current_humidity) ||
|
|
519
|
+
0;
|
|
520
|
+
// Get target humidity (humidity setting)
|
|
521
|
+
const targetHumidity = extendedDevice.humidity ||
|
|
522
|
+
((_b = extendedDevice.configuration) === null || _b === void 0 ? void 0 : _b.auto_target_humidity) ||
|
|
523
|
+
((_c = extendedDevice.details) === null || _c === void 0 ? void 0 : _c.target_humidity) ||
|
|
524
|
+
45; // Default to 45% if not available
|
|
525
|
+
// In auto mode, check if we need to be humidifying
|
|
526
|
+
if (currentHumidity < targetHumidity) {
|
|
527
|
+
currentState = 2; // HUMIDIFYING - will show "Rising to X%"
|
|
528
|
+
this.platform.log.debug(`Auto mode: Current humidity ${currentHumidity}% is below target ${targetHumidity}%, setting state to HUMIDIFYING`);
|
|
529
|
+
}
|
|
530
|
+
else {
|
|
531
|
+
currentState = 1; // IDLE - will show "Set to X%"
|
|
532
|
+
this.platform.log.debug(`Auto mode: Current humidity ${currentHumidity}% has reached target ${targetHumidity}%, setting state to IDLE`);
|
|
533
|
+
}
|
|
534
|
+
}
|
|
535
|
+
}
|
|
461
536
|
this.service.updateCharacteristic(this.platform.Characteristic.CurrentHumidifierDehumidifierState, currentState);
|
|
462
537
|
// Update device state and characteristics
|
|
463
538
|
await this.updateDeviceSpecificStates(this.device);
|
|
@@ -487,6 +562,7 @@ class HumidifierAccessory extends base_accessory_1.BaseAccessory {
|
|
|
487
562
|
}
|
|
488
563
|
}
|
|
489
564
|
async setTargetState(value) {
|
|
565
|
+
var _a, _b, _c;
|
|
490
566
|
try {
|
|
491
567
|
// HomeKit Target State: 0 = HUMIDIFIER_OR_DEHUMIDIFIER (Auto), 1 = HUMIDIFIER, 2 = DEHUMIDIFIER
|
|
492
568
|
this.platform.log.debug(`Setting target state to ${value} for device: ${this.device.deviceName}`);
|
|
@@ -584,9 +660,33 @@ class HumidifierAccessory extends base_accessory_1.BaseAccessory {
|
|
|
584
660
|
const targetState = actualMode === 'auto' ? 0 : 1;
|
|
585
661
|
this.updateCharacteristicValue(this.platform.Characteristic.TargetHumidifierDehumidifierState, targetState);
|
|
586
662
|
// Update current state based on the active state and mode
|
|
587
|
-
|
|
588
|
-
|
|
589
|
-
|
|
663
|
+
let currentState = 0; // Default to INACTIVE
|
|
664
|
+
if (this.device.deviceStatus === 'on') {
|
|
665
|
+
if (actualMode === 'manual') {
|
|
666
|
+
currentState = 2; // HUMIDIFYING - will show "Rising to X%"
|
|
667
|
+
}
|
|
668
|
+
else if (actualMode === 'auto' || actualMode === 'sleep') {
|
|
669
|
+
// Get current humidity reading (actual humidity in the room)
|
|
670
|
+
const currentHumidity = device.currentHumidity !== undefined ?
|
|
671
|
+
device.currentHumidity :
|
|
672
|
+
((_a = device.details) === null || _a === void 0 ? void 0 : _a.current_humidity) ||
|
|
673
|
+
0;
|
|
674
|
+
// Get target humidity (humidity setting)
|
|
675
|
+
const targetHumidity = device.humidity ||
|
|
676
|
+
((_b = device.configuration) === null || _b === void 0 ? void 0 : _b.auto_target_humidity) ||
|
|
677
|
+
((_c = device.details) === null || _c === void 0 ? void 0 : _c.target_humidity) ||
|
|
678
|
+
45; // Default to 45% if not available
|
|
679
|
+
// In auto mode, check if we need to be humidifying
|
|
680
|
+
if (currentHumidity < targetHumidity) {
|
|
681
|
+
currentState = 2; // HUMIDIFYING - will show "Rising to X%"
|
|
682
|
+
this.platform.log.debug(`Auto mode: Current humidity ${currentHumidity}% is below target ${targetHumidity}%, setting state to HUMIDIFYING`);
|
|
683
|
+
}
|
|
684
|
+
else {
|
|
685
|
+
currentState = 1; // IDLE - will show "Set to X%"
|
|
686
|
+
this.platform.log.debug(`Auto mode: Current humidity ${currentHumidity}% has reached target ${targetHumidity}%, setting state to IDLE`);
|
|
687
|
+
}
|
|
688
|
+
}
|
|
689
|
+
}
|
|
590
690
|
this.updateCharacteristicValue(this.platform.Characteristic.CurrentHumidifierDehumidifierState, currentState);
|
|
591
691
|
// Update device state and characteristics
|
|
592
692
|
await this.updateDeviceSpecificStates(this.device);
|
|
@@ -679,7 +779,11 @@ class HumidifierAccessory extends base_accessory_1.BaseAccessory {
|
|
|
679
779
|
*/
|
|
680
780
|
async getTargetHumidity() {
|
|
681
781
|
const extendedDevice = this.device;
|
|
682
|
-
//
|
|
782
|
+
// According to API docs, humidifier.humidity returns auto_target_humidity from configuration
|
|
783
|
+
if (typeof extendedDevice.humidity !== 'undefined') {
|
|
784
|
+
return extendedDevice.humidity;
|
|
785
|
+
}
|
|
786
|
+
// Fall back to configuration for auto_target_humidity
|
|
683
787
|
if (extendedDevice.configuration && typeof extendedDevice.configuration.auto_target_humidity !== 'undefined') {
|
|
684
788
|
return extendedDevice.configuration.auto_target_humidity;
|
|
685
789
|
}
|
|
@@ -687,10 +791,6 @@ class HumidifierAccessory extends base_accessory_1.BaseAccessory {
|
|
|
687
791
|
if (extendedDevice.details && typeof extendedDevice.details.target_humidity !== 'undefined') {
|
|
688
792
|
return extendedDevice.details.target_humidity;
|
|
689
793
|
}
|
|
690
|
-
// Try to get target humidity from device property
|
|
691
|
-
if (typeof extendedDevice.targetHumidity !== 'undefined') {
|
|
692
|
-
return extendedDevice.targetHumidity;
|
|
693
|
-
}
|
|
694
794
|
// Default to 45% if no target humidity is available
|
|
695
795
|
return 45;
|
|
696
796
|
}
|