homebridge-plugin-klares4 1.1.7-beta1

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 (65) hide show
  1. package/CHANGELOG.md +238 -0
  2. package/LICENSE +21 -0
  3. package/README.md +495 -0
  4. package/config.schema.json +801 -0
  5. package/dist/accessories/cover-accessory.d.ts +26 -0
  6. package/dist/accessories/cover-accessory.d.ts.map +1 -0
  7. package/dist/accessories/cover-accessory.js +134 -0
  8. package/dist/accessories/cover-accessory.js.map +1 -0
  9. package/dist/accessories/gate-accessory.d.ts +20 -0
  10. package/dist/accessories/gate-accessory.d.ts.map +1 -0
  11. package/dist/accessories/gate-accessory.js +70 -0
  12. package/dist/accessories/gate-accessory.js.map +1 -0
  13. package/dist/accessories/light-accessory.d.ts +20 -0
  14. package/dist/accessories/light-accessory.d.ts.map +1 -0
  15. package/dist/accessories/light-accessory.js +81 -0
  16. package/dist/accessories/light-accessory.js.map +1 -0
  17. package/dist/accessories/scenario-accessory.d.ts +17 -0
  18. package/dist/accessories/scenario-accessory.d.ts.map +1 -0
  19. package/dist/accessories/scenario-accessory.js +59 -0
  20. package/dist/accessories/scenario-accessory.js.map +1 -0
  21. package/dist/accessories/sensor-accessory.d.ts +28 -0
  22. package/dist/accessories/sensor-accessory.d.ts.map +1 -0
  23. package/dist/accessories/sensor-accessory.js +141 -0
  24. package/dist/accessories/sensor-accessory.js.map +1 -0
  25. package/dist/accessories/thermostat-accessory.d.ts +25 -0
  26. package/dist/accessories/thermostat-accessory.d.ts.map +1 -0
  27. package/dist/accessories/thermostat-accessory.js +228 -0
  28. package/dist/accessories/thermostat-accessory.js.map +1 -0
  29. package/dist/accessories/zone-accessory.d.ts +22 -0
  30. package/dist/accessories/zone-accessory.d.ts.map +1 -0
  31. package/dist/accessories/zone-accessory.js +99 -0
  32. package/dist/accessories/zone-accessory.js.map +1 -0
  33. package/dist/debug-capture.d.ts +45 -0
  34. package/dist/debug-capture.d.ts.map +1 -0
  35. package/dist/debug-capture.js +294 -0
  36. package/dist/debug-capture.js.map +1 -0
  37. package/dist/index.d.ts +4 -0
  38. package/dist/index.d.ts.map +1 -0
  39. package/dist/index.js +7 -0
  40. package/dist/index.js.map +1 -0
  41. package/dist/log-levels.d.ts +28 -0
  42. package/dist/log-levels.d.ts.map +1 -0
  43. package/dist/log-levels.js +48 -0
  44. package/dist/log-levels.js.map +1 -0
  45. package/dist/mqtt-bridge.d.ts +33 -0
  46. package/dist/mqtt-bridge.d.ts.map +1 -0
  47. package/dist/mqtt-bridge.js +397 -0
  48. package/dist/mqtt-bridge.js.map +1 -0
  49. package/dist/platform.d.ts +90 -0
  50. package/dist/platform.d.ts.map +1 -0
  51. package/dist/platform.js +517 -0
  52. package/dist/platform.js.map +1 -0
  53. package/dist/settings.d.ts +3 -0
  54. package/dist/settings.d.ts.map +1 -0
  55. package/dist/settings.js +6 -0
  56. package/dist/settings.js.map +1 -0
  57. package/dist/types.d.ts +284 -0
  58. package/dist/types.d.ts.map +1 -0
  59. package/dist/types.js +81 -0
  60. package/dist/types.js.map +1 -0
  61. package/dist/websocket-client.d.ts +69 -0
  62. package/dist/websocket-client.d.ts.map +1 -0
  63. package/dist/websocket-client.js +1068 -0
  64. package/dist/websocket-client.js.map +1 -0
  65. package/package.json +63 -0
