homebridge-tsvesync 1.1.2 → 1.3.4

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.
Files changed (35) hide show
  1. package/CHANGELOG.md +312 -0
  2. package/dist/accessories/air-purifier.accessory.d.ts +1 -0
  3. package/dist/accessories/air-purifier.accessory.d.ts.map +1 -1
  4. package/dist/accessories/air-purifier.accessory.js +38 -26
  5. package/dist/accessories/air-purifier.accessory.js.map +1 -1
  6. package/dist/accessories/light.accessory.d.ts +25 -3
  7. package/dist/accessories/light.accessory.d.ts.map +1 -1
  8. package/dist/accessories/light.accessory.js +290 -14
  9. package/dist/accessories/light.accessory.js.map +1 -1
  10. package/dist/platform.d.ts +18 -0
  11. package/dist/platform.d.ts.map +1 -1
  12. package/dist/platform.js +224 -11
  13. package/dist/platform.js.map +1 -1
  14. package/dist/types/device.types.d.ts +16 -0
  15. package/dist/types/device.types.d.ts.map +1 -1
  16. package/dist/utils/api-proxy.d.ts +4 -1
  17. package/dist/utils/api-proxy.d.ts.map +1 -1
  18. package/dist/utils/api-proxy.js +5 -3
  19. package/dist/utils/api-proxy.js.map +1 -1
  20. package/dist/utils/device-factory.d.ts +1 -0
  21. package/dist/utils/device-factory.d.ts.map +1 -1
  22. package/dist/utils/device-factory.js +10 -2
  23. package/dist/utils/device-factory.js.map +1 -1
  24. package/dist/utils/session-store.d.ts +28 -0
  25. package/dist/utils/session-store.d.ts.map +1 -0
  26. package/dist/utils/session-store.js +92 -0
  27. package/dist/utils/session-store.js.map +1 -0
  28. package/package.json +2 -2
  29. package/src/accessories/air-purifier.accessory.ts +38 -22
  30. package/src/accessories/light.accessory.ts +415 -34
  31. package/src/platform.ts +223 -9
  32. package/src/types/device.types.ts +18 -0
  33. package/src/utils/api-proxy.ts +8 -2
  34. package/src/utils/device-factory.ts +16 -4
  35. package/src/utils/session-store.ts +92 -0
package/CHANGELOG.md CHANGED
@@ -1,5 +1,317 @@
1
1
  # Changelog
2
2
 
