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/README.md ADDED
@@ -0,0 +1,495 @@
1
+ # homebridge-plugin-klares4
2
+
3
+ [![npm version](https://badge.fury.io/js/homebridge-plugin-klares4.svg)](https://badge.fury.io/js/homebridge-plugin-klares4)
4
+ [![verified-by-homebridge](https://badgen.net/badge/homebridge/verified/purple)](https://github.com/homebridge/homebridge/wiki/Verified-Plugins)
5
+ [![License: MIT](https://img.shields.io/badge/License-MIT-yellow.svg)](https://opensource.org/licenses/MIT)
6
+
7
+ Complete plugin for Ksenia Lares4 systems integrating security zones, lights, covers, thermostats, and environmental sensors into a single Homebridge solution.
8
+
9
+ ---
10
+
11
+ ## English Documentation
12
+
13
+ ### Features
14
+
15
+ - **Security Zones**: Contact sensors for doors and windows
16
+ - **Light Control**: On/off control for all system lights
17
+ - **Smart Covers**: Percentage control with configurable timing
18
+ - **Thermostats**: Temperature and heating/cooling mode control
19
+ - **Environmental Sensors**: Real-time temperature, humidity, and light levels
20
+ - **Real-time Updates**: WebSocket connection with automatic reconnection
21
+ - **UI Configuration**: Complete graphical interface in Homebridge UI
22
+ - **Customization**: Custom names and selective entity exclusion
23
+ - **MQTT Bridge**: State publishing and command reception via MQTT (optional)
24
+
25
+ ### Prerequisites
26
+
27
+ - Homebridge >= 1.6.0
28
+ - Node.js >= 14.18.1
29
+ - Ksenia Lares4 system with WebSocket access enabled
30
+
31
+ ### Installation
32
+
33
+ #### Via Homebridge UI (Recommended)
34
+
35
+ 1. Open Homebridge UI
36
+ 2. Go to **Plugins**
37
+ 3. Search for `homebridge-plugin-klares4`
38
+ 4. Click **Install**
39
+ 5. Configure the plugin via the graphical interface
40
+
41
+ #### Via npm
42
+
43
+ ```bash
44
+ npm install -g homebridge-plugin-klares4
45
+ ```
46
+
47
+ ### Configuration
48
+
49
+ #### Basic Configuration
50
+
51
+ The plugin can be fully configured via the Homebridge UI graphical interface. Required parameters:
52
+
53
+ - **Plugin Name**: Name that will appear in logs
54
+ - **IP Address**: IP of the Ksenia Lares4 system
55
+ - **Sender ID**: Unique identifier for WebSocket connection
56
+ - **System PIN**: Access PIN for the Lares4 system
57
+
58
+ #### Manual Configuration (config.json)
59
+
60
+ ```json
61
+ {
62
+ "platforms": [
63
+ {
64
+ "platform": "Lares4Complete",
65
+ "name": "Klares4",
66
+ "ip": "192.168.1.100",
67
+ "sender": "homebridge",
68
+ "pin": "123456",
69
+ "maxSeconds": 30,
70
+ "reconnectInterval": 5000,
71
+ "heartbeatInterval": 30000,
72
+ "debug": false,
73
+ "excludeZones": ["1", "5"],
74
+ "excludeOutputs": ["2", "7"],
75
+ "excludeSensors": ["3"],
76
+ "customNames": {
77
+ "zones": {
78
+ "1": "Main Door",
79
+ "2": "Kitchen Window"
80
+ },
81
+ "outputs": {
82
+ "9": "Living Room Light",
83
+ "1": "Office Blind"
84
+ },
85
+ "sensors": {
86
+ "1": "Living Room Thermometer"
87
+ }
88
+ }
89
+ }
90
+ ]
91
+ }
92
+ ```
93
+
94
+ #### Configuration Parameters
95
+
96
+ | Parameter | Type | Default | Description |
97
+ | ------------------- | -------- | ------------ | ------------------------------- |
98
+ | `name` | string | "Klares4" | Plugin name |
99
+ | `ip` | string | required | Lares4 system IP address |
100
+ | `sender` | string | "homebridge" | Unique WebSocket ID |
101
+ | `pin` | string | required | Access PIN |
102
+ | `maxSeconds` | number | 30 | Max cover travel time (seconds) |
103
+ | `reconnectInterval` | number | 5000 | Reconnection interval (ms) |
104
+ | `heartbeatInterval` | number | 30000 | Heartbeat interval (ms) |
105
+ | `debug` | boolean | false | Detailed logging |
106
+ | `excludeZones` | string[] | [] | Zones to exclude |
107
+ | `excludeOutputs` | string[] | [] | Outputs to exclude |
108
+ | `excludeSensors` | string[] | [] | Sensors to exclude |
109
+ | `customNames` | object | {} | Custom names |
110
+
111
+ ### Supported Accessory Types
112
+
113
+ #### Security Zones
114
+
115
+ - **HomeKit Type**: Contact Sensor
116
+ - **States**: Open/Closed, Bypass
117
+ - **Updates**: Real-time via WebSocket
118
+
119
+ #### Lights
120
+
121
+ - **HomeKit Type**: Lightbulb
122
+ - **Control**: On/Off
123
+ - **Feedback**: Real-time state
124
+
125
+ #### Covers
126
+
127
+ - **HomeKit Type**: Window Covering
128
+ - **Control**: Percentage (0-100%)
129
+ - **Commands**: Up/Down/Stop
130
+ - **Timing**: Configurable via `maxSeconds`
131
+
132
+ #### Thermostats
133
+
134
+ - **HomeKit Type**: Thermostat
135
+ - **Modes**: Off/Heat/Cool
136
+ - **Control**: Target temperature
137
+ - **Sensors**: Current temperature
138
+
139
+ #### Environmental Sensors
140
+
141
+ - **HomeKit Types**: Temperature/Humidity/Light Sensor
142
+ - **Data**: Temperature, Humidity, Light level
143
+ - **Updates**: Real-time
144
+
145
+ ### MQTT Bridge (Optional)
146
+
147
+ The plugin includes an MQTT bridge for publishing accessory states and receiving commands via MQTT.
148
+
149
+ #### MQTT Configuration
150
+
151
+ Enable the MQTT bridge in the "MQTT Bridge" configuration section:
152
+
153
+ ```json
154
+ {
155
+ "mqtt": {
156
+ "enabled": true,
157
+ "broker": "mqtt://192.168.1.100:1883",
158
+ "username": "mqtt_user",
159
+ "password": "mqtt_password",
160
+ "clientId": "homebridge-klares4",
161
+ "topicPrefix": "homebridge/klares4",
162
+ "qos": 1,
163
+ "retain": true
164
+ }
165
+ }
166
+ ```
167
+
168
+ #### State Publishing
169
+
170
+ Accessory states are published to the following topics:
171
+
172
+ - **Lights**: `homebridge/klares4/light/{id}/state`
173
+ - **Covers**: `homebridge/klares4/cover/{id}/state`
174
+ - **Thermostats**: `homebridge/klares4/thermostat/{id}/state`
175
+ - **Sensors**: `homebridge/klares4/sensor/{id}/state`
176
+ - **Zones**: `homebridge/klares4/zone/{id}/state`
177
+ - **Scenarios**: `homebridge/klares4/scenario/{id}/state`
178
+
179
+ #### Command Reception
180
+
181
+ Send commands to accessories on the following topics:
182
+
183
+ - **Lights**: `homebridge/klares4/light/{id}/set`
184
+ - **Covers**: `homebridge/klares4/cover/{id}/set`
185
+ - **Thermostats**: `homebridge/klares4/thermostat/{id}/set`
186
+ - **Scenarios**: `homebridge/klares4/scenario/{id}/set`
187
+
188
+ #### Usage Examples
189
+
190
+ ##### Turn on a light:
191
+
192
+ ```bash
193
+ mosquitto_pub -h 192.168.1.100 -t "homebridge/klares4/light/1/set" -m '{"on": true, "brightness": 80}'
194
+ ```
195
+
196
+ ##### Move a cover:
197
+
198
+ ```bash
199
+ mosquitto_pub -h 192.168.1.100 -t "homebridge/klares4/cover/2/set" -m '{"position": 50}'
200
+ ```
201
+
202
+ ##### Set thermostat temperature:
203
+
204
+ ```bash
205
+ mosquitto_pub -h 192.168.1.100 -t "homebridge/klares4/thermostat/3/set" -m '{"targetTemperature": 22, "mode": "heat"}'
206
+ ```
207
+
208
+ ##### Trigger a scenario:
209
+
210
+ ```bash
211
+ mosquitto_pub -h 192.168.1.100 -t "homebridge/klares4/scenario/4/set" -m '{"active": true}'
212
+ ```
213
+
214
+ ### Troubleshooting
215
+
216
+ #### WebSocket Connection
217
+
218
+ If the plugin cannot connect:
219
+
220
+ 1. Verify the IP address is correct
221
+ 2. Check that the PIN is valid
222
+ 3. Ensure the Lares4 system accepts WebSocket connections
223
+ 4. Verify port 443 (HTTPS) or 80 (HTTP) is accessible
224
+
225
+ #### Debug
226
+
227
+ Enable debug logging for detailed diagnostics:
228
+
229
+ ```json
230
+ {
231
+ "debug": true
232
+ }
233
+ ```
234
+
235
+ ### License
236
+
237
+ This project is released under the MIT license.
238
+
239
+ ### Useful Links
240
+
241
+ - [Homebridge](https://homebridge.io/)
242
+ - [Homebridge UI](https://github.com/homebridge/homebridge-config-ui-x)
243
+ - [Ksenia Security](https://www.ksenia.it/)
244
+
245
+ ---
246
+
247
+ ## Documentazione Italiana
248
+
249
+ ### Caratteristiche
250
+
251
+ - **Zone di Sicurezza**: Sensori di contatto per porte e finestre
252
+ - **Controllo Luci**: Accensione/spegnimento di tutte le luci del sistema
253
+ - **Tapparelle Intelligenti**: Controllo percentuale con timing configurabile
254
+ - **Termostati**: Controllo temperatura e modalita riscaldamento/raffreddamento
255
+ - **Sensori Ambientali**: Temperatura, umidita e luminosita in tempo reale
256
+ - **Aggiornamenti Real-time**: Connessione WebSocket con riconnessione automatica
257
+ - **Configurazione UI**: Interfaccia grafica completa in Homebridge UI
258
+ - **Personalizzazione**: Nomi personalizzati ed esclusione selettiva di entita
259
+ - **Bridge MQTT**: Pubblicazione stati e ricezione comandi via MQTT (opzionale)
260
+
261
+ ### Prerequisiti
262
+
263
+ - Homebridge >= 1.6.0
264
+ - Node.js >= 14.18.1
265
+ - Sistema Ksenia Lares4 con accesso WebSocket abilitato
266
+
267
+ ### Installazione
268
+
269
+ #### Tramite Homebridge UI (Consigliato)
270
+
271
+ 1. Apri Homebridge UI
272
+ 2. Vai su **Plugins**
273
+ 3. Cerca `homebridge-plugin-klares4`
274
+ 4. Clicca **Install**
275
+ 5. Configura il plugin tramite l'interfaccia grafica
276
+
277
+ #### Tramite npm
278
+
279
+ ```bash
280
+ npm install -g homebridge-plugin-klares4
281
+ ```
282
+
283
+ ### Configurazione
284
+
285
+ #### Configurazione Base
286
+
287
+ Il plugin puo essere configurato completamente tramite l'interfaccia grafica di Homebridge UI. I parametri obbligatori sono:
288
+
289
+ - **Nome Plugin**: Nome che apparira nei log
290
+ - **Indirizzo IP**: IP del sistema Ksenia Lares4
291
+ - **Sender ID**: Identificativo univoco per la connessione WebSocket
292
+ - **PIN Sistema**: PIN di accesso al sistema Lares4
293
+
294
+ #### Configurazione Manuale (config.json)
295
+
296
+ ```json
297
+ {
298
+ "platforms": [
299
+ {
300
+ "platform": "Lares4Complete",
301
+ "name": "Klares4",
302
+ "ip": "192.168.1.100",
303
+ "sender": "homebridge",
304
+ "pin": "123456",
305
+ "maxSeconds": 30,
306
+ "reconnectInterval": 5000,
307
+ "heartbeatInterval": 30000,
308
+ "debug": false,
309
+ "excludeZones": ["1", "5"],
310
+ "excludeOutputs": ["2", "7"],
311
+ "excludeSensors": ["3"],
312
+ "customNames": {
313
+ "zones": {
314
+ "1": "Porta Principale",
315
+ "2": "Finestra Cucina"
316
+ },
317
+ "outputs": {
318
+ "9": "Luce Sala Custom",
319
+ "1": "Tapparella Studio"
320
+ },
321
+ "sensors": {
322
+ "1": "Termometro Sala"
323
+ }
324
+ }
325
+ }
326
+ ]
327
+ }
328
+ ```
329
+
330
+ #### Parametri di Configurazione
331
+
332
+ | Parametro | Tipo | Default | Descrizione |
333
+ | ------------------- | -------- | ------------ | ------------------------------- |
334
+ | `name` | string | "Klares4" | Nome del plugin |
335
+ | `ip` | string | obbligatorio | Indirizzo IP del sistema Lares4 |
336
+ | `sender` | string | "homebridge" | ID univoco per WebSocket |
337
+ | `pin` | string | obbligatorio | PIN di accesso |
338
+ | `maxSeconds` | number | 30 | Tempo max tapparelle (secondi) |
339
+ | `reconnectInterval` | number | 5000 | Intervallo riconnessione (ms) |
340
+ | `heartbeatInterval` | number | 30000 | Intervallo heartbeat (ms) |
341
+ | `debug` | boolean | false | Logging dettagliato |
342
+ | `excludeZones` | string[] | [] | Zone da escludere |
343
+ | `excludeOutputs` | string[] | [] | Output da escludere |
344
+ | `excludeSensors` | string[] | [] | Sensori da escludere |
345
+ | `customNames` | object | {} | Nomi personalizzati |
346
+
347
+ ### Tipi di Accessori Supportati
348
+
349
+ #### Zone di Sicurezza
350
+
351
+ - **Tipo HomeKit**: Contact Sensor
352
+ - **Stati**: Aperto/Chiuso, Bypass
353
+ - **Aggiornamenti**: Real-time via WebSocket
354
+
355
+ #### Luci
356
+
357
+ - **Tipo HomeKit**: Lightbulb
358
+ - **Controllo**: On/Off
359
+ - **Feedback**: Stato real-time
360
+
361
+ #### Tapparelle
362
+
363
+ - **Tipo HomeKit**: Window Covering
364
+ - **Controllo**: Percentuale (0-100%)
365
+ - **Comandi**: Su/Giu/Stop
366
+ - **Timing**: Configurabile tramite `maxSeconds`
367
+
368
+ #### Termostati
369
+
370
+ - **Tipo HomeKit**: Thermostat
371
+ - **Modalita**: Off/Heat/Cool
372
+ - **Controllo**: Temperatura target
373
+ - **Sensori**: Temperatura corrente
374
+
375
+ #### Sensori Ambientali
376
+
377
+ - **Tipi HomeKit**: Temperature/Humidity/Light Sensor
378
+ - **Dati**: Temperatura, Umidita, Luminosita
379
+ - **Aggiornamenti**: Real-time
380
+
381
+ ### Bridge MQTT (Opzionale)
382
+
383
+ Il plugin include un bridge MQTT che permette di pubblicare gli stati degli accessori e ricevere comandi via MQTT.
384
+
385
+ #### Configurazione MQTT
386
+
387
+ Abilita il bridge MQTT nella sezione "MQTT Bridge" della configurazione:
388
+
389
+ ```json
390
+ {
391
+ "mqtt": {
392
+ "enabled": true,
393
+ "broker": "mqtt://192.168.1.100:1883",
394
+ "username": "mqtt_user",
395
+ "password": "mqtt_password",
396
+ "clientId": "homebridge-klares4",
397
+ "topicPrefix": "homebridge/klares4",
398
+ "qos": 1,
399
+ "retain": true
400
+ }
401
+ }
402
+ ```
403
+
404
+ #### Pubblicazione Stati
405
+
406
+ Gli stati degli accessori vengono pubblicati sui seguenti topic:
407
+
408
+ - **Luci**: `homebridge/klares4/light/{id}/state`
409
+ - **Tapparelle**: `homebridge/klares4/cover/{id}/state`
410
+ - **Termostati**: `homebridge/klares4/thermostat/{id}/state`
411
+ - **Sensori**: `homebridge/klares4/sensor/{id}/state`
412
+ - **Zone**: `homebridge/klares4/zone/{id}/state`
413
+ - **Scenari**: `homebridge/klares4/scenario/{id}/state`
414
+
415
+ #### Ricezione Comandi
416
+
417
+ Invia comandi agli accessori sui seguenti topic:
418
+
419
+ - **Luci**: `homebridge/klares4/light/{id}/set`
420
+ - **Tapparelle**: `homebridge/klares4/cover/{id}/set`
421
+ - **Termostati**: `homebridge/klares4/thermostat/{id}/set`
422
+ - **Scenari**: `homebridge/klares4/scenario/{id}/set`
423
+
424
+ #### Esempi di Utilizzo
425
+
426
+ ##### Accendere una luce:
427
+
428
+ ```bash
429
+ mosquitto_pub -h 192.168.1.100 -t "homebridge/klares4/light/1/set" -m '{"on": true, "brightness": 80}'
430
+ ```
431
+
432
+ ##### Muovere una tapparella:
433
+
434
+ ```bash
435
+ mosquitto_pub -h 192.168.1.100 -t "homebridge/klares4/cover/2/set" -m '{"position": 50}'
436
+ ```
437
+
438
+ ##### Impostare temperatura termostato:
439
+
440
+ ```bash
441
+ mosquitto_pub -h 192.168.1.100 -t "homebridge/klares4/thermostat/3/set" -m '{"targetTemperature": 22, "mode": "heat"}'
442
+ ```
443
+
444
+ ##### Attivare uno scenario:
445
+
446
+ ```bash
447
+ mosquitto_pub -h 192.168.1.100 -t "homebridge/klares4/scenario/4/set" -m '{"active": true}'
448
+ ```
449
+
450
+ ### Risoluzione Problemi
451
+
452
+ #### Connessione WebSocket
453
+
454
+ Se il plugin non riesce a connettersi:
455
+
456
+ 1. Verifica che l'IP sia corretto
457
+ 2. Controlla che il PIN sia valido
458
+ 3. Assicurati che il sistema Lares4 accetti connessioni WebSocket
459
+ 4. Verifica che la porta 443 (HTTPS) o 80 (HTTP) sia accessibile
460
+
461
+ #### Debug
462
+
463
+ Abilita il debug logging per diagnosi dettagliate:
464
+
465
+ ```json
466
+ {
467
+ "debug": true
468
+ }
469
+ ```
470
+
471
+ ### Contributi
472
+
473
+ I contributi sono benvenuti! Per contribuire:
474
+
475
+ 1. Fork del repository
476
+ 2. Crea un branch per la tua feature
477
+ 3. Commit delle modifiche
478
+ 4. Push al branch
479
+ 5. Apri una Pull Request
480
+
481
+ ### Licenza
482
+
483
+ Questo progetto e rilasciato sotto licenza MIT.
484
+
485
+ ### Link Utili
486
+
487
+ - [Homebridge](https://homebridge.io/)
488
+ - [Homebridge UI](https://github.com/homebridge/homebridge-config-ui-x)
489
+ - [Ksenia Security](https://www.ksenia.it/)
490
+
491
+ ---
492
+
493
+ **Note**: This project is not affiliated with Ksenia Security S.p.A. It is an open source project developed by the community.
494
+
495
+ **Nota**: Questo progetto non e affiliato con Ksenia Security S.p.A. E un progetto open source sviluppato dalla comunita.