homebridge-plugin-klares4 1.1.0

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 (48) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +203 -0
  3. package/config.schema.json +206 -0
  4. package/dist/accessories/cover-accessory.d.ts +21 -0
  5. package/dist/accessories/cover-accessory.d.ts.map +1 -0
  6. package/dist/accessories/cover-accessory.js +128 -0
  7. package/dist/accessories/cover-accessory.js.map +1 -0
  8. package/dist/accessories/light-accessory.d.ts +16 -0
  9. package/dist/accessories/light-accessory.d.ts.map +1 -0
  10. package/dist/accessories/light-accessory.js +78 -0
  11. package/dist/accessories/light-accessory.js.map +1 -0
  12. package/dist/accessories/scenario-accessory.d.ts +13 -0
  13. package/dist/accessories/scenario-accessory.d.ts.map +1 -0
  14. package/dist/accessories/scenario-accessory.js +55 -0
  15. package/dist/accessories/scenario-accessory.js.map +1 -0
  16. package/dist/accessories/sensor-accessory.d.ts +24 -0
  17. package/dist/accessories/sensor-accessory.d.ts.map +1 -0
  18. package/dist/accessories/sensor-accessory.js +128 -0
  19. package/dist/accessories/sensor-accessory.js.map +1 -0
  20. package/dist/accessories/thermostat-accessory.d.ts +21 -0
  21. package/dist/accessories/thermostat-accessory.d.ts.map +1 -0
  22. package/dist/accessories/thermostat-accessory.js +215 -0
  23. package/dist/accessories/thermostat-accessory.js.map +1 -0
  24. package/dist/accessories/zone-accessory.d.ts +18 -0
  25. package/dist/accessories/zone-accessory.d.ts.map +1 -0
  26. package/dist/accessories/zone-accessory.js +99 -0
  27. package/dist/accessories/zone-accessory.js.map +1 -0
  28. package/dist/index.d.ts +4 -0
  29. package/dist/index.d.ts.map +1 -0
  30. package/dist/index.js +7 -0
  31. package/dist/index.js.map +1 -0
  32. package/dist/platform.d.ts +69 -0
  33. package/dist/platform.d.ts.map +1 -0
  34. package/dist/platform.js +345 -0
  35. package/dist/platform.js.map +1 -0
  36. package/dist/settings.d.ts +3 -0
  37. package/dist/settings.d.ts.map +1 -0
  38. package/dist/settings.js +6 -0
  39. package/dist/settings.js.map +1 -0
  40. package/dist/types.d.ts +82 -0
  41. package/dist/types.d.ts.map +1 -0
  42. package/dist/types.js +3 -0
  43. package/dist/types.js.map +1 -0
  44. package/dist/websocket-client.d.ts +57 -0
  45. package/dist/websocket-client.d.ts.map +1 -0
  46. package/dist/websocket-client.js +991 -0
  47. package/dist/websocket-client.js.map +1 -0
  48. package/package.json +64 -0