3
+ ## 1.3.4 (2025-09-18)
4
+
5
+ ### Added
6
+ - **🕹️ ESWD16 Dimming in HomeKit**: ESWD16 dimmer switches now register as HomeKit `Lightbulb` accessories with native On/Off and Brightness control.
7
+ - **🌈 Indicator Ring Control**: Introduced a dedicated "Indicator" light service for the ESWD16 locator ring, including Hue/Saturation control powered by automatic HSV→RGB conversion.
8
+
9
+ ### Improved
10
+ - **🔄 State Synchronization**: On/Off and brightness updates now refresh ESWD16 cloud state immediately, keeping HomeKit characteristics accurate even when VeSync lags.
11
+ - **🛡️ Polling Guardrails**: Background discovery is now serialized and paired with UUID-stable Air Quality accessories, preventing duplicate registrations and overlapping sync loops.
12
+
13
+ ### Dependencies
14
+ - **📦 tsvesync**: Upgraded to 1.3.4 to stay aligned with the latest ESWD16 API surfaces.
15
+
16
+ ## 1.3.3 (2025-01-05)
17
+
18
+ ### Fixed
19
+ - **⏰ Extended Timeout Chain Fix**: Enhanced proactive token refresh system to handle very long-duration tokens
20
+ - **🔧 Timeout Chaining**: Implemented timeout chaining for refresh delays exceeding Node.js setTimeout maximum (~24.8 days)
21
+ - **🛡️ Robust Scheduling**: Prevents timer overflow errors with automatic timer chaining for extended token lifetimes
22
+ - **⚡ Seamless Operation**: Long-duration token refresh scheduling now works reliably without timing limitations
23
+ - **🎯 Precision Handling**: Maintains accurate refresh timing even for tokens with extended lifetimes
24
+ - **📊 Enhanced Logging**: Improved logging for chained timer operations and extended refresh scheduling
25
+
26
+ - **🔄 Session Hydration Compatibility**: Enhanced session recovery with backward compatibility
27
+ - **🛡️ Fallback Support**: Added backward-compatible session hydration for older tsvesync versions
28
+ - **⚡ Direct Field Setting**: Automatic fallback to direct field setting when hydrateSession method unavailable
29
+ - **🔧 Improved Reliability**: Enhanced session recovery across different tsvesync library versions
30
+ - **📊 Better Error Handling**: Graceful handling of version compatibility during session restoration
31
+
32
+ ### Enhanced
33
+ - **🎯 Timer Management**: Advanced timer management system for extended timeout scenarios
34
+ - **🔧 MAX_DELAY Handling**: Proper handling of Node.js setTimeout maximum delay limitations (2,147,483,647 ms)
35
+ - **⚡ Chain Calculation**: Intelligent timer chaining with accurate remaining time calculations
36
+ - **🛡️ Error Prevention**: Prevents timer overflow errors and ensures reliable long-duration scheduling
37
+ - **📈 Performance**: Optimized timer chaining with minimal overhead for standard use cases
38
+
39
+ ### Technical Details
40
+ - **🏗️ Timeout Architecture**: Enhanced proactive refresh system with timeout chaining support
41
+ - **📊 Timer Chain Logic**: Automatic detection and handling of timeouts exceeding Node.js limitations
42
+ - **🔧 Compatibility Layer**: Backward-compatible session hydration for various tsvesync versions
43
+ - **⚡ Precision Timing**: Maintains accurate refresh timing regardless of token lifetime duration
44
+
45
+ ### Dependencies
46
+ - **📦 tsvesync**: Updated to 1.3.3 for enhanced cross-project version synchronization
47
+
48
+ ### Summary of All Enhancements from v1.2.0 onwards
49
+
50
+ #### Session Management & Authentication System (v1.2.0-1.3.3)
51
+ - **💾 Complete Session Persistence**: Sessions survive across Homebridge restarts with enhanced validation
52
+ - **⏰ Advanced Proactive Token Refresh**: Intelligent refresh scheduling with extended timeout support (v1.3.0-1.3.3)
53
+ - **🔐 Enhanced Security**: Username validation and account isolation for multi-user environments
54
+ - **📊 JWT Token Mastery**: Complete lifecycle management with normalized timestamp handling
55
+ - **🛡️ Secure Storage**: Protected session storage with comprehensive validation and recovery
56
+ - **🚀 Performance Optimization**: Reduced authentication overhead with intelligent session reuse
57
+ - **🔄 Cross-Region Support**: Enhanced compatibility with different VeSync regional endpoints
58
+ - **🎯 Extended Timeout Handling**: Reliable scheduling for very long-duration token refresh scenarios (NEW in 1.3.3)
59
+
60
+ #### Speed Control & HomeKit Integration (v1.2.0-1.3.1)
61
+ - **🎛️ Advanced Speed Control**: Dynamic support for 3-4+ speed air purifiers with model-specific logic
62
+ - **🌙 Intelligent Sleep Mode**: Sleep mode integration as first notch on HomeKit slider
63
+ - **🎯 Precision Mapping**: Accurate percentage-to-speed conversions for different device capabilities
64
+ - **📱 Enhanced UX**: Improved slider positions, speed transitions, and HomeKit responsiveness
65
+ - **🔄 Smart Notch System**: Automatic adjustment based on device capabilities and speed ranges
66
+
67
+ Full changelog: https://github.com/mickgiles/homebridge-tsvesync/blob/main/CHANGELOG.md
68
+
69
+ ## 1.3.2 (2025-01-05)
70
+
71
+ ### Enhanced
72
+ - **🔐 Advanced Session Management**: Comprehensive improvements to session persistence and authentication reliability
73
+ - **👤 Enhanced Username Validation**: Session reuse now validates username to prevent cross-account authentication conflicts
74
+ - **🔒 Improved Account Isolation**: Persisted sessions are properly isolated and validated against configured accounts
75
+ - **💾 Optimized Session Persistence**: Best-effort session saving immediately after successful authentication
76
+ - **📝 Detailed Session Logging**: Comprehensive debug logging for session save/load operations with expiration tracking
77
+ - **🛡️ Robust Error Handling**: Enhanced error messages and recovery flows for session hydration failures
78
+
79
+ - **🔧 JWT Timestamp Precision Handling**: Enhanced token timestamp processing for consistent authentication
80
+ - **📊 Timestamp Normalization**: Automatic detection and conversion of millisecond timestamps to seconds
81
+ - **⚡ Improved Token Validation**: Ensures accurate token expiration calculations across different token formats
82
+ - **🔄 Cross-Region Compatibility**: Better handling of JWT tokens from different VeSync regional endpoints
83
+ - **🛡️ Edge Case Prevention**: Fixes authentication issues with tokens using inconsistent timestamp precision
84
+
85
+ ### Fixed
86
+ - **🎛️ Session Hydration Reliability**: Improved session recovery and validation processes
87
+ - **🔍 Better Error Detection**: Enhanced detection of invalid or corrupted session data
88
+ - **📈 Startup Performance**: Optimized authentication flow to reduce unnecessary login attempts
89
+ - **⚡ Token Lifecycle Management**: Better coordination with tsvesync library's token refresh mechanisms
90
+ - **🛡️ Authentication Stability**: Reduced authentication interruptions during long-running sessions
91
+
92
+ ### Technical Details
93
+ - **🏗️ Session Architecture**: Enhanced session store with improved persistence and validation logic
94
+ - **📊 Token Management**: Advanced JWT token handling with normalized timestamp precision
95
+ - **🔧 Error Handling**: Comprehensive error recovery flows with detailed logging and debugging
96
+ - **⚡ Performance**: Optimized session operations for better startup performance and reliability
97
+
98
+ ### Dependencies
99
+ - **📦 tsvesync**: Updated to 1.3.2 for enhanced JWT timestamp handling and session management improvements
100
+
101
+ ### Summary of All Enhancements from v1.2.0 onwards
102
+
103
+ #### Session Management & Authentication System (v1.2.0-1.3.2)
104
+ - **💾 Complete Session Persistence**: Sessions survive across Homebridge restarts with enhanced validation
105
+ - **⏰ Advanced Proactive Token Refresh**: Intelligent refresh scheduling prevents JWT expiration (v1.3.0)
106
+ - **🔐 Enhanced Security**: Username validation and account isolation for multi-user environments
107
+ - **📊 JWT Token Mastery**: Complete lifecycle management with normalized timestamp handling
108
+ - **🛡️ Secure Storage**: Protected session storage with comprehensive validation and recovery
109
+ - **🚀 Performance Optimization**: Reduced authentication overhead with intelligent session reuse
110
+ - **🔄 Cross-Region Support**: Enhanced compatibility with different VeSync regional endpoints
111
+
112
+ #### Speed Control & HomeKit Integration (v1.2.0-1.3.1)
113
+ - **🎛️ Advanced Speed Control**: Dynamic support for 3-4+ speed air purifiers with model-specific logic
114
+ - **🌙 Intelligent Sleep Mode**: Sleep mode integration as first notch on HomeKit slider
115
+ - **🎯 Precision Mapping**: Accurate percentage-to-speed conversions for different device capabilities
116
+ - **📱 Enhanced UX**: Improved slider positions, speed transitions, and HomeKit responsiveness
117
+ - **🔄 Smart Notch System**: Automatic adjustment based on device capabilities and speed ranges
118
+
119
+ Full changelog: https://github.com/mickgiles/homebridge-tsvesync/blob/main/CHANGELOG.md
120
+
121
+ ## 1.3.1 (2025-09-04)
122
+
123
+ ### Fixed
124
+ - **🔐 Enhanced Session Management**: Improved session persistence and authentication flow
125
+ - **👤 Username Validation**: Session reuse now validates username to prevent cross-account conflicts
126
+ - **🔒 Account Isolation**: Persisted sessions are ignored if they belong to a different configured account
127
+ - **⚡ Optimized Login Flow**: Authentication only occurs when necessary, relying on persisted tokens and library re-login
128
+ - **🛡️ Session Security**: Enhanced session storage with username tracking for better account management
129
+
130
+ - **🎛️ Core 200S Speed Control Improvements**: Enhanced air purifier speed control for Core 200S devices
131
+ - **🎯 Model-Specific Logic**: Core 200S now uses dedicated speed calculation method with proper 25% steps
132
+ - **📊 Accurate Mapping**: Improved speed-to-percentage conversion for devices with 3 manual speeds
133
+ - **🌙 Sleep Mode Integration**: Better sleep mode handling with model-specific speed ranges
134
+ - **🔄 Precise Notch Calculation**: Enhanced notch-to-speed mapping for more accurate HomeKit control
135
+
136
+ ### Enhanced
137
+ - **📝 Improved Logging**: Better debugging information for mode changes and device operations
138
+ - **🔍 Mode Change Tracking**: Enhanced logging for manual, auto, and sleep mode transitions
139
+ - **🎛️ Speed Control Logging**: More detailed logging for speed changes and slider operations
140
+ - **📱 HomeKit Integration**: Better visibility into device state changes and characteristic updates
141
+
142
+ ### Changed
143
+ - **🔄 Authentication Strategy**: Optimized authentication flow to reduce unnecessary login attempts
144
+ - **💾 Token Persistence**: Improved reliance on persisted tokens with library-managed re-authentication
145
+ - **⚡ Startup Performance**: Faster platform initialization by avoiding redundant login checks
146
+ - **🎯 Smart Re-login**: Authentication only triggered when API returns 401/419 status codes
147
+
148
+ ### Technical Details
149
+ - **🏗️ Session Architecture**: Enhanced session store with username tracking and validation
150
+ - **🎛️ Speed Control Algorithm**: Model-specific speed calculation methods for different device types
151
+ - **🔧 Authentication Flow**: Streamlined login logic with better token lifecycle management
152
+ - **📊 Core 200S Support**: Dedicated isCore200S() method for model-specific functionality
153
+
154
+ ### Dependencies
155
+ - **📦 tsvesync**: Updated to 1.3.1 for enhanced token expiration detection and authentication improvements
156
+
157
+ ## 1.3.0 (2025-09-04)
158
+
159
+ ### Added
160
+ - **⏰ Enhanced Proactive Token Refresh**: Advanced JWT token refresh system with intelligent scheduling
161
+ - **🎯 Smart Scheduling Policy**: Dynamic refresh timing based on token lifetime:
162
+ - >7 days remaining: refresh 5 days before expiry
163
+ - 1-7 days remaining: refresh 12 hours before expiry
164
+ - 1-24 hours remaining: refresh 1 hour before expiry
165
+ - <1 hour remaining: rely on 401-triggered re-login to prevent thrashing
166
+ - **📊 Accurate Lifetime Tracking**: Uses actual token issuance time (iat) for precise calculations
167
+ - **🛡️ Duplicate Prevention**: Guards against multiple timers for same token expiration
168
+ - **🔄 State Management**: Concurrent refresh protection with in-progress tracking
169
+ - **🧹 Clean Shutdown**: Proper timer cleanup on platform shutdown
170
+ - **⚡ Background Operation**: Seamless token refresh without service interruption
171
+
172
+ - **🔧 Advanced Session Management**: Enhanced integration with tsvesync v1.3.0
173
+ - **🔔 Token Change Integration**: Full utilization of tsvesync's onTokenChange callback system
174
+ - **📈 Reliability**: Eliminates VeSync connectivity interruptions from expired tokens
175
+ - **🎯 Optimal Timing**: Intelligent buffer calculation prevents both premature and late refreshes
176
+ - **⏰ Safety Floor**: Never schedules refresh less than 30 minutes from current time
177
+
178
+ ### Enhanced
179
+ - **🔐 Session Persistence**: Improved session management with proactive refresh integration
180
+ - **💾 Complete Session Recovery**: Sessions survive across Homebridge restarts with enhanced refresh
181
+ - **📊 JWT Integration**: Advanced token lifecycle management with expiration tracking
182
+ - **🛡️ Secure Storage**: Protected session storage in tsvesync subdirectory
183
+ - **🚀 Faster Startup**: Reduced authentication overhead via intelligent session reuse
184
+ - **🔄 Seamless Recovery**: Automatic fallback when persisted sessions are invalid
185
+
186
+ ### Changed
187
+ - **📚 Dependency Update**: Updated tsvesync dependency to 1.3.0 for enhanced session management
188
+ - **📝 Documentation**: Comprehensive release notes including all enhancements from 1.2.0 onwards
189
+ - **⚡ Performance**: Optimized token refresh logic for better performance and reliability
190
+
191
+ ### Technical Details
192
+ - **🔧 Advanced Token Lifecycle**: Proactive refresh ensures tokens never expire during operation
193
+ - **🎯 Progressive Buffer Strategy**: Smart refresh timing based on token lifetime for optimal reliability
194
+ - **📈 Enhanced Error Handling**: Comprehensive try/finally blocks for robust operation
195
+ - **🔄 State Coordination**: Prevents concurrent refresh operations with proper synchronization
196
+ - **🛡️ Authentication Stability**: Eliminates authentication interruptions during long-running sessions
197
+
198
+ ### Summary of All Features from v1.2.0 onwards
199
+
200
+ #### Session Management & Authentication (v1.2.0-1.3.0)
201
+ - **💾 Complete Session Persistence**: Sessions survive across Homebridge restarts
202
+ - **⏰ Enhanced Proactive Token Refresh**: Advanced refresh before JWT expiration (NEW in 1.3.0)
203
+ - **🔐 Automatic Recovery**: Seamless fallback when persisted sessions are invalid
204
+ - **📊 JWT Integration**: Full token lifecycle management with expiration tracking
205
+ - **🛡️ Secure Storage**: Protected session storage in tsvesync subdirectory
206
+ - **🚀 Faster Startup**: Reduced authentication overhead via session reuse
207
+
208
+ #### Speed Control & HomeKit Integration (v1.2.0)
209
+ - **🎛️ Advanced Speed Control**: Dynamic support for 3-4+ speed air purifiers
210
+ - **🌙 Sleep Mode Integration**: Sleep mode as first notch on HomeKit slider
211
+ - **🎯 Precision Mapping**: Accurate percentage-to-speed conversions
212
+ - **📱 Enhanced UX**: Improved slider positions and speed transitions
213
+ - **🔄 Smart Notch System**: Automatic adjustment based on device capabilities
214
+
215
+ Full changelog: https://github.com/mickgiles/homebridge-tsvesync/blob/main/CHANGELOG.md
216
+
217
+ ## 1.2.2 (2025-09-04)
218
+
219
+ ### Added
220
+ - **⏰ Proactive Token Refresh**: Intelligent JWT token refresh before expiration
221
+ - **🔄 Smart Scheduling**: Automatically schedules token refresh before JWT expiry
222
+ - **📊 Accurate Lifetime Tracking**: Uses actual token issuance time (iat) for precise calculations
223
+ - **🎯 Dynamic Buffer Calculation**: Refresh buffer is earlier of 5 days or 10% of token lifetime
224
+ - **🔔 Token Change Integration**: Leverages tsvesync's onTokenChange callback system
225
+ - **🧹 Clean Shutdown**: Properly clears refresh timer on platform shutdown
226
+ - **🛡️ Uninterrupted Service**: Prevents authentication failures during long-running sessions
227
+
228
+ ### Changed
229
+ - **📚 Dependency Update**: Updated tsvesync dependency to 1.2.2
230
+ - **📝 Documentation**: Comprehensive release notes including all changes from 1.2.0 onwards
231
+
232
+ ### Technical Details
233
+ - **🔧 Token Lifecycle**: Proactive refresh ensures tokens never expire during operation
234
+ - **📈 Reliability**: Eliminates VeSync connectivity interruptions from expired tokens
235
+ - **🎯 Buffer Strategy**: Minimum 1 day, maximum 5 days refresh buffer for optimal timing
236
+ - **⚡ Background Operation**: Token refresh happens seamlessly without service interruption
237
+
238
+ ### Summary of All Features from v1.2.0 onwards
239
+
240
+ #### Session Management & Authentication (v1.2.0-1.2.2)
241
+ - **💾 Complete Session Persistence**: Sessions survive across Homebridge restarts
242
+ - **⏰ Proactive Token Refresh**: Automatic refresh before JWT expiration (NEW in 1.2.2)
243
+ - **🔐 Automatic Recovery**: Seamless fallback when persisted sessions are invalid
244
+ - **📊 JWT Integration**: Full token lifecycle management with expiration tracking
245
+ - **🛡️ Secure Storage**: Protected session storage in tsvesync subdirectory
246
+ - **🚀 Faster Startup**: Reduced authentication overhead via session reuse
247
+
248
+ #### Speed Control & HomeKit Integration (v1.2.0)
249
+ - **🎛️ Advanced Speed Control**: Dynamic support for 3-4+ speed air purifiers
250
+ - **🌙 Sleep Mode Integration**: Sleep mode as first notch on HomeKit slider
251
+ - **🎯 Precision Mapping**: Accurate percentage-to-speed conversions
252
+ - **📱 Enhanced UX**: Improved slider positions and speed transitions
253
+ - **🔄 Smart Notch System**: Automatic adjustment based on device capabilities
254
+
255
+ Full changelog: https://github.com/mickgiles/homebridge-tsvesync/blob/main/CHANGELOG.md
256
+
257
+ ## 1.2.1 (2025-09-04)
258
+
259
+ ### Changed
260
+ - **📦 Re-release**: Version 1.2.1 re-release with comprehensive release notes from 1.2.0
261
+ - **📝 Documentation**: Enhanced release documentation and changelog formatting
262
+ - **🔄 Version Alignment**: Synchronized version numbers across tsvesync and homebridge-tsvesync
263
+ - **📚 Dependency Update**: Updated tsvesync dependency to 1.2.1
264
+
265
+ ## 1.2.0 (2025-09-04)
266
+
267
+ ### Added
268
+ - **💾 Session Persistence**: Comprehensive session management for improved reliability
269
+ - **🔐 Automatic Session Recovery**: VeSync sessions now persist across Homebridge restarts
270
+ - **📊 Token Lifecycle Management**: JWT token expiration tracking and automatic refresh
271
+ - **🛡️ Secure Storage**: Sessions stored with appropriate file permissions in tsvesync subdirectory
272
+ - **🚀 Faster Startup**: Reduced authentication overhead on Homebridge startup via session reuse
273
+ - **🔄 Seamless Recovery**: Automatic fallback to fresh login when persisted sessions are invalid
274
+
275
+ - **🎛️ Advanced Speed Control**: Enhanced speed control for air purifiers with 4+ manual speeds
276
+ - **🌟 Multi-Speed Support**: Dynamic step calculation for devices with 4+ manual speed levels
277
+ - **🎯 Precision Mapping**: Better percentage-to-speed conversion for devices with varying speed counts
278
+ - **🔄 Smart Notch System**: Automatic adjustment of speed notches based on device capabilities
279
+ - **📱 Improved HomeKit UX**: More accurate slider positions and speed transitions
280
+
281
+ ### Enhanced
282
+ - **🔧 API Integration**: Enhanced tsvesync library integration with session management
283
+ - **📦 Library Update**: Updated to tsvesync 1.2.0 with session persistence capabilities
284
+ - **🔗 Session Callbacks**: Integration with tsvesync session store for automatic persistence
285
+ - **⚡ Performance**: Reduced API calls through intelligent session reuse
286
+ - **🛡️ Reliability**: Better handling of authentication failures with automatic recovery
287
+
288
+ - **🌙 Sleep Mode Control**: Refined sleep mode speed control logic
289
+ - **🎛️ Dynamic Step Calculation**: Speed steps now adjust based on maximum device speeds (20% vs 25%)
290
+ - **🎯 Better Speed Mapping**: More accurate conversion between HomeKit percentages and device speeds
291
+ - **🔄 Consistent Behavior**: Unified speed control logic across all sleep-capable devices
292
+ - **📱 UI Responsiveness**: Improved HomeKit characteristic updates during sleep mode transitions
293
+
294
+ ### Fixed
295
+ - **🔧 Speed Control Accuracy**: Enhanced speed control precision for various device configurations
296
+ - **📊 Speed Calculation**: Fixed percentage calculation for devices with 4+ manual speeds
297
+ - **🎛️ Notch Mapping**: Improved notch-to-speed conversion with proper boundary checking
298
+ - **🔄 State Synchronization**: Better synchronization between device state and HomeKit display
299
+ - **🛡️ Edge Case Handling**: Enhanced handling of speed edge cases and boundary conditions
300
+
301
+ ### Technical Details
302
+ - **🏗️ Session Architecture**: Complete integration with tsvesync 1.2.0 session management system
303
+ - **🔧 FileSessionStore**: Dedicated session storage in ~/.homebridge/tsvesync/session.json
304
+ - **📊 JWT Integration**: Automatic JWT token expiration tracking and session validation
305
+ - **🎛️ Speed Algorithm**: Enhanced speed calculation algorithms for multi-speed device support
306
+ - **🔄 Promise Coordination**: Better coordination with tsvesync library's promise-based login system
307
+
308
+ ### Migration Notes
309
+ - **🚀 Automatic Enhancement**: Session persistence activates automatically after Homebridge restart
310
+ - **📁 New Storage**: Session files stored in new tsvesync subdirectory under Homebridge storage path
311
+ - **🔄 Backward Compatible**: All existing functionality preserved with enhanced capabilities
312
+ - **✅ No Configuration**: No configuration changes required - enhancements work automatically
313
+ - **🔧 Dependency Update**: tsvesync library automatically updated to version 1.2.0
314
+
3
315
  ## 1.1.2 (2025-09-03)
