@lv426/homebridge-systemair-enhanced 1.0.0 → 1.0.2
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/index.js +48 -38
- package/package.json +2 -2
package/index.js
CHANGED
|
@@ -22,7 +22,6 @@ class SystemairVentilator {
|
|
|
22
22
|
// These may need adjustment based on your specific device model
|
|
23
23
|
this.PARAM_IDS = {
|
|
24
24
|
FAN_SPEED: '1130', // Fan speed control (0=off, 2=low, 3=medium, 4=high)
|
|
25
|
-
TIMER: '1110', // Timer remaining time
|
|
26
25
|
CURRENT_TEMP: '12543', // Current temperature sensor reading
|
|
27
26
|
TARGET_TEMP: '2000', // Target temperature setting
|
|
28
27
|
HUMIDITY: '12135', // Current humidity sensor reading
|
|
@@ -38,9 +37,6 @@ class SystemairVentilator {
|
|
|
38
37
|
// Refresh service
|
|
39
38
|
this.refreshService = new Service.Switch(this.config.name + ' Refresh');
|
|
40
39
|
|
|
41
|
-
// Timer service (using BatteryService instead of LightSensor)
|
|
42
|
-
this.timerService = new Service.BatteryService(this.config.name + ' Timer');
|
|
43
|
-
|
|
44
40
|
// Thermostat service
|
|
45
41
|
this.thermostatService = new Service.Thermostat(
|
|
46
42
|
this.config.name + ' Thermostat'
|
|
@@ -71,11 +67,6 @@ class SystemairVentilator {
|
|
|
71
67
|
.getCharacteristic(Characteristic.On)
|
|
72
68
|
.onSet(this.setRefresh.bind(this));
|
|
73
69
|
|
|
74
|
-
// Timer characteristic (using Battery Level to store remaining time)
|
|
75
|
-
this.timerService
|
|
76
|
-
.getCharacteristic(Characteristic.BatteryLevel)
|
|
77
|
-
.onGet(this.getTimer.bind(this));
|
|
78
|
-
|
|
79
70
|
// Thermostat characteristics
|
|
80
71
|
this.thermostatService
|
|
81
72
|
.getCharacteristic(Characteristic.CurrentTemperature)
|
|
@@ -88,9 +79,21 @@ class SystemairVentilator {
|
|
|
88
79
|
.setProps({
|
|
89
80
|
minValue: 10,
|
|
90
81
|
maxValue: 38,
|
|
91
|
-
minStep:
|
|
82
|
+
minStep: 1,
|
|
92
83
|
});
|
|
93
84
|
|
|
85
|
+
this.thermostatService
|
|
86
|
+
.getCharacteristic(Characteristic.TargetHeatingCoolingState)
|
|
87
|
+
.onGet(this.getTargetHeatingCoolingState.bind(this))
|
|
88
|
+
.onSet(this.setTargetHeatingCoolingState.bind(this))
|
|
89
|
+
.setProps({
|
|
90
|
+
validValues: [0, 3], // Only OFF and AUTO modes supported
|
|
91
|
+
});
|
|
92
|
+
|
|
93
|
+
this.thermostatService
|
|
94
|
+
.getCharacteristic(Characteristic.CurrentHeatingCoolingState)
|
|
95
|
+
.onGet(this.getCurrentHeatingCoolingState.bind(this));
|
|
96
|
+
|
|
94
97
|
// Humidity sensor characteristic
|
|
95
98
|
this.humiditySensorService
|
|
96
99
|
.getCharacteristic(Characteristic.CurrentRelativeHumidity)
|
|
@@ -176,38 +179,16 @@ class SystemairVentilator {
|
|
|
176
179
|
}
|
|
177
180
|
}
|
|
178
181
|
|
|
179
|
-
async getTimer() {
|
|
180
|
-
const url = `http://${this.config.ip}/mread?{"${this.PARAM_IDS.TIMER}":2}`;
|
|
181
|
-
this.log(`Timer: Fetching timer value from ${url}`);
|
|
182
|
-
try {
|
|
183
|
-
const response = await this.retryRequest(url);
|
|
184
|
-
let timerValue = response.data[this.PARAM_IDS.TIMER]; // Extract timer value
|
|
185
|
-
|
|
186
|
-
// Ensure timer value is valid for HomeKit (0 - 100% battery level range)
|
|
187
|
-
if (timerValue < 0) {
|
|
188
|
-
timerValue = 0;
|
|
189
|
-
} else if (timerValue > 100) {
|
|
190
|
-
timerValue = 100; // Max HomeKit battery level
|
|
191
|
-
}
|
|
192
|
-
|
|
193
|
-
this.log(`Timer: Current remaining time is ${timerValue} minutes.`);
|
|
194
|
-
return timerValue; // Return valid percentage
|
|
195
|
-
} catch (error) {
|
|
196
|
-
this.log(`Timer: Error - ${error.message}`);
|
|
197
|
-
return 0; // Default to 0% if an error occurs
|
|
198
|
-
}
|
|
199
|
-
}
|
|
200
|
-
|
|
201
182
|
// Thermostat methods
|
|
202
183
|
async getCurrentTemperature() {
|
|
203
184
|
const url = `http://${this.config.ip}/mread?{"${this.PARAM_IDS.CURRENT_TEMP}":1}`;
|
|
204
185
|
this.log(`getCurrentTemperature: Fetching from ${url}`);
|
|
205
186
|
try {
|
|
206
187
|
const response = await this.retryRequest(url);
|
|
207
|
-
let temperature = response.data[this.PARAM_IDS.CURRENT_TEMP] || 20; // Default to 20°C if no data
|
|
188
|
+
let temperature = response.data[this.PARAM_IDS.CURRENT_TEMP] / 10 || 20; // Default to 20°C if no data
|
|
208
189
|
|
|
209
|
-
// Ensure temperature is within HomeKit range (
|
|
210
|
-
temperature = Math.max(
|
|
190
|
+
// Ensure temperature is within HomeKit range (10 to 38°C)
|
|
191
|
+
temperature = Math.max(10, Math.min(38, temperature));
|
|
211
192
|
|
|
212
193
|
this.log(
|
|
213
194
|
`getCurrentTemperature: Current temperature is ${temperature}°C`
|
|
@@ -224,7 +205,7 @@ class SystemairVentilator {
|
|
|
224
205
|
this.log(`getTargetTemperature: Fetching from ${url}`);
|
|
225
206
|
try {
|
|
226
207
|
const response = await this.retryRequest(url);
|
|
227
|
-
let temperature = response.data[this.PARAM_IDS.TARGET_TEMP] || 20; // Default to 20°C if no data
|
|
208
|
+
let temperature = response.data[this.PARAM_IDS.TARGET_TEMP] / 10 || 20; // Default to 20°C if no data
|
|
228
209
|
|
|
229
210
|
// Ensure temperature is within HomeKit target range (10-38°C)
|
|
230
211
|
temperature = Math.max(10, Math.min(38, temperature));
|
|
@@ -241,7 +222,9 @@ class SystemairVentilator {
|
|
|
241
222
|
// Ensure the value is within valid range
|
|
242
223
|
value = Math.max(10, Math.min(38, value));
|
|
243
224
|
|
|
244
|
-
const url = `http://${this.config.ip}/mwrite?{"${
|
|
225
|
+
const url = `http://${this.config.ip}/mwrite?{"${
|
|
226
|
+
this.PARAM_IDS.TARGET_TEMP
|
|
227
|
+
}":${value * 10}}`;
|
|
245
228
|
this.log(`setTargetTemperature: Setting target temperature to ${value}°C`);
|
|
246
229
|
try {
|
|
247
230
|
await this.retryRequest(url);
|
|
@@ -251,6 +234,34 @@ class SystemairVentilator {
|
|
|
251
234
|
}
|
|
252
235
|
}
|
|
253
236
|
|
|
237
|
+
async getCurrentHeatingCoolingState() {
|
|
238
|
+
// Always return Auto
|
|
239
|
+
const targetTemperature = await this.getTargetTemperature();
|
|
240
|
+
const currentTemperature = await this.getCurrentTemperature();
|
|
241
|
+
|
|
242
|
+
if (!targetTemperature) {
|
|
243
|
+
return 0; // Off
|
|
244
|
+
}
|
|
245
|
+
|
|
246
|
+
if (currentTemperature < targetTemperature) {
|
|
247
|
+
return 1; // Heating
|
|
248
|
+
} else {
|
|
249
|
+
return 2; // Cooling
|
|
250
|
+
}
|
|
251
|
+
}
|
|
252
|
+
|
|
253
|
+
async getTargetHeatingCoolingState() {
|
|
254
|
+
return this.getCurrentHeatingCoolingState();
|
|
255
|
+
}
|
|
256
|
+
|
|
257
|
+
async setTargetHeatingCoolingState(value) {
|
|
258
|
+
if (value === 0) {
|
|
259
|
+
await this.setActive(0); // Turn off the fan
|
|
260
|
+
} else {
|
|
261
|
+
await this.setActive(1); // Turn on the fan
|
|
262
|
+
}
|
|
263
|
+
}
|
|
264
|
+
|
|
254
265
|
// Humidity sensor method
|
|
255
266
|
async getCurrentRelativeHumidity() {
|
|
256
267
|
const url = `http://${this.config.ip}/mread?{"${this.PARAM_IDS.HUMIDITY}":1}`;
|
|
@@ -274,7 +285,6 @@ class SystemairVentilator {
|
|
|
274
285
|
return [
|
|
275
286
|
this.fanService,
|
|
276
287
|
this.refreshService,
|
|
277
|
-
this.timerService,
|
|
278
288
|
this.thermostatService,
|
|
279
289
|
this.humiditySensorService,
|
|
280
290
|
];
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@lv426/homebridge-systemair-enhanced",
|
|
3
|
-
"version": "1.0.
|
|
4
|
-
"description": "An enhanced Homebridge plugin for controlling
|
|
3
|
+
"version": "1.0.2",
|
|
4
|
+
"description": "An enhanced Homebridge plugin for controlling Systemair Ventilators.",
|
|
5
5
|
"main": "index.js",
|
|
6
6
|
"scripts": {
|
|
7
7
|
"test": "echo \"Error: no test specified\" && exit 1"
|