homebridge-tasmota-control 1.4.0-beta.34 → 1.4.0-beta.35
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 +23 -23
- package/package.json +1 -1
package/index.js
CHANGED
|
@@ -27,7 +27,7 @@ class tasmotaPlatform {
|
|
|
27
27
|
}
|
|
28
28
|
|
|
29
29
|
api.on('didFinishLaunching', async () => {
|
|
30
|
-
for (const
|
|
30
|
+
for (const device of config.devices) {
|
|
31
31
|
|
|
32
32
|
//check accessory is enabled
|
|
33
33
|
const disableAccessory = deviceConfig.disableAccessory || false;
|
|
@@ -35,8 +35,8 @@ class tasmotaPlatform {
|
|
|
35
35
|
continue;
|
|
36
36
|
}
|
|
37
37
|
|
|
38
|
-
const deviceName =
|
|
39
|
-
const host =
|
|
38
|
+
const deviceName = device.name;
|
|
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
|
return;
|
|
@@ -44,20 +44,20 @@ class tasmotaPlatform {
|
|
|
44
44
|
|
|
45
45
|
//log config
|
|
46
46
|
const url = `http://${host}/cm?cmnd=`;
|
|
47
|
-
const auth =
|
|
48
|
-
const user =
|
|
49
|
-
const passwd =
|
|
50
|
-
const loadNameFromDevice =
|
|
51
|
-
const refreshInterval =
|
|
52
|
-
const enableDebugMode =
|
|
53
|
-
const disableLogDeviceInfo =
|
|
54
|
-
const disableLogInfo =
|
|
55
|
-
const disableLogSuccess =
|
|
56
|
-
const disableLogWarn =
|
|
57
|
-
const disableLogError =
|
|
47
|
+
const auth = device.auth || false;
|
|
48
|
+
const user = device.user || '';
|
|
49
|
+
const passwd = device.passwd || '';
|
|
50
|
+
const loadNameFromDevice = device.loadNameFromDevice || false;
|
|
51
|
+
const refreshInterval = device.refreshInterval * 1000 || 5000;
|
|
52
|
+
const enableDebugMode = device.enableDebugMode || false;
|
|
53
|
+
const disableLogDeviceInfo = device.disableLogDeviceInfo || false;
|
|
54
|
+
const disableLogInfo = device.disableLogInfo || false;
|
|
55
|
+
const disableLogSuccess = device.disableLogSuccess || false;
|
|
56
|
+
const disableLogWarn = device.disableLogWarn || false;
|
|
57
|
+
const disableLogError = device.disableLogError || false;
|
|
58
58
|
const debug = enableDebugMode ? log.info(`Device: ${host} ${deviceName}, debug: Did finish launching.`) : false;
|
|
59
59
|
const newConfig = {
|
|
60
|
-
...
|
|
60
|
+
...device,
|
|
61
61
|
user: 'removed',
|
|
62
62
|
passwd: 'removed'
|
|
63
63
|
};
|
|
@@ -82,7 +82,7 @@ class tasmotaPlatform {
|
|
|
82
82
|
return;
|
|
83
83
|
}
|
|
84
84
|
|
|
85
|
-
let
|
|
85
|
+
let deviceType;
|
|
86
86
|
switch (info.deviceType) {
|
|
87
87
|
case 0://mielhvac
|
|
88
88
|
//check files exists, if not then create it
|
|
@@ -107,23 +107,23 @@ class tasmotaPlatform {
|
|
|
107
107
|
return;
|
|
108
108
|
}
|
|
109
109
|
|
|
110
|
-
|
|
110
|
+
deviceType = new mielhvac(api, device, info, refreshInterval, defaultHeatingSetTemperatureFile, defaultCoolingSetTemperatureFile);
|
|
111
111
|
break;
|
|
112
112
|
case 1://switches
|
|
113
|
-
|
|
113
|
+
deviceType = new switches(api, device, info, refreshInterval);
|
|
114
114
|
break;
|
|
115
115
|
case 2://lights
|
|
116
|
-
|
|
116
|
+
deviceType = new lights(api, device, info, refreshInterval);
|
|
117
117
|
break;
|
|
118
118
|
case 3://fans
|
|
119
|
-
|
|
119
|
+
deviceType = new fans(api, device, info, refreshInterval);
|
|
120
120
|
break;
|
|
121
121
|
default:
|
|
122
122
|
const emitLog = disableLogWarn ? false : log.warn(`Device: ${host} ${deviceName}, unknown device: ${info.deviceType}.`);
|
|
123
123
|
return;
|
|
124
124
|
}
|
|
125
125
|
|
|
126
|
-
|
|
126
|
+
deviceType.on('publishAccessory', (accessory) => {
|
|
127
127
|
api.publishExternalAccessories(PluginName, [accessory]);
|
|
128
128
|
const emitLog = disableLogSuccess ? false : log.success(`Device: ${host} ${deviceName}, Published as external accessory.`);
|
|
129
129
|
})
|
|
@@ -150,11 +150,11 @@ class tasmotaPlatform {
|
|
|
150
150
|
const impulseGenerator = new ImpulseGenerator();
|
|
151
151
|
impulseGenerator.on('start', async () => {
|
|
152
152
|
try {
|
|
153
|
-
const startDone = await
|
|
153
|
+
const startDone = await deviceType.start();
|
|
154
154
|
const stopImpulseGenerator = startDone ? await impulseGenerator.stop() : false;
|
|
155
155
|
|
|
156
156
|
//start impulse generator
|
|
157
|
-
const startImpulseGenerator = stopImpulseGenerator ? await
|
|
157
|
+
const startImpulseGenerator = stopImpulseGenerator ? await deviceType.startImpulseGenerator() : false
|
|
158
158
|
} catch (error) {
|
|
159
159
|
const emitLog = disableLogError ? false : log.error(`Device: ${host} ${deviceName}, ${error}, trying again.`);
|
|
160
160
|
}
|
package/package.json
CHANGED