package/CHANGELOG.md ADDED
@@ -0,0 +1,238 @@
1
+ # Changelog
2
+
3
+ All notable changes to this project will be documented in this file.
4
+
5
+ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
6
+ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
7
+
8
+ ## [Unreleased]
9
+
10
+ ## [1.1.6-beta.4] - 2026-01-11
11
+
12
+ ### Added
13
+
14
+ - **Comprehensive Debug Capture System**: New 60-second diagnostic tool
15
+ - Captures ALL raw WebSocket messages (incoming and outgoing)
16
+ - Multiple device snapshots every 10 seconds during capture
17
+ - Complete message analysis by type and command
18
+ - Automatic PIN masking for security
19
+ - Clear on-screen instructions for users to test non-working entities
20
+ - Generates complete JSON file with everything needed for support
21
+ - File location printed in logs: `~/.homebridge/klares4-debug-*.json`
22
+
23
+ ### Improved
24
+
25
+ - **Enhanced Config UI**: Better debug section with step-by-step instructions
26
+ - Added helpful alerts explaining what to do during capture
27
+ - Clear file location display in UI
28
+ - Simplified user experience for generating debug files
29
+
30
+ ## [1.1.6] - 2026-01-01
31
+
32
+ ### Added
33
+
34
+ - **Verbosity System**: New `logLevel` configuration option with 3 levels
35
+ - `0` (Minimal): Only errors and zone alarms - reduces log noise by ~95%
36
+ - `1` (Normal): Standard operation logs, startup summary, commands (default)
37
+ - `2` (Debug): Full verbose logging for troubleshooting
38
+
39
+ ### Security
40
+
41
+ - **PIN Masking**: PIN codes are now masked in all log messages (`"PIN":"***"`)
42
+ - Raw JSON containing sensitive data no longer logged
43
+
44
+ ### Improved
45
+
46
+ - **Exponential Backoff Reconnection**: WebSocket reconnection now uses exponential backoff with jitter
47
+
48
+ - Initial delay doubles with each attempt (5s -> 10s -> 20s -> 40s -> max 60s)
49
+ - +/-10% jitter prevents "thundering herd" when multiple clients reconnect
50
+ - Reduces log spam and CPU usage during network outages by ~80%
51
+ - Attempt counter resets on successful connection
52
+
53
+ - **Heartbeat PONG Timeout**: Added dead connection detection
54
+
55
+ - System now verifies PONG response to heartbeat PING
56
+ - If no PONG received within 2x heartbeat interval, forces reconnection
57
+ - Detects "zombie" TCP connections (half-open sockets)
58
+ - Reduces HomeKit "Accessory Not Responding" false positives
59
+
60
+ - **Cover Movement Simulation**: Fixed concurrent interval issue
61
+ - Previous movement simulation is now cancelled when new command arrives
62
+ - Prevents erratic position updates when user sends rapid commands
63
+ - Eliminates potential memory leak from orphaned intervals
64
+
65
+ ### Changed
66
+
67
+ - Sensor value updates now log only at DEBUG level (major noise reduction)
68
+ - Zone IDLE events log at NORMAL+ level, but ALARM events always visible
69
+ - System temperature updates log only at DEBUG level
70
+ - Backward compatible: `debug: true` still works (equals `logLevel: 2`)
71
+
72
+ ### Technical
73
+
74
+ - Added `reconnectAttempts` counter and `maxReconnectDelay` configuration
75
+ - Added `heartbeatPending` and `lastPongReceived` tracking for PONG timeout
76
+ - Added `forceReconnect()` method for clean reconnection on timeout
77
+ - Added `moveInterval` property to `CoverAccessory` for proper cleanup
78
+
79
+ ## [1.1.5] - 2025-12-28
80
+
81
+ ### Added
82
+
83
+ - **MQTT Bridge**: Full MQTT integration for publishing states and receiving commands
84
+ - Room mapping for MQTT topics
85
+ - Bilingual documentation (English/Italian)
86
+
87
+ ## [1.1.1-beta.6] - 2025-12-28
88
+
89
+ ### Changed
90
+
91
+ - **Strict TypeScript Refactoring**: Complete codebase rewrite for strict type compliance
92
+ - Replaced all `any` types with proper interfaces and discriminated unions
93
+ - Added explicit return types to all functions and methods
94
+ - Implemented type guards for MQTT command validation
95
+ - Improved error handling: clean messages without stack traces in production logs
96
+ - Removed all emojis from source code, comments, and log messages
97
+
98
+ ### Technical
99
+
100
+ - New discriminated union types for device status (`KseniaLight`, `KseniaCover`, etc.)
101
+ - `AccessoryHandler` union type for typed accessory management
102
+ - Raw API response interfaces (`KseniaOutputStatusRaw`, `KseniaSensorStatusRaw`, etc.)
103
+ - Type guard functions (`isMqttLightCommand`, `isMqttCoverCommand`, etc.)
104
+ - Removed duplicate `MqttConfig` definition
105
+
106
+ ### Documentation
107
+
108
+ - Bilingual README (English/Italian)
109
+ - Removed all emojis from documentation files
110
+ - Updated code style to match strict TypeScript standards
111
+
112
+ ## [1.1.1-beta.5] - 2025-09-18
113
+
114
+ ### Fixed
115
+
116
+ - **MQTT Bridge**: Corrected light state publishing - fixed `light.on` to `light.status?.on` mapping
117
+ - Light states now correctly reflect actual on/off status in MQTT messages
118
+ - Resolved issue where lights always appeared as "off" in MQTT broker
119
+
120
+ ### Added
121
+
122
+ - Dynamic device list generation for room mapping configuration
123
+ - Auto-generated `klares4-room-mapping-example.json` file with real device data
124
+ - Enhanced user interface for room mapping with actual device names and IDs
125
+ - Improved logging with full device IDs for easier configuration
126
+
127
+ ### Changed
128
+
129
+ - Removed hardcoded device examples from config schema
130
+ - Enhanced device discovery summary with full device IDs
131
+ - Improved help documentation in Homebridge UI for room mapping
132
+
133
+ ### Fixed
134
+
135
+ - Room mapping configuration now uses actual devices from user's Lares4 system
136
+
137
+ ## [1.1.1-beta.1] - 2025-09-16
138
+
139
+ ### Added
140
+
141
+ - **Room Mapping for MQTT**: New feature to organize devices by room in MQTT topics
142
+ - Room-based MQTT topic structure: `homebridge/{room}/{type}/{id}/state`
143
+ - Configurable room mapping through Homebridge UI
144
+ - Backward compatibility for existing MQTT topic format
145
+ - Support for both old and new command topic formats
146
+
147
+ ### Changed
148
+
149
+ - MQTT topic structure can now include room names when room mapping is enabled
150
+ - Enhanced config schema with new "Room Mapping MQTT" section
151
+ - Improved MQTT bridge to support dynamic room assignment
152
+
153
+ ### Technical
154
+
155
+ - Added `getRoomForDevice()` function to MQTT bridge
156
+ - Enhanced TypeScript types for room mapping configuration
157
+ - Updated subscription logic to handle multiple topic formats
158
+ - Maintained full backward compatibility
159
+
160
+ ## [1.1.1-beta.0] - 2025-09-16
161
+
162
+ ### Added
163
+
164
+ - Initial MQTT bridge functionality
165
+ - Device state publishing to MQTT topics
166
+ - MQTT command reception for device control
167
+ - Comprehensive device discovery and caching
168
+
169
+ ### Changed
170
+
171
+ - Enhanced plugin architecture for better extensibility
172
+ - Improved device management and exclusion system
173
+
174
+ ### Fixed
175
+
176
+ - Various stability improvements
177
+ - Enhanced error handling
178
+
179
+ ## [1.1.0] - 2025-09-10
180
+
181
+ ### Added
182
+
183
+ - Complete plugin rewrite for Ksenia Lares4 systems
184
+ - Support for multiple device types:
185
+ - Security zones (contact sensors)
186
+ - Lights with on/off control
187
+ - Window coverings with position control
188
+ - Thermostats with temperature and mode control
189
+ - Environmental sensors (temperature, humidity, light)
190
+ - Scenario automation triggers
191
+ - Real-time WebSocket communication with Lares4 system
192
+ - Configurable device exclusion system
193
+ - Custom device naming support
194
+ - Comprehensive Homebridge UI configuration interface
195
+
196
+ ### Technical
197
+
198
+ - Modern TypeScript implementation
199
+ - Robust WebSocket client with auto-reconnection
200
+ - Modular accessory architecture
201
+ - Comprehensive logging and debugging support
202
+ - Device state caching and persistence
203
+
204
+ ---
205
+
206
+ ## Version History Summary
207
+
208
+ - **1.1.1-beta.x**: MQTT integration and room mapping features
209
+ - **1.1.0**: Complete plugin rewrite with full Lares4 integration
210
+ - **1.0.x**: Legacy versions (deprecated)
211
+
212
+ ## Migration Guide
213
+
214
+ ### From 1.1.1-beta.5 to 1.1.1-beta.6
215
+
216
+ - No configuration changes required
217
+ - Codebase refactored for strict TypeScript compliance
218
+ - All functionality remains the same
219
+
220
+ ### From 1.1.1-beta.0 to 1.1.1-beta.1+
221
+
222
+ - Room mapping is optional and disabled by default
223
+ - Existing MQTT configurations continue to work unchanged
224
+ - To use room mapping, enable it in the new "Room Mapping MQTT" section
225
+
226
+ ### From 1.0.x to 1.1.0+
227
+
228
+ - Complete reconfiguration required
229
+ - New device discovery process
230
+ - Enhanced configuration options through Homebridge UI
231
+ - Improved stability and performance
232
+
233
+ ## Support
234
+
235
+ For issues, feature requests, or questions:
236
+
237
+ - GitHub Issues: https://github.com/paolo-trivi/homebridge-plugin-klares4/issues
238
+ - Documentation: Check README.md for detailed setup instructions
package/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2025 Paolo Trivi
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.