@lv426/homebridge-systemair-enhanced 1.0.3 → 1.0.5

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 (2) hide show
  1. package/index.js +67 -12
  2. package/package.json +1 -1
package/index.js CHANGED
@@ -25,27 +25,52 @@ class SystemairVentilator {
25
25
  CURRENT_TEMP: '12543', // Current temperature sensor reading
26
26
  TARGET_TEMP: '2000', // Target temperature setting
27
27
  HUMIDITY: '12135', // Current humidity sensor reading
28
+ ECO_MODE: '2504', // Turning ECO mode on / off
29
+ FREE_COOLING: '4100', // Free Cooling activate / deactivate
28
30
  };
29
31
 
30
32
  this.axiosInstance = axios.create({
31
33
  timeout: 20000, // 20 seconds timeout
32
34
  });
33
35
 
34
- // Fan service
35
- this.fanService = new Service.Fanv2(this.config.name + ' Fan');
36
+ // FAN
37
+ this.fanService =
38
+ this.accessory.getService(Service.Fanv2) ??
39
+ this.accessory.addService(Service.Fanv2, `${this.config.name} Fan`);
40
+
41
+ // REFRESH (Switch #1) — add subtype "refresh"
42
+ this.refreshService =
43
+ this.accessory.getServiceById(Service.Switch, 'refresh') ??
44
+ this.accessory.addService(
45
+ Service.Switch,
46
+ `${this.config.name} Refresh`,
47
+ 'refresh'
48
+ );
36
49
 
37
- // Refresh service
38
- this.refreshService = new Service.Switch(this.config.name + ' Refresh');
50
+ // ECO MODE (Switch #2) — add subtype "eco"
51
+ this.ecoModeService =
52
+ this.accessory.getServiceById(Service.Switch, 'eco') ??
53
+ this.accessory.addService(
54
+ Service.Switch,
55
+ `${this.config.name} Eco Mode`,
56
+ 'eco'
57
+ );
39
58
 
40
- // Thermostat service
41
- this.thermostatService = new Service.Thermostat(
42
- this.config.name + ' Thermostat'
43
- );
59
+ // THERMOSTAT
60
+ this.thermostatService =
61
+ this.accessory.getService(Service.Thermostat) ??
62
+ this.accessory.addService(
63
+ Service.Thermostat,
64
+ `${this.config.name} Thermostat`
65
+ );
44
66
 
45
- // Humidity sensor service
46
- this.humiditySensorService = new Service.HumiditySensor(
47
- this.config.name + ' Humidity'
48
- );
67
+ // HUMIDITY SENSOR
68
+ this.humiditySensorService =
69
+ this.accessory.getService(Service.HumiditySensor) ??
70
+ this.accessory.addService(
71
+ Service.HumiditySensor,
72
+ `${this.config.name} Humidity`
73
+ );
49
74
 
50
75
  this.setupCharacteristics();
51
76
  }
@@ -67,6 +92,12 @@ class SystemairVentilator {
67
92
  .getCharacteristic(Characteristic.On)
68
93
  .onSet(this.setRefresh.bind(this));
69
94
 
95
+ // Eco Mode characteristic
96
+ this.ecoModeService
97
+ .getCharacteristic(Characteristic.On)
98
+ .onGet(this.getEcoMode.bind(this))
99
+ .onSet(this.setEcoMode.bind(this));
100
+
70
101
  // Thermostat characteristics
71
102
  this.thermostatService
72
103
  .getCharacteristic(Characteristic.CurrentTemperature)
@@ -179,6 +210,22 @@ class SystemairVentilator {
179
210
  }
180
211
  }
181
212
 
213
+ async setEcoMode(value) {
214
+ const writeUrl = `http://${this.config.ip}/mwrite?{"${this.PARAM_IDS.ECO_MODE}":${value}}`;
215
+ this.log(`Eco Mode: Sending request to ${writeUrl}`);
216
+ await this.retryRequest(writeUrl);
217
+ this.log(`Eco Mode: Successfully started eco mode.`);
218
+ }
219
+
220
+ async getEcoMode() {
221
+ const url = `http://${this.config.ip}/mread?{"${this.PARAM_IDS.ECO_MODE}":1}`;
222
+ this.log(`Eco Mode: Sending request to ${url}`);
223
+ const response = await this.retryRequest(url);
224
+ const isEcoMode = response.data[this.PARAM_IDS.ECO_MODE] > 0;
225
+ this.log(`Eco Mode: Current state is ${isEcoMode ? 'ON' : 'OFF'}`);
226
+ return isEcoMode ? 1 : 0;
227
+ }
228
+
182
229
  // Thermostat methods
183
230
  async getCurrentTemperature() {
184
231
  const url = `http://${this.config.ip}/mread?{"${this.PARAM_IDS.CURRENT_TEMP}":1}`;
@@ -243,6 +290,12 @@ class SystemairVentilator {
243
290
  return 0; // Off
244
291
  }
245
292
 
293
+ this.log(
294
+ `Getting Current Heating and Cooling State. Current temperature is ${currentTemperature}°C and target is set to ${targetTemperature}°C - ${
295
+ currentTemperature < targetTemperature ? 'Heating' : 'Cooling'
296
+ } is starting.`
297
+ );
298
+
246
299
  if (currentTemperature < targetTemperature) {
247
300
  return 1; // Heating
248
301
  } else {
@@ -251,6 +304,7 @@ class SystemairVentilator {
251
304
  }
252
305
 
253
306
  async getTargetHeatingCoolingState() {
307
+ this.log(`Getting Target Heating and Cooling State`);
254
308
  return this.getCurrentHeatingCoolingState();
255
309
  }
256
310
 
@@ -287,6 +341,7 @@ class SystemairVentilator {
287
341
  this.refreshService,
288
342
  this.thermostatService,
289
343
  this.humiditySensorService,
344
+ this.ecoModeService,
290
345
  ];
291
346
  }
292
347
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@lv426/homebridge-systemair-enhanced",
3
- "version": "1.0.3",
3
+ "version": "1.0.5",
4
4
  "description": "An enhanced Homebridge plugin for controlling Systemair Ventilators.",
5
5
  "main": "index.js",
6
6
  "scripts": {