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.
Files changed (2) hide show
  1. package/index.js +23 -23
  2. 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 deviceConfig of config.devices) {
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 = deviceConfig.name;
39
- const host = deviceConfig.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 = deviceConfig.auth || false;
48
- const user = deviceConfig.user || '';
49
- const passwd = deviceConfig.passwd || '';
50
- const loadNameFromDevice = deviceConfig.loadNameFromDevice || false;
51
- const refreshInterval = deviceConfig.refreshInterval * 1000 || 5000;
52
- const enableDebugMode = deviceConfig.enableDebugMode || false;
53
- const disableLogDeviceInfo = deviceConfig.disableLogDeviceInfo || false;
54
- const disableLogInfo = deviceConfig.disableLogInfo || false;
55
- const disableLogSuccess = deviceConfig.disableLogSuccess || false;
56
- const disableLogWarn = deviceConfig.disableLogWarn || false;
57
- const disableLogError = deviceConfig.disableLogError || false;
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
- ...deviceConfig,
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 device;
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
- device = new mielhvac(api, deviceConfig, info, refreshInterval, defaultHeatingSetTemperatureFile, defaultCoolingSetTemperatureFile);
110
+ deviceType = new mielhvac(api, device, info, refreshInterval, defaultHeatingSetTemperatureFile, defaultCoolingSetTemperatureFile);
111
111
  break;
112
112
  case 1://switches
113
- device = new switches(api, deviceConfig, info, refreshInterval);
113
+ deviceType = new switches(api, device, info, refreshInterval);
114
114
  break;
115
115
  case 2://lights
116
- device = new lights(api, deviceConfig, info, refreshInterval);
116
+ deviceType = new lights(api, device, info, refreshInterval);
117
117
  break;
118
118
  case 3://fans
119
- device = new fans(api, deviceConfig, info, refreshInterval);
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
- device.on('publishAccessory', (accessory) => {
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 device.start();
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 device.startImpulseGenerator() : false
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
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "displayName": "Tasmota Control",
3
3
  "name": "homebridge-tasmota-control",
4
- "version": "1.4.0-beta.34",
4
+ "version": "1.4.0-beta.35",
5
5
  "description": "Homebridge plugin to control Tasmota flashed devices.",
6
6
  "license": "MIT",
7
7
  "author": "grzegorz914",