homebridge-verano 2.0.0 → 2.0.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.d.ts +2 -9
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +67 -51
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
- package/src/index.ts +71 -61
package/dist/index.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { AccessoryConfig, AccessoryPlugin, API,
|
|
1
|
+
import { AccessoryConfig, AccessoryPlugin, API, Controller, Logging, Service } from 'homebridge';
|
|
2
2
|
export declare class VeranoAccessoryPlugin implements AccessoryPlugin {
|
|
3
3
|
private readonly log;
|
|
4
4
|
private readonly config;
|
|
@@ -7,7 +7,7 @@ export declare class VeranoAccessoryPlugin implements AccessoryPlugin {
|
|
|
7
7
|
private readonly TURN_ON_OFF_TEMPERATURE;
|
|
8
8
|
private readonly informationService;
|
|
9
9
|
private readonly name;
|
|
10
|
-
private readonly
|
|
10
|
+
private readonly service;
|
|
11
11
|
private isOn;
|
|
12
12
|
private isAuthorized;
|
|
13
13
|
private sessionCookie;
|
|
@@ -16,13 +16,6 @@ export declare class VeranoAccessoryPlugin implements AccessoryPlugin {
|
|
|
16
16
|
identify?(): void;
|
|
17
17
|
getServices(): Service[];
|
|
18
18
|
getControllers?(): Controller[];
|
|
19
|
-
handleActiveGet(): Promise<any>;
|
|
20
|
-
handleActiveSet(value: CharacteristicValue): Promise<void>;
|
|
21
|
-
handleCurrentTemperatureGet(): Promise<number>;
|
|
22
|
-
handleTargetTemperatureGet(): Promise<number>;
|
|
23
|
-
handleTargetTemperatureSet(targetTemperature: any): Promise<void>;
|
|
24
|
-
handleTemperatureDisplayUnitsGet(): any;
|
|
25
|
-
handleTemperatureDisplayUnitsSet(value: any): void;
|
|
26
19
|
private fetchTargetTemperature;
|
|
27
20
|
private fetchCurrentTemperature;
|
|
28
21
|
private fetchDataTiles;
|
package/dist/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,eAAe,EAAE,eAAe,EAAE,GAAG,EAAE,
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,eAAe,EAAE,eAAe,EAAE,GAAG,EAAE,UAAU,EAAE,OAAO,EAAE,OAAO,EAAC,MAAM,YAAY,CAAC;AAQ/F,qBAAa,qBAAsB,YAAW,eAAe;IAcrD,OAAO,CAAC,QAAQ,CAAC,GAAG;IACpB,OAAO,CAAC,QAAQ,CAAC,MAAM;IACvB,OAAO,CAAC,QAAQ,CAAC,GAAG;IAdxB,OAAO,CAAC,QAAQ,CAAC,mBAAmB,CAAc;IAClD,OAAO,CAAC,QAAQ,CAAC,uBAAuB,CAAc;IACtD,OAAO,CAAC,QAAQ,CAAC,kBAAkB,CAAM;IACzC,OAAO,CAAC,QAAQ,CAAC,IAAI,CAAS;IAC9B,OAAO,CAAC,QAAQ,CAAC,OAAO,CAAU;IAElC,OAAO,CAAC,IAAI,CAAU;IACtB,OAAO,CAAC,YAAY,CAAU;IAC9B,OAAO,CAAC,aAAa,CAAS;IAC9B,OAAO,CAAC,cAAc,CAAM;gBAGP,GAAG,EAAE,OAAO,EACZ,MAAM,EAAE,eAAe,EACvB,GAAG,EAAE,GAAG;IA0F7B,QAAQ,CAAC,IAAI,IAAI;IAIjB,WAAW,IAAI,OAAO,EAAE;IAOxB,cAAc,CAAC,IAAI,UAAU,EAAE;YAIjB,sBAAsB;YAMtB,uBAAuB;YAMvB,cAAc;YA0Bd,oBAAoB;YAwBpB,wBAAwB;CAwBzC"}
|
package/dist/index.js
CHANGED
|
@@ -15,30 +15,79 @@ class VeranoAccessoryPlugin {
|
|
|
15
15
|
this.api = api;
|
|
16
16
|
this.TEMPERATURE_DIVIDER = 10;
|
|
17
17
|
this.TURN_ON_OFF_TEMPERATURE = 10;
|
|
18
|
+
this.log.debug('Verano accessory plugin initializing');
|
|
18
19
|
this.log = log;
|
|
19
20
|
this.config = config;
|
|
21
|
+
this.name = config.name;
|
|
20
22
|
this.api = api;
|
|
21
23
|
this.isAuthorized = false;
|
|
22
|
-
this.
|
|
24
|
+
this.sessionCookie = '';
|
|
25
|
+
this.isOn = false;
|
|
23
26
|
this.Characteristic = this.api.hap.Characteristic;
|
|
24
27
|
this.informationService = new this.api.hap.Service.AccessoryInformation()
|
|
25
28
|
.setCharacteristic(this.api.hap.Characteristic.Manufacturer, "Verano")
|
|
26
29
|
.setCharacteristic(this.api.hap.Characteristic.Model, "VER-24 WiFi");
|
|
27
|
-
this.
|
|
28
|
-
this.
|
|
29
|
-
|
|
30
|
-
.
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
.
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
30
|
+
this.service = new this.api.hap.Service.Thermostat(this.name);
|
|
31
|
+
this.service.getCharacteristic(this.Characteristic.CurrentHeatingCoolingState)
|
|
32
|
+
.on('get', (callback) => {
|
|
33
|
+
const value = this.isOn ? this.Characteristic.CurrentHeatingCoolingState.HEAT : this.Characteristic.CurrentHeatingCoolingState.OFF;
|
|
34
|
+
callback(null, value);
|
|
35
|
+
});
|
|
36
|
+
this.service.getCharacteristic(this.Characteristic.TargetHeatingCoolingState)
|
|
37
|
+
.on('get', (callback) => {
|
|
38
|
+
this.fetchTargetTemperature()
|
|
39
|
+
.then(targetTemperature => {
|
|
40
|
+
this.isOn = targetTemperature > this.TURN_ON_OFF_TEMPERATURE;
|
|
41
|
+
const value = this.isOn ? this.Characteristic.TargetHeatingCoolingState.HEAT : this.Characteristic.TargetHeatingCoolingState.OFF;
|
|
42
|
+
callback(null, value);
|
|
43
|
+
});
|
|
44
|
+
})
|
|
45
|
+
.on('set', (value, callback) => {
|
|
46
|
+
this.isOn = value === this.Characteristic.TargetHeatingCoolingState.OFF;
|
|
47
|
+
if (this.isOn) {
|
|
48
|
+
callback(null);
|
|
49
|
+
return;
|
|
50
|
+
}
|
|
51
|
+
this.log.info('Turning off');
|
|
52
|
+
this.requestTemperatureChange(this.TURN_ON_OFF_TEMPERATURE)
|
|
53
|
+
.then(() => callback(null))
|
|
54
|
+
.catch(error => callback(error));
|
|
55
|
+
});
|
|
56
|
+
this.service.getCharacteristic(this.Characteristic.CurrentTemperature)
|
|
57
|
+
.on('get', (callback) => {
|
|
58
|
+
this.log.debug('Triggered GET CurrentTemperature');
|
|
59
|
+
this.fetchCurrentTemperature()
|
|
60
|
+
.then(currentTemperature => {
|
|
61
|
+
callback(null, currentTemperature);
|
|
62
|
+
})
|
|
63
|
+
.catch(error => {
|
|
64
|
+
this.log.error('Error during current temperature fetch', error);
|
|
65
|
+
callback(error);
|
|
66
|
+
});
|
|
67
|
+
});
|
|
68
|
+
this.service.getCharacteristic(this.Characteristic.TargetTemperature)
|
|
69
|
+
.on('get', (callback) => {
|
|
70
|
+
this.log.debug('Triggered GET TargetTemperature');
|
|
71
|
+
this.fetchTargetTemperature()
|
|
72
|
+
.then(targetTemperature => {
|
|
73
|
+
callback(null, targetTemperature);
|
|
74
|
+
})
|
|
75
|
+
.catch(error => {
|
|
76
|
+
this.log.error('Error during current temperature fetch', error);
|
|
77
|
+
callback(error);
|
|
78
|
+
});
|
|
79
|
+
})
|
|
80
|
+
.on('set', (value, callback) => {
|
|
81
|
+
this.log.debug('Triggered SET TargetTemperature:', value);
|
|
82
|
+
this.requestTemperatureChange(value)
|
|
83
|
+
.then(() => callback(null))
|
|
84
|
+
.catch(error => callback(error));
|
|
85
|
+
});
|
|
86
|
+
this.service.getCharacteristic(this.Characteristic.TemperatureDisplayUnits)
|
|
87
|
+
.on('get', (callback) => {
|
|
88
|
+
callback(null, this.Characteristic.TemperatureDisplayUnits.CELSIUS);
|
|
89
|
+
})
|
|
90
|
+
.on('set', (value, callback) => { });
|
|
42
91
|
this.log.debug('Verano accessory plugin initialized');
|
|
43
92
|
this.requestAuthorization();
|
|
44
93
|
}
|
|
@@ -48,45 +97,12 @@ class VeranoAccessoryPlugin {
|
|
|
48
97
|
getServices() {
|
|
49
98
|
return [
|
|
50
99
|
this.informationService,
|
|
51
|
-
this.
|
|
100
|
+
this.service,
|
|
52
101
|
];
|
|
53
102
|
}
|
|
54
103
|
getControllers() {
|
|
55
104
|
return [];
|
|
56
105
|
}
|
|
57
|
-
async handleActiveGet() {
|
|
58
|
-
const targetTemperature = await this.fetchTargetTemperature();
|
|
59
|
-
this.isOn = targetTemperature > this.TURN_ON_OFF_TEMPERATURE;
|
|
60
|
-
this.log.debug('Triggered GET Target Temperature:', targetTemperature, "isOn:", this.isOn);
|
|
61
|
-
return this.isOn ? this.Characteristic.Active.ACTIVE : this.Characteristic.Active.INACTIVE;
|
|
62
|
-
}
|
|
63
|
-
async handleActiveSet(value) {
|
|
64
|
-
this.log.debug('Triggered SET Active:', value);
|
|
65
|
-
this.isOn = value === this.Characteristic.Active.ACTIVE;
|
|
66
|
-
if (!this.isOn) {
|
|
67
|
-
this.log.info('Turning off');
|
|
68
|
-
await this.requestTemperatureChange(this.TURN_ON_OFF_TEMPERATURE);
|
|
69
|
-
}
|
|
70
|
-
}
|
|
71
|
-
async handleCurrentTemperatureGet() {
|
|
72
|
-
this.log.debug('Triggered GET CurrentTemperature');
|
|
73
|
-
return await this.fetchCurrentTemperature();
|
|
74
|
-
}
|
|
75
|
-
async handleTargetTemperatureGet() {
|
|
76
|
-
this.log.debug('Triggered GET TargetTemperature');
|
|
77
|
-
return await this.fetchTargetTemperature();
|
|
78
|
-
}
|
|
79
|
-
async handleTargetTemperatureSet(targetTemperature) {
|
|
80
|
-
this.log.debug('Triggered SET TargetTemperature:', targetTemperature);
|
|
81
|
-
await this.requestTemperatureChange(targetTemperature);
|
|
82
|
-
}
|
|
83
|
-
handleTemperatureDisplayUnitsGet() {
|
|
84
|
-
this.log.debug('Triggered GET TemperatureDisplayUnits (NOP)');
|
|
85
|
-
return this.Characteristic.TemperatureDisplayUnits.CELSIUS;
|
|
86
|
-
}
|
|
87
|
-
handleTemperatureDisplayUnitsSet(value) {
|
|
88
|
-
this.log.debug('Triggered SET TemperatureDisplayUnits (NOP):', value);
|
|
89
|
-
}
|
|
90
106
|
async fetchTargetTemperature() {
|
|
91
107
|
const tiles = await this.fetchDataTiles();
|
|
92
108
|
const foundTile = tiles.filter(tile => tile.id === 58)[0];
|
|
@@ -113,7 +129,7 @@ class VeranoAccessoryPlugin {
|
|
|
113
129
|
.get('https://emodul.pl/frontend/module_data', config)
|
|
114
130
|
.then(response => {
|
|
115
131
|
const tiles = response.data.tiles;
|
|
116
|
-
this.log.
|
|
132
|
+
this.log.info("Fetched", tiles.length, "data tiles");
|
|
117
133
|
return tiles;
|
|
118
134
|
}).catch(error => {
|
|
119
135
|
this.log.error("Error during tiles fetch", error);
|
package/dist/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";;;;;;AACA,kDAA0B;AAE1B,MAAM,CAAC,OAAO,GAAG,CAAC,GAAQ,EAAE,EAAE;IAC1B,GAAG,CAAC,iBAAiB,CAAC,uBAAuB,EAAE,qBAAqB,CAAC,CAAC;AAC1E,CAAC,CAAA;AAGD,MAAa,qBAAqB;IAa9B,YACqB,GAAY,EACZ,MAAuB,EACvB,GAAQ;QAFR,QAAG,GAAH,GAAG,CAAS;QACZ,WAAM,GAAN,MAAM,CAAiB;QACvB,QAAG,GAAH,GAAG,CAAK;QAdZ,wBAAmB,GAAW,EAAE,CAAC;QACjC,4BAAuB,GAAW,EAAE,CAAC;QAelD,IAAI,CAAC,GAAG,GAAG,GAAG,CAAC;QACf,IAAI,CAAC,MAAM,GAAG,MAAM,CAAC;QACrB,IAAI,CAAC,GAAG,GAAG,GAAG,CAAC;QACf,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AAC;YAC1B,MAAM,KAAK,CAAC;QAChB,CAAC,CAAC,CAAC;IACX,CAAC;IAEO,KAAK,CAAC,wBAAwB,CAAC,iBAAyB;QAC5D,IAAI,CAAC,GAAG,CAAC,IAAI,CAAC,yBAAyB,EAAE,iBAAiB,CAAC,CAAC;QAC5D,MAAM,WAAW,GAAG;YAChB;gBACI,GAAG,EAAE,GAAG;gBACR,MAAM,EAAE,iBAAiB,GAAG,IAAI,CAAC,mBAAmB;gBACpD,YAAY,EAAE,CAAC;aAClB;SACJ,CAAA;QACD,MAAM,MAAM,GAAG;YACX,OAAO,EAAE;gBACL,QAAQ,EAAE,IAAI,CAAC,aAAa;aAC/B;YACD,eAAe,EAAE,IAAI;SACxB,CAAC;QACF,OAAO,eAAK;aACP,IAAI,CAAC,qCAAqC,EAAE,WAAW,EAAE,MAAM,CAAC;aAChE,IAAI,CAAC,QAAQ,CAAC,EAAE,CAAC,QAAQ,aAAR,QAAQ,uBAAR,QAAQ,CAAE,IAAI,CAAC;aAChC,KAAK,CAAC,KAAK,CAAC,EAAE;YACX,IAAI,CAAC,GAAG,CAAC,KAAK,CAAC,iCAAiC,EAAE,KAAK,CAAC,CAAC;YACzD,MAAM,KAAK,CAAC;QAChB,CAAC,CAAC,CAAA;IACV,CAAC;CAEJ;AA/MD,sDA+MC"}
|
package/package.json
CHANGED
package/src/index.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {AccessoryConfig, AccessoryPlugin, API,
|
|
1
|
+
import {AccessoryConfig, AccessoryPlugin, API, Controller, Logging, Service} from 'homebridge';
|
|
2
2
|
import axios from "axios";
|
|
3
3
|
|
|
4
4
|
module.exports = (api: API) => {
|
|
@@ -12,7 +12,7 @@ export class VeranoAccessoryPlugin implements AccessoryPlugin {
|
|
|
12
12
|
private readonly TURN_ON_OFF_TEMPERATURE: number = 10;
|
|
13
13
|
private readonly informationService: any;
|
|
14
14
|
private readonly name: string;
|
|
15
|
-
private readonly
|
|
15
|
+
private readonly service: Service;
|
|
16
16
|
|
|
17
17
|
private isOn: boolean;
|
|
18
18
|
private isAuthorized: boolean;
|
|
@@ -24,11 +24,14 @@ export class VeranoAccessoryPlugin implements AccessoryPlugin {
|
|
|
24
24
|
private readonly config: AccessoryConfig,
|
|
25
25
|
private readonly api: API,
|
|
26
26
|
) {
|
|
27
|
+
this.log.debug('Verano accessory plugin initializing');
|
|
27
28
|
this.log = log;
|
|
28
29
|
this.config = config;
|
|
30
|
+
this.name = config.name;
|
|
29
31
|
this.api = api;
|
|
30
32
|
this.isAuthorized = false;
|
|
31
|
-
this.
|
|
33
|
+
this.sessionCookie = '';
|
|
34
|
+
this.isOn = false;
|
|
32
35
|
|
|
33
36
|
this.Characteristic = this.api.hap.Characteristic;
|
|
34
37
|
|
|
@@ -36,27 +39,75 @@ export class VeranoAccessoryPlugin implements AccessoryPlugin {
|
|
|
36
39
|
.setCharacteristic(this.api.hap.Characteristic.Manufacturer, "Verano")
|
|
37
40
|
.setCharacteristic(this.api.hap.Characteristic.Model, "VER-24 WiFi");
|
|
38
41
|
|
|
39
|
-
this.
|
|
42
|
+
this.service = new this.api.hap.Service.Thermostat(this.name);
|
|
40
43
|
|
|
41
|
-
this.
|
|
44
|
+
this.service.getCharacteristic(this.Characteristic.CurrentHeatingCoolingState)
|
|
45
|
+
.on('get', (callback) => {
|
|
46
|
+
const value = this.isOn ? this.Characteristic.CurrentHeatingCoolingState.HEAT : this.Characteristic.CurrentHeatingCoolingState.OFF;
|
|
47
|
+
callback(null, value);
|
|
48
|
+
});
|
|
42
49
|
|
|
43
|
-
this.
|
|
44
|
-
.
|
|
45
|
-
|
|
50
|
+
this.service.getCharacteristic(this.Characteristic.TargetHeatingCoolingState)
|
|
51
|
+
.on('get', (callback) => {
|
|
52
|
+
this.fetchTargetTemperature()
|
|
53
|
+
.then(targetTemperature => {
|
|
54
|
+
this.isOn = targetTemperature > this.TURN_ON_OFF_TEMPERATURE;
|
|
55
|
+
const value = this.isOn ? this.Characteristic.TargetHeatingCoolingState.HEAT : this.Characteristic.TargetHeatingCoolingState.OFF;
|
|
56
|
+
callback(null, value);
|
|
57
|
+
});
|
|
58
|
+
})
|
|
59
|
+
.on('set', (value, callback) => {
|
|
60
|
+
this.isOn = value === this.Characteristic.TargetHeatingCoolingState.OFF;
|
|
61
|
+
if (this.isOn) {
|
|
62
|
+
callback(null);
|
|
63
|
+
return;
|
|
64
|
+
}
|
|
65
|
+
this.log.info('Turning off');
|
|
66
|
+
this.requestTemperatureChange(this.TURN_ON_OFF_TEMPERATURE)
|
|
67
|
+
.then(() => callback(null))
|
|
68
|
+
.catch(error => callback(error));
|
|
46
69
|
|
|
47
|
-
this.heaterCooler.getCharacteristic(this.Characteristic.TargetHeaterCoolerState)
|
|
48
|
-
.onGet(this.handleTargetTemperatureGet.bind(this))
|
|
49
|
-
.onSet(this.handleTargetTemperatureSet.bind(this));
|
|
50
70
|
|
|
51
|
-
|
|
52
|
-
.onGet(this.handleTemperatureDisplayUnitsGet.bind(this))
|
|
53
|
-
.onSet(this.handleTemperatureDisplayUnitsSet.bind(this));
|
|
71
|
+
});
|
|
54
72
|
|
|
55
|
-
this.
|
|
56
|
-
.
|
|
73
|
+
this.service.getCharacteristic(this.Characteristic.CurrentTemperature)
|
|
74
|
+
.on('get', (callback) => {
|
|
75
|
+
this.log.debug('Triggered GET CurrentTemperature');
|
|
76
|
+
this.fetchCurrentTemperature()
|
|
77
|
+
.then(currentTemperature => {
|
|
78
|
+
callback(null, currentTemperature);
|
|
79
|
+
})
|
|
80
|
+
.catch(error => {
|
|
81
|
+
this.log.error('Error during current temperature fetch', error);
|
|
82
|
+
callback(error);
|
|
83
|
+
});
|
|
84
|
+
});
|
|
85
|
+
|
|
86
|
+
this.service.getCharacteristic(this.Characteristic.TargetTemperature)
|
|
87
|
+
.on('get', (callback) => {
|
|
88
|
+
this.log.debug('Triggered GET TargetTemperature');
|
|
89
|
+
this.fetchTargetTemperature()
|
|
90
|
+
.then(targetTemperature => {
|
|
91
|
+
callback(null, targetTemperature);
|
|
92
|
+
})
|
|
93
|
+
.catch(error => {
|
|
94
|
+
this.log.error('Error during current temperature fetch', error);
|
|
95
|
+
callback(error);
|
|
96
|
+
});
|
|
97
|
+
})
|
|
98
|
+
.on('set', (value, callback) => {
|
|
99
|
+
this.log.debug('Triggered SET TargetTemperature:', value);
|
|
100
|
+
this.requestTemperatureChange(value as number)
|
|
101
|
+
.then(() => callback(null))
|
|
102
|
+
.catch(error => callback(error));
|
|
103
|
+
});
|
|
104
|
+
|
|
105
|
+
this.service.getCharacteristic(this.Characteristic.TemperatureDisplayUnits)
|
|
106
|
+
.on('get', (callback) => {
|
|
107
|
+
callback(null, this.Characteristic.TemperatureDisplayUnits.CELSIUS);
|
|
108
|
+
})
|
|
109
|
+
.on('set', (value, callback) => {});
|
|
57
110
|
|
|
58
|
-
this.sessionCookie = '';
|
|
59
|
-
this.isOn = false;
|
|
60
111
|
this.log.debug('Verano accessory plugin initialized');
|
|
61
112
|
this.requestAuthorization();
|
|
62
113
|
}
|
|
@@ -68,7 +119,7 @@ export class VeranoAccessoryPlugin implements AccessoryPlugin {
|
|
|
68
119
|
getServices(): Service[] {
|
|
69
120
|
return [
|
|
70
121
|
this.informationService,
|
|
71
|
-
this.
|
|
122
|
+
this.service,
|
|
72
123
|
];
|
|
73
124
|
}
|
|
74
125
|
|
|
@@ -76,47 +127,6 @@ export class VeranoAccessoryPlugin implements AccessoryPlugin {
|
|
|
76
127
|
return [];
|
|
77
128
|
}
|
|
78
129
|
|
|
79
|
-
async handleActiveGet() {
|
|
80
|
-
const targetTemperature = await this.fetchTargetTemperature();
|
|
81
|
-
this.isOn = targetTemperature > this.TURN_ON_OFF_TEMPERATURE;
|
|
82
|
-
this.log.debug('Triggered GET Target Temperature:', targetTemperature, "isOn:", this.isOn);
|
|
83
|
-
return this.isOn ? this.Characteristic.Active.ACTIVE : this.Characteristic.Active.INACTIVE;
|
|
84
|
-
|
|
85
|
-
}
|
|
86
|
-
|
|
87
|
-
async handleActiveSet(value: CharacteristicValue) {
|
|
88
|
-
this.log.debug('Triggered SET Active:', value);
|
|
89
|
-
this.isOn = value === this.Characteristic.Active.ACTIVE;
|
|
90
|
-
if (!this.isOn) {
|
|
91
|
-
this.log.info('Turning off');
|
|
92
|
-
await this.requestTemperatureChange(this.TURN_ON_OFF_TEMPERATURE);
|
|
93
|
-
}
|
|
94
|
-
}
|
|
95
|
-
|
|
96
|
-
async handleCurrentTemperatureGet() {
|
|
97
|
-
this.log.debug('Triggered GET CurrentTemperature');
|
|
98
|
-
return await this.fetchCurrentTemperature();
|
|
99
|
-
}
|
|
100
|
-
|
|
101
|
-
async handleTargetTemperatureGet() {
|
|
102
|
-
this.log.debug('Triggered GET TargetTemperature');
|
|
103
|
-
return await this.fetchTargetTemperature();
|
|
104
|
-
}
|
|
105
|
-
|
|
106
|
-
async handleTargetTemperatureSet(targetTemperature) {
|
|
107
|
-
this.log.debug('Triggered SET TargetTemperature:', targetTemperature);
|
|
108
|
-
await this.requestTemperatureChange(targetTemperature);
|
|
109
|
-
}
|
|
110
|
-
|
|
111
|
-
handleTemperatureDisplayUnitsGet() {
|
|
112
|
-
this.log.debug('Triggered GET TemperatureDisplayUnits (NOP)');
|
|
113
|
-
return this.Characteristic.TemperatureDisplayUnits.CELSIUS;
|
|
114
|
-
}
|
|
115
|
-
|
|
116
|
-
handleTemperatureDisplayUnitsSet(value) {
|
|
117
|
-
this.log.debug('Triggered SET TemperatureDisplayUnits (NOP):', value);
|
|
118
|
-
}
|
|
119
|
-
|
|
120
130
|
private async fetchTargetTemperature() {
|
|
121
131
|
const tiles = await this.fetchDataTiles()
|
|
122
132
|
const foundTile = tiles.filter(tile => tile.id === 58)[0]
|
|
@@ -146,7 +156,7 @@ export class VeranoAccessoryPlugin implements AccessoryPlugin {
|
|
|
146
156
|
.get('https://emodul.pl/frontend/module_data', config)
|
|
147
157
|
.then(response => {
|
|
148
158
|
const tiles = response.data.tiles;
|
|
149
|
-
this.log.
|
|
159
|
+
this.log.info("Fetched", tiles.length, "data tiles");
|
|
150
160
|
return tiles;
|
|
151
161
|
}).catch(error => {
|
|
152
162
|
this.log.error("Error during tiles fetch", error);
|