homebridge-tasmota-control 1.4.0-beta.32 → 1.4.0-beta.34
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 +29 -26
- package/package.json +1 -1
- package/src/deviceinfo.js +1 -1
- package/src/fans.js +3 -2
- package/src/lights.js +3 -2
- package/src/mielhvac.js +3 -2
- package/src/switches.js +3 -2
package/index.js
CHANGED
|
@@ -6,7 +6,7 @@ import switches from './src/switches.js';
|
|
|
6
6
|
import lights from './src/lights.js';
|
|
7
7
|
import fans from './src/fans.js';
|
|
8
8
|
import ImpulseGenerator from './src/impulsegenerator.js';
|
|
9
|
-
import { PluginName, PlatformName
|
|
9
|
+
import { PluginName, PlatformName } from './src/constants.js';
|
|
10
10
|
|
|
11
11
|
class tasmotaPlatform {
|
|
12
12
|
constructor(log, config, api) {
|
|
@@ -43,11 +43,11 @@ class tasmotaPlatform {
|
|
|
43
43
|
}
|
|
44
44
|
|
|
45
45
|
//log config
|
|
46
|
-
const loadNameFromDevice = deviceConfig.loadNameFromDevice || false;
|
|
47
|
-
const auth = deviceConfig.auth || false;
|
|
48
46
|
const url = `http://${host}/cm?cmnd=`;
|
|
47
|
+
const auth = deviceConfig.auth || false;
|
|
49
48
|
const user = deviceConfig.user || '';
|
|
50
49
|
const passwd = deviceConfig.passwd || '';
|
|
50
|
+
const loadNameFromDevice = deviceConfig.loadNameFromDevice || false;
|
|
51
51
|
const refreshInterval = deviceConfig.refreshInterval * 1000 || 5000;
|
|
52
52
|
const enableDebugMode = deviceConfig.enableDebugMode || false;
|
|
53
53
|
const disableLogDeviceInfo = deviceConfig.disableLogDeviceInfo || false;
|
|
@@ -63,28 +63,6 @@ class tasmotaPlatform {
|
|
|
63
63
|
};
|
|
64
64
|
const debug1 = !enableDebugMode ? false : log.info(`Device: ${host} ${deviceName}, Config: ${JSON.stringify(newConfig, null, 2)}.`);
|
|
65
65
|
|
|
66
|
-
//check files exists, if not then create it
|
|
67
|
-
const postFix = deviceConfig.host.split('.').join('');
|
|
68
|
-
const defaultHeatingSetTemperatureFile = `${prefDir}/defaultHeatingSetTemperature_${postFix}`;
|
|
69
|
-
const defaultCoolingSetTemperatureFile = `${prefDir}/defaultCoolingSetTemperature_${postFix}`;
|
|
70
|
-
|
|
71
|
-
try {
|
|
72
|
-
const files = [
|
|
73
|
-
defaultHeatingSetTemperatureFile,
|
|
74
|
-
defaultCoolingSetTemperatureFile
|
|
75
|
-
];
|
|
76
|
-
|
|
77
|
-
files.forEach((file, index) => {
|
|
78
|
-
if (!existsSync(file)) {
|
|
79
|
-
const data = ['20', '23'][index]
|
|
80
|
-
writeFileSync(file, data);
|
|
81
|
-
}
|
|
82
|
-
});
|
|
83
|
-
} catch (error) {
|
|
84
|
-
log.error(`Device: ${host} ${deviceName}, Prepare files error: ${error}`);
|
|
85
|
-
return;
|
|
86
|
-
}
|
|
87
|
-
|
|
88
66
|
try {
|
|
89
67
|
//get device info
|
|
90
68
|
const deviceInfo = new deviceinfo(url, auth, user, passwd, deviceName, loadNameFromDevice, enableDebugMode, refreshInterval);
|
|
@@ -104,11 +82,33 @@ class tasmotaPlatform {
|
|
|
104
82
|
return;
|
|
105
83
|
}
|
|
106
84
|
|
|
107
|
-
log.warn(info.deviceType);
|
|
108
85
|
let device;
|
|
109
86
|
switch (info.deviceType) {
|
|
110
87
|
case 0://mielhvac
|
|
88
|
+
//check files exists, if not then create it
|
|
89
|
+
const postFix = deviceConfig.host.split('.').join('');
|
|
90
|
+
const defaultHeatingSetTemperatureFile = `${prefDir}/defaultHeatingSetTemperature_${postFix}`;
|
|
91
|
+
const defaultCoolingSetTemperatureFile = `${prefDir}/defaultCoolingSetTemperature_${postFix}`;
|
|
92
|
+
|
|
93
|
+
try {
|
|
94
|
+
const files = [
|
|
95
|
+
defaultHeatingSetTemperatureFile,
|
|
96
|
+
defaultCoolingSetTemperatureFile
|
|
97
|
+
];
|
|
98
|
+
|
|
99
|
+
files.forEach((file, index) => {
|
|
100
|
+
if (!existsSync(file)) {
|
|
101
|
+
const data = ['20', '23'][index]
|
|
102
|
+
writeFileSync(file, data);
|
|
103
|
+
}
|
|
104
|
+
});
|
|
105
|
+
} catch (error) {
|
|
106
|
+
log.error(`Device: ${host} ${deviceName}, Prepare files error: ${error}`);
|
|
107
|
+
return;
|
|
108
|
+
}
|
|
109
|
+
|
|
111
110
|
device = new mielhvac(api, deviceConfig, info, refreshInterval, defaultHeatingSetTemperatureFile, defaultCoolingSetTemperatureFile);
|
|
111
|
+
break;
|
|
112
112
|
case 1://switches
|
|
113
113
|
device = new switches(api, deviceConfig, info, refreshInterval);
|
|
114
114
|
break;
|
|
@@ -118,6 +118,9 @@ class tasmotaPlatform {
|
|
|
118
118
|
case 3://fans
|
|
119
119
|
device = new fans(api, deviceConfig, info, refreshInterval);
|
|
120
120
|
break;
|
|
121
|
+
default:
|
|
122
|
+
const emitLog = disableLogWarn ? false : log.warn(`Device: ${host} ${deviceName}, unknown device: ${info.deviceType}.`);
|
|
123
|
+
return;
|
|
121
124
|
}
|
|
122
125
|
|
|
123
126
|
device.on('publishAccessory', (accessory) => {
|
package/package.json
CHANGED
package/src/deviceinfo.js
CHANGED
package/src/fans.js
CHANGED
|
@@ -343,7 +343,7 @@ class Fans extends EventEmitter {
|
|
|
343
343
|
}
|
|
344
344
|
}
|
|
345
345
|
|
|
346
|
-
deviceInfo() {
|
|
346
|
+
async deviceInfo() {
|
|
347
347
|
this.emit('devInfo', `----- ${this.info.deviceName} -----`);
|
|
348
348
|
this.emit('devInfo', `Manufacturer: Tasmota`);
|
|
349
349
|
this.emit('devInfo', `Hardware: ${this.info.modelName}`);
|
|
@@ -352,6 +352,7 @@ class Fans extends EventEmitter {
|
|
|
352
352
|
this.emit('devInfo', `Relays: ${this.info.relaysCount}`);
|
|
353
353
|
this.emit('devInfo', `Sensors: ${this.sensorsCount}`);
|
|
354
354
|
this.emit('devInfo', `----------------------------------`);
|
|
355
|
+
return;
|
|
355
356
|
}
|
|
356
357
|
|
|
357
358
|
//prepare accessory
|
|
@@ -695,7 +696,7 @@ class Fans extends EventEmitter {
|
|
|
695
696
|
this.emit('success', `Connect Success`)
|
|
696
697
|
|
|
697
698
|
//check device info
|
|
698
|
-
const devInfo = !this.disableLogDeviceInfo ? this.deviceInfo() : false;
|
|
699
|
+
const devInfo = !this.disableLogDeviceInfo ? await this.deviceInfo() : false;
|
|
699
700
|
|
|
700
701
|
//start prepare accessory
|
|
701
702
|
if (this.startPrepareAccessory) {
|
package/src/lights.js
CHANGED
|
@@ -359,7 +359,7 @@ class Lights extends EventEmitter {
|
|
|
359
359
|
}
|
|
360
360
|
}
|
|
361
361
|
|
|
362
|
-
deviceInfo() {
|
|
362
|
+
async deviceInfo() {
|
|
363
363
|
this.emit('devInfo', `----- ${this.info.deviceName} -----`);
|
|
364
364
|
this.emit('devInfo', `Manufacturer: Tasmota`);
|
|
365
365
|
this.emit('devInfo', `Hardware: ${this.info.modelName}`);
|
|
@@ -368,6 +368,7 @@ class Lights extends EventEmitter {
|
|
|
368
368
|
this.emit('devInfo', `Relays: ${this.info.relaysCount}`);
|
|
369
369
|
this.emit('devInfo', `Sensors: ${this.sensorsCount}`);
|
|
370
370
|
this.emit('devInfo', `----------------------------------`);
|
|
371
|
+
return;
|
|
371
372
|
}
|
|
372
373
|
|
|
373
374
|
//prepare accessory
|
|
@@ -716,7 +717,7 @@ class Lights extends EventEmitter {
|
|
|
716
717
|
this.emit('success', `Connect Success`)
|
|
717
718
|
|
|
718
719
|
//check device info
|
|
719
|
-
const devInfo = !this.disableLogDeviceInfo ? this.deviceInfo() : false;
|
|
720
|
+
const devInfo = !this.disableLogDeviceInfo ? await this.deviceInfo() : false;
|
|
720
721
|
|
|
721
722
|
//start prepare accessory
|
|
722
723
|
if (this.startPrepareAccessory) {
|
package/src/mielhvac.js
CHANGED
|
@@ -811,7 +811,7 @@ class MiElHvac extends EventEmitter {
|
|
|
811
811
|
}
|
|
812
812
|
}
|
|
813
813
|
|
|
814
|
-
deviceInfo() {
|
|
814
|
+
async deviceInfo() {
|
|
815
815
|
this.emit('devInfo', `----- ${this.info.deviceName} -----`);
|
|
816
816
|
this.emit('devInfo', `Manufacturer: Tasmota`);
|
|
817
817
|
this.emit('devInfo', `Hardware: ${this.info.modelName}`);
|
|
@@ -819,6 +819,7 @@ class MiElHvac extends EventEmitter {
|
|
|
819
819
|
this.emit('devInfo', `Firmware: ${this.info.firmwareRevision}`);
|
|
820
820
|
this.emit('devInfo', `Sensor: MiELHVAC`);
|
|
821
821
|
this.emit('devInfo', `----------------------------------`);
|
|
822
|
+
return;
|
|
822
823
|
}
|
|
823
824
|
|
|
824
825
|
//prepare accessory
|
|
@@ -1380,7 +1381,7 @@ class MiElHvac extends EventEmitter {
|
|
|
1380
1381
|
this.emit('success', `Connect Success`)
|
|
1381
1382
|
|
|
1382
1383
|
//check device info
|
|
1383
|
-
const devInfo = !this.disableLogDeviceInfo ? this.deviceInfo() : false;
|
|
1384
|
+
const devInfo = !this.disableLogDeviceInfo ? await this.deviceInfo() : false;
|
|
1384
1385
|
|
|
1385
1386
|
//start prepare accessory
|
|
1386
1387
|
if (this.startPrepareAccessory) {
|
package/src/switches.js
CHANGED
|
@@ -312,7 +312,7 @@ class Switches extends EventEmitter {
|
|
|
312
312
|
}
|
|
313
313
|
}
|
|
314
314
|
|
|
315
|
-
deviceInfo() {
|
|
315
|
+
async deviceInfo() {
|
|
316
316
|
this.emit('devInfo', `----- ${this.info.deviceName} -----`);
|
|
317
317
|
this.emit('devInfo', `Manufacturer: Tasmota`);
|
|
318
318
|
this.emit('devInfo', `Hardware: ${this.info.modelName}`);
|
|
@@ -321,6 +321,7 @@ class Switches extends EventEmitter {
|
|
|
321
321
|
this.emit('devInfo', `Relays: ${this.info.relaysCount}`);
|
|
322
322
|
this.emit('devInfo', `Sensors: ${this.sensorsCount}`);
|
|
323
323
|
this.emit('devInfo', `----------------------------------`);
|
|
324
|
+
return;
|
|
324
325
|
}
|
|
325
326
|
|
|
326
327
|
//prepare accessory
|
|
@@ -605,7 +606,7 @@ class Switches extends EventEmitter {
|
|
|
605
606
|
this.emit('success', `Connect Success`)
|
|
606
607
|
|
|
607
608
|
//check device info
|
|
608
|
-
const devInfo = !this.disableLogDeviceInfo ? this.deviceInfo() : false;
|
|
609
|
+
const devInfo = !this.disableLogDeviceInfo ? await this.deviceInfo() : false;
|
|
609
610
|
|
|
610
611
|
//start prepare accessory
|
|
611
612
|
if (this.startPrepareAccessory) {
|