homebridge-tasmota-control 1.6.15-beta.32 → 1.6.15-beta.33
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 +31 -27
- package/package.json +1 -1
- package/src/fans.js +0 -1
- package/src/lights.js +0 -1
- package/src/mielhvac.js +0 -1
- package/src/sensors.js +0 -1
- package/src/switches.js +0 -1
package/index.js
CHANGED
|
@@ -39,7 +39,7 @@ class tasmotaPlatform {
|
|
|
39
39
|
const host = device.host;
|
|
40
40
|
if (!deviceName || !host) {
|
|
41
41
|
log.warn(`Device Name: ${deviceName ? 'OK' : deviceName}, host: ${host ? 'OK' : host}, in config wrong or missing.`);
|
|
42
|
-
|
|
42
|
+
continue;
|
|
43
43
|
}
|
|
44
44
|
|
|
45
45
|
//log config
|
|
@@ -48,7 +48,7 @@ class tasmotaPlatform {
|
|
|
48
48
|
const user = device.user || '';
|
|
49
49
|
const passwd = device.passwd || '';
|
|
50
50
|
const loadNameFromDevice = device.loadNameFromDevice || false;
|
|
51
|
-
const refreshInterval = device.refreshInterval * 1000
|
|
51
|
+
const refreshInterval = Number.isInteger(device.refreshInterval) && device.refreshInterval > 0 ? device.refreshInterval * 1000 : 5000;
|
|
52
52
|
const enableDebugMode = device.enableDebugMode || false;
|
|
53
53
|
const logLevel = {
|
|
54
54
|
debug: device.enableDebugMode,
|
|
@@ -77,37 +77,39 @@ class tasmotaPlatform {
|
|
|
77
77
|
const info = await deviceInfo.getInfo();
|
|
78
78
|
if (!info.serialNumber) {
|
|
79
79
|
log.warn(`Device: ${host} ${deviceName}, serial not found.`);
|
|
80
|
-
|
|
80
|
+
continue;
|
|
81
81
|
}
|
|
82
82
|
|
|
83
83
|
let i = 0;
|
|
84
84
|
for (const type of info.deviceTypes) {
|
|
85
85
|
const serialNumber = i === 0 ? info.serialNumber : `${info.serialNumber}${i}`;
|
|
86
86
|
|
|
87
|
+
//check files exists, if not then create it
|
|
88
|
+
if (type === 0) {
|
|
89
|
+
try {
|
|
90
|
+
const postFix = device.host.split('.').join('');
|
|
91
|
+
info.defaultHeatingSetTemperatureFile = `${prefDir}/defaultHeatingSetTemperature_${postFix}`;
|
|
92
|
+
info.defaultCoolingSetTemperatureFile = `${prefDir}/defaultCoolingSetTemperature_${postFix}`;
|
|
93
|
+
const files = [
|
|
94
|
+
info.defaultHeatingSetTemperatureFile,
|
|
95
|
+
info.defaultCoolingSetTemperatureFile
|
|
96
|
+
];
|
|
97
|
+
|
|
98
|
+
files.forEach((file, index) => {
|
|
99
|
+
if (!existsSync(file)) {
|
|
100
|
+
const data = ['20', '23'][index];
|
|
101
|
+
writeFileSync(file, data);
|
|
102
|
+
}
|
|
103
|
+
});
|
|
104
|
+
} catch (error) {
|
|
105
|
+
if (logLevel.error) log.error(`Device: ${host} ${deviceName}, Prepare files error: ${error}`);
|
|
106
|
+
continue;
|
|
107
|
+
}
|
|
108
|
+
}
|
|
109
|
+
|
|
87
110
|
let deviceType;
|
|
88
111
|
switch (type) {
|
|
89
112
|
case 0: //mielhvac
|
|
90
|
-
//check files exists, if not then create it
|
|
91
|
-
try {
|
|
92
|
-
const postFix = device.host.split('.').join('');
|
|
93
|
-
info.defaultHeatingSetTemperatureFile = `${prefDir}/defaultHeatingSetTemperature_${postFix}`;
|
|
94
|
-
info.defaultCoolingSetTemperatureFile = `${prefDir}/defaultCoolingSetTemperature_${postFix}`;
|
|
95
|
-
const files = [
|
|
96
|
-
info.defaultHeatingSetTemperatureFile,
|
|
97
|
-
info.defaultCoolingSetTemperatureFile
|
|
98
|
-
];
|
|
99
|
-
|
|
100
|
-
files.forEach((file, index) => {
|
|
101
|
-
if (!existsSync(file)) {
|
|
102
|
-
const data = ['20', '23'][index]
|
|
103
|
-
writeFileSync(file, data);
|
|
104
|
-
}
|
|
105
|
-
});
|
|
106
|
-
} catch (error) {
|
|
107
|
-
if (logLevel.error) log.error(`Device: ${host} ${deviceName}, Prepare files error: ${error}`);
|
|
108
|
-
return;
|
|
109
|
-
}
|
|
110
|
-
|
|
111
113
|
deviceType = new MiElHvac(api, device, info, serialNumber, refreshInterval);
|
|
112
114
|
break;
|
|
113
115
|
case 1: //switches
|
|
@@ -124,7 +126,7 @@ class tasmotaPlatform {
|
|
|
124
126
|
break;
|
|
125
127
|
default:
|
|
126
128
|
if (logLevel.warn) log.warn(`Device: ${host} ${deviceName}, unknown device: ${info.deviceTypes}.`);
|
|
127
|
-
|
|
129
|
+
continue;
|
|
128
130
|
}
|
|
129
131
|
|
|
130
132
|
deviceType.on('devInfo', (msg) => logLevel.devInfo && log.info(msg))
|
|
@@ -138,7 +140,7 @@ class tasmotaPlatform {
|
|
|
138
140
|
const impulseGenerator = new ImpulseGenerator()
|
|
139
141
|
.on('start', async () => {
|
|
140
142
|
try {
|
|
141
|
-
const accessory = await deviceType.start()
|
|
143
|
+
const accessory = await deviceType.start();
|
|
142
144
|
if (accessory) {
|
|
143
145
|
api.publishExternalAccessories(PluginName, [accessory]);
|
|
144
146
|
if (logLevel.success) log.success(`Device: ${host} ${deviceName}, Published as external accessory.`);
|
|
@@ -160,6 +162,8 @@ class tasmotaPlatform {
|
|
|
160
162
|
} catch (error) {
|
|
161
163
|
if (logLevel.error) log.error(`Device: ${host} ${deviceName}, Did finish launching error: ${error}.`);
|
|
162
164
|
}
|
|
165
|
+
|
|
166
|
+
await new Promise(resolve => setTimeout(resolve, 300));
|
|
163
167
|
}
|
|
164
168
|
});
|
|
165
169
|
}
|
|
@@ -172,4 +176,4 @@ class tasmotaPlatform {
|
|
|
172
176
|
export default (api) => {
|
|
173
177
|
CustomCharacteristics(api);
|
|
174
178
|
api.registerPlatform(PluginName, PlatformName, tasmotaPlatform);
|
|
175
|
-
}
|
|
179
|
+
}
|
package/package.json
CHANGED
package/src/fans.js
CHANGED
package/src/lights.js
CHANGED
package/src/mielhvac.js
CHANGED
package/src/sensors.js
CHANGED
package/src/switches.js
CHANGED