homebridge-tasmota-control 1.4.0-beta.33 → 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 CHANGED
@@ -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,10 +82,31 @@ 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);
112
111
  break;
113
112
  case 1://switches
@@ -119,6 +118,9 @@ class tasmotaPlatform {
119
118
  case 3://fans
120
119
  device = new fans(api, deviceConfig, info, refreshInterval);
121
120
  break;
121
+ default:
122
+ const emitLog = disableLogWarn ? false : log.warn(`Device: ${host} ${deviceName}, unknown device: ${info.deviceType}.`);
123
+ return;
122
124
  }
123
125
 
124
126
  device.on('publishAccessory', (accessory) => {
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "displayName": "Tasmota Control",
3
3
  "name": "homebridge-tasmota-control",
4
- "version": "1.4.0-beta.33",
4
+ "version": "1.4.0-beta.34",
5
5
  "description": "Homebridge plugin to control Tasmota flashed devices.",
6
6
  "license": "MIT",
7
7
  "author": "grzegorz914",
package/src/deviceinfo.js CHANGED
@@ -67,7 +67,7 @@ class DeviceInfo extends EventEmitter {
67
67
  serialNumber: addressMac,
68
68
  firmwareRevision: firmwareRevision,
69
69
  relaysCount: friendlyNames.length
70
- }
70
+ };
71
71
  return obj;
72
72
  } catch (error) {
73
73
  throw new Error(`Check info error: ${error}`);
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) {