4
316
 
5
317
  ### Enhanced
@@ -24,6 +24,7 @@ export declare class AirPurifierAccessory extends BaseAccessory {
24
24
  * Get the maximum fan speed for the device
25
25
  */
26
26
  private getMaxFanSpeed;
27
+ private isCore200S;
27
28
  /**
28
29
  * Calculate the appropriate step size for discrete speed levels
29
30
  */
@@ -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,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,iBAAiB,EAAE,MAAM,uBAAuB,CAAC;AAkC9E,qBAAa,oBAAqB,SAAQ,aAAa;IACrD,OAAO,CAAC,QAAQ,CAAC,YAAY,CAAqB;IAClD,SAAS,CAAC,QAAQ,CAAC,MAAM,EAAE,iBAAiB,CAAC;IAC7C,OAAO,CAAC,iBAAiB,CAAU;IACnC,OAAO,CAAC,iBAAiB,CAAU;IACnC,OAAO,CAAC,cAAc,CAAU;IAChC,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unknown devices
215
215
  return 3;
216
216
  }
217
+ isCore200S() {
218
+ return (this.device.deviceType || '').toUpperCase().includes('CORE200S');
219
+ }
217
220
  /**
218
221
  * Calculate the appropriate step size for discrete speed levels
219
222
  */