@@ -0,0 +1,78 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.LightAccessory = void 0;
4
+ class LightAccessory {
5
+ constructor(platform, accessory) {
6
+ this.platform = platform;
7
+ this.accessory = accessory;
8
+ this.device = accessory.context.device;
9
+ // Imposta le informazioni dell'accessorio
10
+ this.accessory.getService(this.platform.Service.AccessoryInformation)
11
+ .setCharacteristic(this.platform.Characteristic.Manufacturer, 'Ksenia')
12
+ .setCharacteristic(this.platform.Characteristic.Model, 'Lares4 Light')
13
+ .setCharacteristic(this.platform.Characteristic.SerialNumber, this.device.id)
14
+ .setCharacteristic(this.platform.Characteristic.FirmwareRevision, '2.0.0');
15
+ // Ottieni o crea il servizio Lightbulb
16
+ this.service = this.accessory.getService(this.platform.Service.Lightbulb)
17
+ || this.accessory.addService(this.platform.Service.Lightbulb);
18
+ this.service.setCharacteristic(this.platform.Characteristic.Name, this.device.name);
19
+ // Imposta gli handlers per le caratteristiche
20
+ this.service.getCharacteristic(this.platform.Characteristic.On)
21
+ .onSet(this.setOn.bind(this))
22
+ .onGet(this.getOn.bind(this));
23
+ // Se la luce è dimmerabile, aggiungi la caratteristica Brightness
24
+ if (this.device.status?.dimmable) {
25
+ this.service.getCharacteristic(this.platform.Characteristic.Brightness)
26
+ .onSet(this.setBrightness.bind(this))
27
+ .onGet(this.getBrightness.bind(this));
28
+ }
29
+ }
30
+ async setOn(value) {
31
+ const on = value;
32
+ try {
33
+ await this.platform.wsClient?.switchLight(this.device.id, on);
34
+ this.device.status.on = on;
35
+ this.platform.log.info(`💡 ${this.device.name}: ${on ? 'Accesa' : 'Spenta'}`);
36
+ }
37
+ catch (error) {
38
+ this.platform.log.error(`❌ Errore controllo luce ${this.device.name}:`, error);
39
+ throw new this.platform.api.hap.HapStatusError(-70402 /* this.platform.api.hap.HAPStatus.SERVICE_COMMUNICATION_FAILURE */);
40
+ }
41
+ }
42
+ async getOn() {
43
+ return this.device.status?.on || false;
44
+ }
45
+ async setBrightness(value) {
46
+ const brightness = value;
47
+ if (!this.device.status?.dimmable) {
48
+ return;
49
+ }
50
+ try {
51
+ await this.platform.wsClient?.dimLight(this.device.id, brightness);
52
+ this.device.status.brightness = brightness;
53
+ this.device.status.on = brightness > 0;
54
+ // Aggiorna anche la caratteristica On
55
+ this.service.updateCharacteristic(this.platform.Characteristic.On, this.device.status.on);
56
+ this.platform.log.info(`💡 ${this.device.name}: Luminosità ${brightness}%`);
57
+ }
58
+ catch (error) {
59
+ this.platform.log.error(`❌ Errore dimmer luce ${this.device.name}:`, error);
60
+ throw new this.platform.api.hap.HapStatusError(-70402 /* this.platform.api.hap.HAPStatus.SERVICE_COMMUNICATION_FAILURE */);
61
+ }
62
+ }
63
+ async getBrightness() {
64
+ return this.device.status?.brightness || (this.device.status?.on ? 100 : 0);
65
+ }
66
+ // Metodo per aggiornare lo stato dall'esterno (aggiornamenti real-time)
67
+ updateStatus(newDevice) {
68
+ this.device = newDevice;
69
+ // Aggiorna le caratteristiche
70
+ this.service.updateCharacteristic(this.platform.Characteristic.On, this.device.status?.on || false);
71
+ if (this.device.status?.dimmable && this.device.status?.brightness !== undefined) {
72
+ this.service.updateCharacteristic(this.platform.Characteristic.Brightness, this.device.status.brightness);
73
+ }
74
+ this.platform.log.debug(`🔄 Aggiornato stato luce ${this.device.name}: ${this.device.status?.on ? 'ON' : 'OFF'}`);
75
+ }
76
+ }
77
+ exports.LightAccessory = LightAccessory;
78
+ //# sourceMappingURL=light-accessory.js.map
@@ -0,0 +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E,EAAE,CAAC,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC;IAChF,CAAC;IAED,wEAAwE;IACxE,YAAY,CAAC,SAAuB;QAChC,IAAI,CAAC,MAAM,GAAG,SAAS,CAAC;QAExB,8BAA8B;QAC9B,IAAI,CAAC,OAAO,CAAC,oBAAoB,CAAC,IAAI,CAAC,QAAQ,CAAC,cAAc,CAAC,EAAE,EAAE,IAAI,CAAC,MAAM,CAAC,MAAM,EAAE,EAAE,IAAI,KAAK,CAAC,CAAC;QAEpG,IAAI,IAAI,CAAC,MAAM,CAAC,MAAM,EAAE,QAAQ,IAAI,IAAI,CAAC,MAAM,CAAC,MAAM,EAAE,UAAU,KAAK,SAAS,EAAE,CAAC;YAC/E,IAAI,CAAC,OAAO,CAAC,oBAAoB,CAAC,IAAI,CAAC,QAAQ,CAAC,cAAc,CAAC,UAAU,EAAE,IAAI,CAAC,MAAM,CAAC,MAAM,CAAC,UAAU,CAAC,CAAC;QAC9G,CAAC;QAED,IAAI,CAAC,QAAQ,CAAC,GAAG,CAAC,KAAK,CAAC,4BAA4B,IAAI,CAAC,MAAM,CAAC,IAAI,KAAK,IAAI,CAAC,MAAM,CAAC,MAAM,EAAE,EAAE,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,KAAK,EAAE,CAAC,CAAC;IACtH,CAAC;CACJ;AA5FD,wCA4FC"}
@@ -0,0 +1,13 @@
1
+ import type { PlatformAccessory, CharacteristicValue } from 'homebridge';
2
+ import { Lares4Platform } from '../platform';
3
+ import { KseniaDevice } from '../types';
4
+ export declare class ScenarioAccessory {
5
+ private readonly platform;
6
+ private readonly accessory;
7
+ private readonly device;
8
+ private service;
9
+ constructor(platform: Lares4Platform, accessory: PlatformAccessory, device: KseniaDevice);
10
+ setOn(value: CharacteristicValue): Promise<void>;
11
+ getOn(): Promise<CharacteristicValue>;
12
+ }
13
+ //# sourceMappingURL=scenario-accessory.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"scenario-accessory.d.ts","sourceRoot":"","sources":["../../src/accessories/scenario-accessory.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAER,iBAAiB,EACjB,mBAAmB,EACtB,MAAM,YAAY,CAAC;AAEpB,OAAO,EAAE,cAAc,EAAE,MAAM,aAAa,CAAC;AAC7C,OAAO,EAAE,YAAY,EAAE,MAAM,UAAU,CAAC;AAExC,qBAAa,iBAAiB;IAItB,OAAO,CAAC,QAAQ,CAAC,QAAQ;IACzB,OAAO,CAAC,QAAQ,CAAC,SAAS;IAC1B,OAAO,CAAC,QAAQ,CAAC,MAAM;IAL3B,OAAO,CAAC,OAAO,CAAU;gBAGJ,QAAQ,EAAE,cAAc,EACxB,SAAS,EAAE,iBAAiB,EAC5B,MAAM,EAAE,YAAY;IAqBnC,KAAK,CAAC,KAAK,EAAE,mBAAmB;IA4BhC,KAAK,IAAI,OAAO,CAAC,mBAAmB,CAAC;CAI9C"}
@@ -0,0 +1,55 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.ScenarioAccessory = void 0;
4
+ class ScenarioAccessory {
5
+ constructor(platform, accessory, device) {
6
+ this.platform = platform;
7
+ this.accessory = accessory;
8
+ this.device = device;
9
+ // Imposta le informazioni dell'accessorio
10
+ this.accessory.getService(this.platform.Service.AccessoryInformation)
11
+ .setCharacteristic(this.platform.Characteristic.Manufacturer, 'Ksenia')
12
+ .setCharacteristic(this.platform.Characteristic.Model, 'Lares4 Scenario')
13
+ .setCharacteristic(this.platform.Characteristic.SerialNumber, device.id);
14
+ // Ottieni il servizio Switch o crealo se non esiste
15
+ this.service = this.accessory.getService(this.platform.Service.Switch) ||
16
+ this.accessory.addService(this.platform.Service.Switch);
17
+ // Imposta il nome del servizio
18
+ this.service.setCharacteristic(this.platform.Characteristic.Name, device.name);
19
+ // Registra gli handler per le caratteristiche
20
+ this.service.getCharacteristic(this.platform.Characteristic.On)
21
+ .onSet(this.setOn.bind(this))
22
+ .onGet(this.getOn.bind(this));
23
+ }
24
+ async setOn(value) {
25
+ const isOn = value;
26
+ if (isOn) {
27
+ try {
28
+ if (!this.platform.wsClient) {
29
+ throw new Error('WebSocket client non inizializzato');
30
+ }
31
+ await this.platform.wsClient.triggerScenario(this.device.id);
32
+ this.platform.log.info(`🎬 Scenario ${this.device.name} eseguito`);
33
+ // Spegni automaticamente dopo timeout configurabile (gli scenari sono momentanei)
34
+ const autoOffDelay = this.platform.config.scenarioAutoOffDelay || 500;
35
+ setTimeout(() => {
36
+ if (this.service) {
37
+ this.service.updateCharacteristic(this.platform.Characteristic.On, false);
38
+ this.platform.log.debug(`🔄 Scenario ${this.device.name} automaticamente spento dopo ${autoOffDelay}ms`);
39
+ }
40
+ }, autoOffDelay);
41
+ }
42
+ catch (error) {
43
+ this.platform.log.error(`❌ Errore esecuzione scenario ${this.device.name}:`, error);
44
+ throw new this.platform.api.hap.HapStatusError(-70402 /* this.platform.api.hap.HAPStatus.SERVICE_COMMUNICATION_FAILURE */);
45
+ }
46
+ }
47
+ // Non facciamo nulla per "spegnere" uno scenario
48
+ }
49
+ async getOn() {
50
+ // Gli scenari non hanno uno stato persistente, tornano sempre false
51
+ return false;
52
+ }
53
+ }
54
+ exports.ScenarioAccessory = ScenarioAccessory;
55
+ //# sourceMappingURL=scenario-accessory.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"scenario-accessory.js","sourceRoot":"","sources":["../../src/accessories/scenario-accessory.ts"],"names":[],"mappings":";;;AASA,MAAa,iBAAiB;IAG1B,YACqB,QAAwB,EACxB,SAA4B,EAC5B,MAAoB;QAFpB,aAAQ,GAAR,QAAQ,CAAgB;QACxB,cAAS,GAAT,SAAS,CAAmB;QAC5B,WAAM,GAAN,MAAM,CAAc;QAErC,0CAA0C;QAC1C,IAAI,CAAC,SAAS,CAAC,UAAU,CAAC,IAAI,CAAC,QAAQ,CAAC,OAAO,CAAC,oBAAoB,CAAE;aACjE,iBAAiB,CAAC,IAAI,CAA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CAAC;gBAC7D,IAAI,CAAC,QAAQ,CAAC,GAAG,CAAC,IAAI,CAAC,eAAe,IAAI,CAAC,MAAM,CAAC,IAAI,WAAW,CAAC,CAAC;gBAEnE,kFAAkF;gBAClF,MAAM,YAAY,GAAG,IAAI,CAAC,QAAQ,CAAC,MAAM,CAAC,oBAAoB,IAAI,GAAG,CAAC;gBACtE,UAAU,CAAC,GAAG,EAAE;oBACZ,IAAI,IAAI,CAAC,OAAO,EAAE,CAAC;wBACf,IAAI,CAAC,OAAO,CAAC,oBAAoB,CAAC,IAAI,CAAC,QAAQ,CAAC,cAAc,CAAC,EAAE,EAAE,KAAK,CAAC,CAAC;wBAC1E,IAAI,CAAC,QAAQ,CAAC,GAAG,CAAC,KAAK,CAAC,eAAe,IAAI,CAAC,MAAM,CAAC,IAAI,gCAAgC,YAAY,IAAI,CAAC,CAAC;oBAC7G,CAAC;gBACL,CAAC,EAAE,YAAY,CAAC,CAAC;YAErB,CAAC;YAAC,OAAO,KAAK,EAAE,CAAC;gBACb,IAAI,CAAC,QAAQ,CAAC,GAAG,CAAC,KAAK,CAAC,gCAAgC,IAAI,CAAC,MAAM,CAAC,IAAI,GAAG,EAAE,KAAK,CAAC,CAAC;gBACpF,MAAM,IAAI,IAAI,CAAC,QAAQ,CAAC,GAAG,CAAC,GAAG,CAAC,cAAc,4EAA+D,CAAC;YAClH,CAAC;QACL,CAAC;QACD,iDAAiD;IACrD,CAAC;IAED,KAAK,CAAC,KAAK;QACP,oEAAoE;QACpE,OAAO,KAAK,CAAC;IACjB,CAAC;CACJ;AA3DD,8CA2DC"}
@@ -0,0 +1,24 @@
1
+ import type { CharacteristicValue, PlatformAccessory } from 'homebridge';
2
+ import type { Lares4Platform } from '../platform';
3
+ import type { KseniaSensor } from '../types';
4
+ export declare class SensorAccessory {
5
+ private readonly platform;
6
+ private readonly accessory;
7
+ private service;
8
+ private device;
9
+ constructor(platform: Lares4Platform, accessory: PlatformAccessory);
10
+ private createSensorService;
11
+ private createTemperatureSensor;
12
+ private createHumiditySensor;
13
+ private createLightSensor;
14
+ private createMotionSensor;
15
+ private createContactSensor;
16
+ getCurrentTemperature(): Promise<CharacteristicValue>;
17
+ getCurrentHumidity(): Promise<CharacteristicValue>;
18
+ getCurrentLightLevel(): Promise<CharacteristicValue>;
19
+ getMotionDetected(): Promise<CharacteristicValue>;
20
+ getContactState(): Promise<CharacteristicValue>;
21
+ private getSensorTypeLabel;
22
+ updateStatus(newDevice: KseniaSensor): void;
23
+ }
24
+ //# sourceMappingURL=sensor-accessory.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"sensor-accessory.d.ts","sourceRoot":"","sources":["../../src/accessories/sensor-accessory.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,mBAAmB,EAAE,iBAAiB,EAAW,MAAM,YAAY,CAAC;AAClF,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,aAAa,CAAC;AAClD,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,UAAU,CAAC;AAE7C,qBAAa,eAAe;IAKpB,OAAO,CAAC,QAAQ,CAAC,QAAQ;IACzB,OAAO,CAAC,QAAQ,CAAC,SAAS;IAL9B,OAAO,CAAC,OAAO,CAAU;IACzB,OAAO,CAAC,MAAM,CAAe;gBAGR,QAAQ,EAAE,cAAc,EACxB,SAAS,EAAE,iBAAiB;IAgBjD,OAAO,CAAC,mBAAmB;IAkB3B,OAAO,CAAC,uBAAuB;IAU/B,OAAO,CAAC,oBAAoB;IAU5B,OAAO,CAAC,iBAAiB;IAUzB,OAAO,CAAC,kBAAkB;IAU1B,OAAO,CAAC,mBAAmB;IAUrB,qBAAqB,IAAI,OAAO,CAAC,mBAAmB,CAAC;IAMrD,kBAAkB,IAAI,OAAO,CAAC,mBAAmB,CAAC;IAMlD,oBAAoB,IAAI,OAAO,CAAC,mBAAmB,CAAC;IAMpD,iBAAiB,IAAI,OAAO,CAAC,mBAAmB,CAAC;IAIjD,eAAe,IAAI,OAAO,CAAC,mBAAmB,CAAC;IAKrD,OAAO,CAAC,kBAAkB;IAY1B,YAAY,CAAC,SAAS,EAAE,YAAY,GAAG,IAAI;CAuC9C"}
@@ -0,0 +1,128 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.SensorAccessory = void 0;
4
+ class SensorAccessory {
5
+ constructor(platform, accessory) {
6
+ this.platform = platform;
7
+ this.accessory = accessory;
8
+ this.device = accessory.context.device;
9
+ // Imposta le informazioni dell'accessorio
10
+ this.accessory.getService(this.platform.Service.AccessoryInformation)
11
+ .setCharacteristic(this.platform.Characteristic.Manufacturer, 'Ksenia')
12
+ .setCharacteristic(this.platform.Characteristic.Model, `Lares4 ${this.getSensorTypeLabel()}`)
13
+ .setCharacteristic(this.platform.Characteristic.SerialNumber, this.device.id)
14
+ .setCharacteristic(this.platform.Characteristic.FirmwareRevision, '2.0.0');
15
+ // Crea il servizio appropriato in base al tipo di sensore
16
+ this.service = this.createSensorService();
17
+ this.service.setCharacteristic(this.platform.Characteristic.Name, this.device.name);
18
+ }
19
+ createSensorService() {
20
+ switch (this.device.status.sensorType) {
21
+ case 'temperature':
22
+ return this.createTemperatureSensor();
23
+ case 'humidity':
24
+ return this.createHumiditySensor();
25
+ case 'light':
26
+ return this.createLightSensor();
27
+ case 'motion':
28
+ return this.createMotionSensor();
29
+ case 'contact':
30
+ return this.createContactSensor();
31
+ default:
32
+ // Default a temperature sensor
33
+ return this.createTemperatureSensor();
34
+ }
35
+ }
36
+ createTemperatureSensor() {
37
+ const service = this.accessory.getService(this.platform.Service.TemperatureSensor)
38
+ || this.accessory.addService(this.platform.Service.TemperatureSensor);
39
+ service.getCharacteristic(this.platform.Characteristic.CurrentTemperature)
40
+ .onGet(this.getCurrentTemperature.bind(this));
41
+ return service;
42
+ }
43
+ createHumiditySensor() {
44
+ const service = this.accessory.getService(this.platform.Service.HumiditySensor)
45
+ || this.accessory.addService(this.platform.Service.HumiditySensor);
46
+ service.getCharacteristic(this.platform.Characteristic.CurrentRelativeHumidity)
47
+ .onGet(this.getCurrentHumidity.bind(this));
48
+ return service;
49
+ }
50
+ createLightSensor() {
51
+ const service = this.accessory.getService(this.platform.Service.LightSensor)
52
+ || this.accessory.addService(this.platform.Service.LightSensor);
53
+ service.getCharacteristic(this.platform.Characteristic.CurrentAmbientLightLevel)
54
+ .onGet(this.getCurrentLightLevel.bind(this));
55
+ return service;
56
+ }
57
+ createMotionSensor() {
58
+ const service = this.accessory.getService(this.platform.Service.MotionSensor)
59
+ || this.accessory.addService(this.platform.Service.MotionSensor);
60
+ service.getCharacteristic(this.platform.Characteristic.MotionDetected)
61
+ .onGet(this.getMotionDetected.bind(this));
62
+ return service;
63
+ }
64
+ createContactSensor() {
65
+ const service = this.accessory.getService(this.platform.Service.ContactSensor)
66
+ || this.accessory.addService(this.platform.Service.ContactSensor);
67
+ service.getCharacteristic(this.platform.Characteristic.ContactSensorState)
68
+ .onGet(this.getContactState.bind(this));
69
+ return service;
70
+ }
71
+ async getCurrentTemperature() {
72
+ const value = this.device.status.value;
73
+ // HomeKit richiede temperature tra -270 e 100°C
74
+ return Math.max(-270, Math.min(100, value));
75
+ }
76
+ async getCurrentHumidity() {
77
+ const value = this.device.status.value;
78
+ // HomeKit richiede umidità tra 0 e 100%
79
+ return Math.max(0, Math.min(100, value));
80
+ }
81
+ async getCurrentLightLevel() {
82
+ const value = this.device.status.value;
83
+ // HomeKit richiede lux tra 0.0001 e 100000
84
+ return Math.max(0.0001, Math.min(100000, value));
85
+ }
86
+ async getMotionDetected() {
87
+ return this.device.status.value > 0;
88
+ }
89
+ async getContactState() {
90
+ // 0 = contact detected (chiuso), 1 = contact not detected (aperto)
91
+ return this.device.status.value > 0 ? 1 : 0;
92
+ }
93
+ getSensorTypeLabel() {
94
+ switch (this.device.status.sensorType) {
95
+ case 'temperature': return 'Temperature Sensor';
96
+ case 'humidity': return 'Humidity Sensor';
97
+ case 'light': return 'Light Sensor';
98
+ case 'motion': return 'Motion Sensor';
99
+ case 'contact': return 'Contact Sensor';
100
+ default: return 'Sensor';
101
+ }
102
+ }
103
+ // Metodo per aggiornare lo stato dall'esterno (aggiornamenti real-time)
104
+ updateStatus(newDevice) {
105
+ this.device = newDevice;
106
+ // Aggiorna la caratteristica appropriata in base al tipo di sensore
107
+ switch (this.device.status.sensorType) {
108
+ case 'temperature':
109
+ this.service.updateCharacteristic(this.platform.Characteristic.CurrentTemperature, Math.max(-270, Math.min(100, this.device.status.value)));
110
+ break;
111
+ case 'humidity':
112
+ this.service.updateCharacteristic(this.platform.Characteristic.CurrentRelativeHumidity, Math.max(0, Math.min(100, this.device.status.value)));
113
+ break;
114
+ case 'light':
115
+ this.service.updateCharacteristic(this.platform.Characteristic.CurrentAmbientLightLevel, Math.max(0.0001, Math.min(100000, this.device.status.value)));
116
+ break;
117
+ case 'motion':
118
+ this.service.updateCharacteristic(this.platform.Characteristic.MotionDetected, this.device.status.value > 0);
119
+ break;
120
+ case 'contact':
121
+ this.service.updateCharacteristic(this.platform.Characteristic.ContactSensorState, this.device.status.value > 0 ? 1 : 0);
122
+ break;
123
+ }
124
+ this.platform.log.debug(`🔄 Aggiornato sensore ${this.device.name}: ${this.device.status.value}${this.device.status.unit || ''}`);
125
+ }
126
+ }
127
+ exports.SensorAccessory = SensorAccessory;
128
+ //# sourceMappingURL=sensor-accessory.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"sensor-accessory.js","sourceRoot":"","sources":["../../src/accessories/sensor-accessory.ts"],"names":[],"mappings":";;;AAIA,MAAa,eAAe;IAIxB,YACqB,QAAwB,EACxB,SAA4B;QAD5B,aAAQ,GAAR,QAAQ,CAAgB;QACxB,cAAS,GAAT,SAAS,CAAmB;QAE7C,IAAI,CAAC,MAAM,GAAG,SAAS,CAAC,OAAO,CAAC,MAAsB,CAAC;QAEvD,0CAA0C;QAC1C,IAAI,CAAC,SAAS,CAAC,UAAU,CAAC,IAAI,CAAC,QAAQ,CAAC,OAAO,CAAC,oBAAoB,CAAE;aACjE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CAAC,KAAK,GAAG,IAAI,CAAC,MAAM,CAAC,MAAM,CAAC,IAAI,IAAI,EAAE,EAAE,CAAC,CAAC;IACtI,CAAC;CACJ;AAxKD,0CAwKC"}
@@ -0,0 +1,21 @@
1
+ import type { CharacteristicValue, PlatformAccessory } from 'homebridge';
2
+ import type { Lares4Platform } from '../platform';
3
+ import type { KseniaThermostat } from '../types';
4
+ export declare class ThermostatAccessory {
5
+ private readonly platform;
6
+ private readonly accessory;
7
+ private service;
8
+ private device;
9
+ constructor(platform: Lares4Platform, accessory: PlatformAccessory);
10
+ getCurrentHeatingCoolingState(): Promise<CharacteristicValue>;
11
+ getTargetHeatingCoolingState(): Promise<CharacteristicValue>;
12
+ setTargetHeatingCoolingState(value: CharacteristicValue): Promise<void>;
13
+ getCurrentTemperature(): Promise<CharacteristicValue>;
14
+ getTargetTemperature(): Promise<CharacteristicValue>;
15
+ setTargetTemperature(value: CharacteristicValue): Promise<void>;
16
+ getTemperatureDisplayUnits(): Promise<CharacteristicValue>;
17
+ getCurrentRelativeHumidity(): Promise<CharacteristicValue>;
18
+ private updateCharacteristics;
19
+ updateStatus(newDevice: KseniaThermostat): void;
20
+ }
21
+ //# sourceMappingURL=thermostat-accessory.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"thermostat-accessory.d.ts","sourceRoot":"","sources":["../../src/accessories/thermostat-accessory.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,mBAAmB,EAAE,iBAAiB,EAAW,MAAM,YAAY,CAAC;AAClF,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,aAAa,CAAC;AAClD,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,UAAU,CAAC;AAEjD,qBAAa,mBAAmB;IAKxB,OAAO,CAAC,QAAQ,CAAC,QAAQ;IACzB,OAAO,CAAC,QAAQ,CAAC,SAAS;IAL9B,OAAO,CAAC,OAAO,CAAU;IACzB,OAAO,CAAC,MAAM,CAAmB;gBAGZ,QAAQ,EAAE,cAAc,EACxB,SAAS,EAAE,iBAAiB;IAsD3C,6BAA6B,IAAI,OAAO,CAAC,mBAAmB,CAAC;IAY7D,4BAA4B,IAAI,OAAO,CAAC,mBAAmB,CAAC;IAU5D,4BAA4B,CAAC,KAAK,EAAE,mBAAmB,GAAG,OAAO,CAAC,IAAI,CAAC;IAuBvE,qBAAqB,IAAI,OAAO,CAAC,mBAAmB,CAAC;IASrD,oBAAoB,IAAI,OAAO,CAAC,mBAAmB,CAAC;IAUpD,oBAAoB,CAAC,KAAK,EAAE,mBAAmB,GAAG,OAAO,CAAC,IAAI,CAAC;IAe/D,0BAA0B,IAAI,OAAO,CAAC,mBAAmB,CAAC;IAI1D,0BAA0B,IAAI,OAAO,CAAC,mBAAmB,CAAC;IAOhE,OAAO,CAAC,qBAAqB;IAyC7B,YAAY,CAAC,SAAS,EAAE,gBAAgB,GAAG,IAAI;CAkDlD"}
@@ -0,0 +1,215 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.ThermostatAccessory = void 0;
4
+ class ThermostatAccessory {
5
+ constructor(platform, accessory) {
6
+ this.platform = platform;
7
+ this.accessory = accessory;
8
+ this.device = accessory.context.device;
9
+ // Imposta le informazioni dell'accessorio
10
+ this.accessory.getService(this.platform.Service.AccessoryInformation)
11
+ .setCharacteristic(this.platform.Characteristic.Manufacturer, 'Ksenia')
12
+ .setCharacteristic(this.platform.Characteristic.Model, 'Lares4 Thermostat')
13
+ .setCharacteristic(this.platform.Characteristic.SerialNumber, this.device.id)
14
+ .setCharacteristic(this.platform.Characteristic.FirmwareRevision, '2.0.0');
15
+ // Ottieni o crea il servizio Thermostat
16
+ this.service = this.accessory.getService(this.platform.Service.Thermostat)
17
+ || this.accessory.addService(this.platform.Service.Thermostat);
18
+ this.service.setCharacteristic(this.platform.Characteristic.Name, this.device.name);
19
+ // Imposta gli handlers per le caratteristiche obbligatorie
20
+ this.service.getCharacteristic(this.platform.Characteristic.CurrentHeatingCoolingState)
21
+ .onGet(this.getCurrentHeatingCoolingState.bind(this));
22
+ this.service.getCharacteristic(this.platform.Characteristic.TargetHeatingCoolingState)
23
+ .onSet(this.setTargetHeatingCoolingState.bind(this))
24
+ .onGet(this.getTargetHeatingCoolingState.bind(this));
25
+ this.service.getCharacteristic(this.platform.Characteristic.CurrentTemperature)
26
+ .onGet(this.getCurrentTemperature.bind(this));
27
+ this.service.getCharacteristic(this.platform.Characteristic.TargetTemperature)
28
+ .onSet(this.setTargetTemperature.bind(this))
29
+ .onGet(this.getTargetTemperature.bind(this));
30
+ this.service.getCharacteristic(this.platform.Characteristic.TemperatureDisplayUnits)
31
+ .onGet(this.getTemperatureDisplayUnits.bind(this));
32
+ // Caratteristiche opzionali
33
+ if (this.device.humidity !== undefined) {
34
+ this.service.getCharacteristic(this.platform.Characteristic.CurrentRelativeHumidity)
35
+ .onGet(this.getCurrentRelativeHumidity.bind(this));
36
+ }
37
+ // Imposta i range di temperatura (configurabili)
38
+ const tempDefaults = this.platform.config.temperatureDefaults || {};
39
+ this.service.getCharacteristic(this.platform.Characteristic.TargetTemperature)
40
+ .setProps({
41
+ minValue: tempDefaults.min || 10,
42
+ maxValue: tempDefaults.max || 38,
43
+ minStep: tempDefaults.step || 0.5,
44
+ });
45
+ // Inizializza i valori delle caratteristiche
46
+ this.updateCharacteristics();
47
+ }
48
+ async getCurrentHeatingCoolingState() {
49
+ // 0 = Off, 1 = Heat, 2 = Cool
50
+ switch (this.device.mode) {
51
+ case 'heat':
52
+ return this.device.currentTemperature < this.device.targetTemperature ? 1 : 0;
53
+ case 'cool':
54
+ return this.device.currentTemperature > this.device.targetTemperature ? 2 : 0;
55
+ default:
56
+ return 0; // Off
57
+ }
58
+ }
59
+ async getTargetHeatingCoolingState() {
60
+ // 0 = Off, 1 = Heat, 2 = Cool, 3 = Auto
61
+ switch (this.device.mode) {
62
+ case 'heat': return 1;
63
+ case 'cool': return 2;
64
+ case 'auto': return 3;
65
+ default: return 0; // Off
66
+ }
67
+ }
68
+ async setTargetHeatingCoolingState(value) {
69
+ const targetState = value;
70
+ let newMode;
71
+ switch (targetState) {
72
+ case 1:
73
+ newMode = 'heat';
74
+ break;
75
+ case 2:
76
+ newMode = 'cool';
77
+ break;
78
+ case 3:
79
+ newMode = 'auto';
80
+ break;
81
+ default:
82
+ newMode = 'off';
83
+ break;
84
+ }
85
+ try {
86
+ await this.platform.wsClient?.setThermostatMode(this.device.id, newMode);
87
+ this.device.mode = newMode;
88
+ this.platform.log.info(`🌡️ ${this.device.name}: Modalità ${newMode}`);
89
+ }
90
+ catch (error) {
91
+ this.platform.log.error(`❌ Errore controllo termostato ${this.device.name}:`, error);
92
+ throw new this.platform.api.hap.HapStatusError(-70402 /* this.platform.api.hap.HAPStatus.SERVICE_COMMUNICATION_FAILURE */);
93
+ }
94
+ }
95
+ async getCurrentTemperature() {
96
+ // Se non abbiamo una temperatura valida, ritorna un valore che indica "dati non disponibili"
97
+ if (this.device.currentTemperature === undefined || this.device.currentTemperature === null) {
98
+ this.platform.log.warn(`⚠️ ${this.device.name}: Temperatura corrente non disponibile`);
99
+ return 0; // Valore che indica dati non disponibili invece di 20°C hardcoded
100
+ }
101
+ return Math.max(-270, Math.min(100, this.device.currentTemperature));
102
+ }
103
+ async getTargetTemperature() {
104
+ // Se non abbiamo una temperatura target valida, usa un valore di default ragionevole
105
+ if (this.device.targetTemperature === undefined || this.device.targetTemperature === null) {
106
+ const defaultTemp = this.platform.config.temperatureDefaults?.target || 21;
107
+ this.platform.log.warn(`⚠️ ${this.device.name}: Temperatura target non disponibile, usando ${defaultTemp}°C come default`);
108
+ return defaultTemp;
109
+ }
110
+ return this.device.targetTemperature;
111
+ }
112
+ async setTargetTemperature(value) {
113
+ const targetTemperature = value;
114
+ try {
115
+ await this.platform.wsClient?.setThermostatTemperature(this.device.id, targetTemperature);
116
+ this.device.targetTemperature = targetTemperature;
117
+ this.platform.log.info(`🌡️ ${this.device.name}: Temperatura target ${targetTemperature}°C`);
118
+ }
119
+ catch (error) {
120
+ this.platform.log.error(`❌ Errore impostazione temperatura ${this.device.name}:`, error);
121
+ throw new this.platform.api.hap.HapStatusError(-70402 /* this.platform.api.hap.HAPStatus.SERVICE_COMMUNICATION_FAILURE */);
122
+ }
123
+ }
124
+ async getTemperatureDisplayUnits() {
125
+ return 0; // Celsius
126
+ }
127
+ async getCurrentRelativeHumidity() {
128
+ if (this.device.humidity !== undefined) {
129
+ return Math.max(0, Math.min(100, this.device.humidity));
130
+ }
131
+ return 50; // Default value
132
+ }
133
+ updateCharacteristics() {
134
+ // Usa valori sincroni per l'inizializzazione
135
+ let currentState = 0; // Off
136
+ switch (this.device.mode) {
137
+ case 'heat':
138
+ currentState = this.device.currentTemperature < this.device.targetTemperature ? 1 : 0;
139
+ break;
140
+ case 'cool':
141
+ currentState = this.device.currentTemperature > this.device.targetTemperature ? 2 : 0;
142
+ break;
143
+ }
144
+ let targetState = 0; // Off
145
+ switch (this.device.mode) {
146
+ case 'heat':
147
+ targetState = 1;
148
+ break;
149
+ case 'cool':
150
+ targetState = 2;
151
+ break;
152
+ case 'auto':
153
+ targetState = 3;
154
+ break;
155
+ }
156
+ this.service.updateCharacteristic(this.platform.Characteristic.CurrentHeatingCoolingState, currentState);
157
+ this.service.updateCharacteristic(this.platform.Characteristic.TargetHeatingCoolingState, targetState);
158
+ // Gestione migliorata per i valori di temperatura
159
+ const currentTemp = this.device.currentTemperature !== undefined && this.device.currentTemperature !== null
160
+ ? Math.max(-270, Math.min(100, this.device.currentTemperature))
161
+ : 0; // Valore che indica dati non disponibili
162
+ const defaultTemp = this.platform.config.temperatureDefaults?.target || 21;
163
+ const targetTemp = this.device.targetTemperature !== undefined && this.device.targetTemperature !== null
164
+ ? this.device.targetTemperature
165
+ : defaultTemp; // Default configurabile quando non disponibile
166
+ this.service.updateCharacteristic(this.platform.Characteristic.CurrentTemperature, currentTemp);
167
+ this.service.updateCharacteristic(this.platform.Characteristic.TargetTemperature, targetTemp);
168
+ if (this.device.humidity !== undefined) {
169
+ this.service.updateCharacteristic(this.platform.Characteristic.CurrentRelativeHumidity, Math.max(0, Math.min(100, this.device.humidity)));
170
+ }
171
+ }
172
+ // Metodo per aggiornare lo stato dall'esterno (aggiornamenti real-time)
173
+ updateStatus(newDevice) {
174
+ const oldDevice = this.device;
175
+ this.device = newDevice;
176
+ // Aggiorna le caratteristiche solo se necessario
177
+ if (oldDevice.currentTemperature !== newDevice.currentTemperature) {
178
+ this.service.updateCharacteristic(this.platform.Characteristic.CurrentTemperature, Math.max(-270, Math.min(100, newDevice.currentTemperature)));
179
+ }
180
+ if (oldDevice.targetTemperature !== newDevice.targetTemperature) {
181
+ this.service.updateCharacteristic(this.platform.Characteristic.TargetTemperature, newDevice.targetTemperature);
182
+ }
183
+ if (oldDevice.mode !== newDevice.mode) {
184
+ let targetState = 0;
185
+ switch (newDevice.mode) {
186
+ case 'heat':
187
+ targetState = 1;
188
+ break;
189
+ case 'cool':
190
+ targetState = 2;
191
+ break;
192
+ case 'auto':
193
+ targetState = 3;
194
+ break;
195
+ }
196
+ let currentState = 0;
197
+ switch (newDevice.mode) {
198
+ case 'heat':
199
+ currentState = newDevice.currentTemperature < newDevice.targetTemperature ? 1 : 0;
200
+ break;
201
+ case 'cool':
202
+ currentState = newDevice.currentTemperature > newDevice.targetTemperature ? 2 : 0;
203
+ break;
204
+ }
205
+ this.service.updateCharacteristic(this.platform.Characteristic.TargetHeatingCoolingState, targetState);
206
+ this.service.updateCharacteristic(this.platform.Characteristic.CurrentHeatingCoolingState, currentState);
207
+ }
208
+ if (oldDevice.humidity !== newDevice.humidity && newDevice.humidity !== undefined) {
209
+ this.service.updateCharacteristic(this.platform.Characteristic.CurrentRelativeHumidity, Math.max(0, Math.min(100, newDevice.humidity)));
210
+ }
211
+ this.platform.log.debug(`🔄 Aggiornato termostato ${this.device.name}: ${this.device.currentTemperature}°C → ${this.device.targetTemperature}°C (${this.device.mode})`);
212
+ }
213
+ }
214
+ exports.ThermostatAccessory = ThermostatAccessory;
215
+ //# sourceMappingURL=thermostat-accessory.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"thermostat-accessory.js","sourceRoot":"","sources":["../../src/accessories/thermostat-accessory.ts"],"names":[],"mappings":";;;AAIA,MAAa,mBAAmB;IAI5B,YACqB,QAAwB,EACxB,SAA4B;QAD5B,aAAQ,GAAR,QAAQ,CAAgB;QACxB,cAAS,GAAT,SAAS,CAAmB;QAE7C,IAAI,CAAC,MAAM,GAAG,SAAS,CAAC,OAAO,CAAC,MAA0B,CAAC;QAE3D,0CAA0C;QAC1C,IAAI,CAAC,SAAS,CAAC,UAAU,CAAC,IAAI,CAAC,QAAQ,CAAC,OAAO,CAAC,oBAAoB,CAAE;aACjE,iBAAiB,CAAC,IAAI,CAAC,QAAQ,CAAC,cAAc,CAAC,YAAY,EAAE,QAAQ,CAAC;aACtE,iBAAiB,CAAC,IAAI,CAAC,QAAQ,CAAC,cAAc,CAAC,KAAK,EAAE,mBAAmB,CAAC;aAC1E,iBAAiB,CAAC,IAAI,CAAC,QAAQ,CAAC,cAAc,CAAC,YAAY,EAAE,IAAI,CAAC,MAAM,CAAC,EAAE,CAAC;aAC5E,iBAAiB,CAAC,IAAI,CAAC,QAAQ,CAAC,cAAc,CAAC,gBAAgB,EAAE,OAAO,CAAC,CAAC;QAE/E,wCAAwC;QACxC,IAAI,CAAC,OAAO,GAAG,IAAI,CAAC,SAAS,CAAC,UAAU,CAAC,IAAI,CAAC,QAAQ,CAAC,OAAO,CAAC,UAAU,CAAC;eACnE,IAAI,CAAC,SAAS,CAAC,UAAU,CAAC,IAAI,CAAC,QAAQ,CAAC,OAAO,CAAC,UAAU,CAAC,CAAC;QAEnE,IAAI,CAAC,OAAO,CAAC,iBAAiB,CAAC,IAAI,CAAC,QAAQ,CAAC,cAAc,CAAC,IAAI,EAAE,IAAI,CAAC,MAAM,CAAC,IAAI,CAAC,CAAC;QAEpF,2DAA2D;QAC3D,IAAI,CAAC,OAAO,CAAC,iBAAiB,CAAC,I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M,CAAC,IAAI,GAAG,CAAC,CAAC;IAC5K,CAAC;CACJ;AAjPD,kDAiPC"}
@@ -0,0 +1,18 @@
1
+ import type { CharacteristicValue, PlatformAccessory } from 'homebridge';
2
+ import type { Lares4Platform } from '../platform';
3
+ import type { KseniaZone } from '../types';
4
+ export declare class ZoneAccessory {
5
+ private readonly platform;
6
+ private readonly accessory;
7
+ private service;
8
+ private device;
9
+ constructor(platform: Lares4Platform, accessory: PlatformAccessory);
10
+ getContactState(): Promise<CharacteristicValue>;
11
+ getStatusActive(): Promise<CharacteristicValue>;
12
+ getStatusFault(): Promise<CharacteristicValue>;
13
+ getStatusTampered(): Promise<CharacteristicValue>;
14
+ private updateCharacteristics;
15
+ updateStatus(newDevice: KseniaZone): void;
16
+ private getZoneStatusString;
17
+ }
18
+ //# sourceMappingURL=zone-accessory.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"zone-accessory.d.ts","sourceRoot":"","sources":["../../src/accessories/zone-accessory.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,mBAAmB,EAAE,iBAAiB,EAAW,MAAM,YAAY,CAAC;AAClF,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,aAAa,CAAC;AAClD,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,UAAU,CAAC;AAE3C,qBAAa,aAAa;IAKlB,OAAO,CAAC,QAAQ,CAAC,QAAQ;IACzB,OAAO,CAAC,QAAQ,CAAC,SAAS;IAL9B,OAAO,CAAC,OAAO,CAAU;IACzB,OAAO,CAAC,MAAM,CAAa;gBAGN,QAAQ,EAAE,cAAc,EACxB,SAAS,EAAE,iBAAiB;IAsC3C,eAAe,IAAI,OAAO,CAAC,mBAAmB,CAAC;IAK/C,eAAe,IAAI,OAAO,CAAC,mBAAmB,CAAC;IAK/C,cAAc,IAAI,OAAO,CAAC,mBAAmB,CAAC;IAK9C,iBAAiB,IAAI,OAAO,CAAC,mBAAmB,CAAC;IAMvD,OAAO,CAAC,qBAAqB;IAuB7B,YAAY,CAAC,SAAS,EAAE,UAAU,GAAG,IAAI;IAgDzC,OAAO,CAAC,mBAAmB;CAS9B"}