220
223
  calculateRotationSpeedStep() {
221
- // Expose Sleep as the first notch when supported: 0,25,50,75,100
224
+ // Expose Sleep as the first notch when supported.
225
+ // Core 200S uses 3 manual speeds (25% step). 4-speed models use 20% step.
222
226
  if (this.hasFeature('sleep_mode')) {
223
- return 25;
227
+ if (this.isCore200S())
228
+ return 25;
229
+ const max = this.getMaxFanSpeed();
230
+ return max >= 4 ? 20 : 25;
224
231
  }
225
232
  const maxSpeed = this.getMaxFanSpeed();
226
233
  if (maxSpeed === 3)
@@ -233,15 +240,15 @@ class AirPurifierAccessory extends base_accessory_1.BaseAccessory {
233
240
  * Convert device speed to percentage
234
241
  */
235
242
  speedToPercentage(speed) {
236
- // Sleep as first notch: show manual 1→50, 2→75, 3+→100
243
+ // Sleep as first notch: map manual speeds to notches based on model
237
244
  if (this.hasFeature('sleep_mode')) {
238
245
  if (typeof speed !== 'number' || speed <= 0)
239
246
  return 0;
240
- if (speed === 1)
241
- return 50;
242
- if (speed === 2)
243
- return 75;
244
- return 100;
247
+ const step = this.calculateRotationSpeedStep();
248
+ const max = this.isCore200S() ? 3 : this.getMaxFanSpeed();
249
+ // Manual speeds occupy notches 2..(max+1)
250
+ const notch = Math.max(2, Math.min(max + 1, speed + 1));
251
+ return Math.min(100, notch * step);
245
252
  }
246
253
  const maxSpeed = this.getMaxFanSpeed();
247
254
  if (maxSpeed <= 0 || typeof speed !== 'number' || speed <= 0)
@@ -296,16 +303,16 @@ class AirPurifierAccessory extends base_accessory_1.BaseAccessory {
296
303
  * Convert percentage to device speed
297
304
  */
298
305
  percentageToSpeed(percentage) {
299
- // Sleep as first notch: round to nearest 25% and map 50/75/100 → 1/2/3
306
+ // Sleep as first notch: round to nearest step and map notches → speeds
300
307
  if (this.hasFeature('sleep_mode')) {
301
308
  if (typeof percentage !== 'number')
302
309
  return 1;
303
- const notch = Math.max(0, Math.min(4, Math.round(Math.min(100, Math.max(0, percentage)) / 25)));
304
- if (notch <= 2)
305
- return 1; // 50%
306
- if (notch === 3)
307
- return 2; // 75%
308
- return 3; // 100%
310
+ const step = this.calculateRotationSpeedStep();
311
+ const max = this.isCore200S() ? 3 : this.getMaxFanSpeed();
312
+ const maxNotch = max + 1; // include Sleep notch
313
+ const notch = Math.max(0, Math.min(maxNotch, Math.round(Math.min(100, Math.max(0, percentage)) / step)));
314
+ const manualNotch = Math.max(2, notch);
315
+ return Math.min(max, manualNotch - 1);
309
316
  }
310
317
  const maxSpeed = this.getMaxFanSpeed();
311
318
  if (maxSpeed <= 0 || typeof percentage !== 'number')
@@ -511,9 +518,10 @@ class AirPurifierAccessory extends base_accessory_1.BaseAccessory {
511
518
  this.service.updateCharacteristic(this.platform.Characteristic.TargetAirPurifierState, targetState);
512
519
  // Update rotation speed
513
520
  if (isOn && this.hasFeature('sleep_mode') && isSleep) {
514
- this.service.updateCharacteristic(this.platform.Characteristic.RotationSpeed, 25);
521
+ const step = this.calculateRotationSpeedStep();
522
+ this.service.updateCharacteristic(this.platform.Characteristic.RotationSpeed, step);
515
523
  this.lastSetSpeed = 0;
516
- this.lastSetPercentage = 25;
524
+ this.lastSetPercentage = step;
517
525
  }
518
526
  else if (isOn && details.speed !== undefined && details.speed !== null) {
519
527
  // Check if we should skip this update
@@ -595,7 +603,7 @@ class AirPurifierAccessory extends base_accessory_1.BaseAccessory {
595
603
  }
596
604
  // For all other devices, including Core300S, normal mode handling
597
605
  const mode = targetState === 1 ? 'auto' : 'manual';
598
- this.platform.log.debug(`Setting mode to ${mode} for device: ${this.device.deviceName}`);
606
+ this.platform.log.info(`Changing mode to ${mode} for device: ${this.device.deviceName}`);
599
607
  let success = false;
600
608
  // Use the appropriate method to set the mode
601
609
  if (targetState === 1 && typeof extendedDevice.autoMode === 'function') {
@@ -634,7 +642,7 @@ class AirPurifierAccessory extends base_accessory_1.BaseAccessory {
634
642
  // If in sleep mode, surface the first notch
635
643
  const extended = this.device;
636
644
  if (this.hasFeature('sleep_mode') && (extended.mode || '').toLowerCase() === 'sleep') {
637
- return 25;
645
+ return this.calculateRotationSpeedStep();
638
646
  }
639
647
  return 0;
640
648
  }
@@ -695,10 +703,13 @@ class AirPurifierAccessory extends base_accessory_1.BaseAccessory {
695
703
  }
696
704
  // When using sleep-as-first-notch, map slider notches robustly by rounding
697
705
  if (this.hasFeature('sleep_mode')) {
698
- const notch = Math.max(0, Math.min(4, Math.round(percentage / 25)));
706
+ const max = this.isCore200S() ? 3 : this.getMaxFanSpeed();
707
+ const step = this.calculateRotationSpeedStep();
708
+ const maxNotch = max + 1; // include Sleep notch
709
+ const notch = Math.max(0, Math.min(maxNotch, Math.round(percentage / step)));
699
710
  if (notch <= 1) {
700
711
  // Sleep
701
- this.platform.log.debug(`Setting sleep mode via slider on ${this.device.deviceName} (notch=${notch})`);
712
+ this.platform.log.info(`Changing mode to sleep for device: ${this.device.deviceName}`);
702
713
  let ok = false;
703
714
  if (typeof extendedDevice.sleepMode === 'function') {
704
715
  ok = await extendedDevice.sleepMode();
@@ -710,20 +721,21 @@ class AirPurifierAccessory extends base_accessory_1.BaseAccessory {
710
721
  throw new Error('Failed to set sleep mode');
711
722
  }
712
723
  // Immediate UI feedback
713
- this.service.updateCharacteristic(this.platform.Characteristic.RotationSpeed, 25);
724
+ this.service.updateCharacteristic(this.platform.Characteristic.RotationSpeed, step);
714
725
  this.service.updateCharacteristic(this.platform.Characteristic.Active, 1);
715
726
  this.service.updateCharacteristic(this.platform.Characteristic.CurrentAirPurifierState, 2);
716
727
  this.lastSetSpeed = 0;
717
- this.lastSetPercentage = 25;
728
+ this.lastSetPercentage = step;
718
729
  this.skipNextUpdate = true;
719
730
  return;
720
731
  }
721
732
  else {
722
- // Map notches 2/3/4 to speeds 1/2/3
723
- const desiredSpeed = Math.min(3, notch - 1);
733
+ // Map manual notches (2..maxNotch) to speeds 1..max
734
+ const desiredSpeed = Math.min(max, notch - 1);
724
735
  // Ensure manual mode before speed change if necessary
725
736
  const modeNow = (extendedDevice.mode || '').toLowerCase();
726
737
  if (modeNow === 'auto' || modeNow === 'sleep') {
738
+ this.platform.log.info(`Changing mode to manual for device: ${this.device.deviceName}`);
727
739
  if (typeof extendedDevice.manualMode === 'function') {
728
740
  await extendedDevice.manualMode();
729
741
  }
@@ -732,7 +744,7 @@ class AirPurifierAccessory extends base_accessory_1.BaseAccessory {
732
744
  }
733
745
  }
734
746
  // Update UI early
735
- const uiPct = desiredSpeed === 1 ? 50 : desiredSpeed === 2 ? 75 : 100;
747
+ const uiPct = Math.min(100, (desiredSpeed + 1) * step);
736
748
  this.service.updateCharacteristic(this.platform.Characteristic.RotationSpeed, uiPct);
737
749
  this.lastSetSpeed = desiredSpeed;
738
750
  this.lastSetPercentage = uiPct;