homebridge-tasmota-control 1.5.1-beta.0 → 1.5.1-beta.10

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
@@ -70,6 +70,9 @@ class tasmotaPlatform {
70
70
  deviceInfo.on('debug', (debug) => {
71
71
  const emitLog = !enableDebugMode ? false : log.info(`Device: ${host} ${deviceName}, debug: ${debug}.`);
72
72
  })
73
+ .on('debug', (debug) => {
74
+ const emitLog = enableDebugMode ? false : log.info(`Device: ${host} ${deviceName}, debug: ${debug}.`);
75
+ })
73
76
  .on('warn', (warn) => {
74
77
  const emitLog = disableLogWarn ? false : log.warn(`Device: ${host} ${deviceName}, ${warn}.`);
75
78
  })
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "displayName": "Tasmota Control",
3
3
  "name": "homebridge-tasmota-control",
4
- "version": "1.5.1-beta.0",
4
+ "version": "1.5.1-beta.10",
5
5
  "description": "Homebridge plugin to control Tasmota flashed devices.",
6
6
  "license": "MIT",
7
7
  "author": "grzegorz914",
package/src/deviceinfo.js CHANGED
@@ -54,6 +54,11 @@ class DeviceInfo extends EventEmitter {
54
54
  //status SNS
55
55
  const statusSns = deviceInfo.StatusSNS ?? {};
56
56
  const statusSnsKeys = Object.keys(statusSns);
57
+ const sensorName = Object.entries(statusSns)
58
+ .filter(([key]) => SensorKeys.some(type => key.includes(type)))
59
+ .reduce((obj, [key, value]) => {
60
+ return key;
61
+ }, {});
57
62
 
58
63
  //status STS
59
64
  const statusSts = deviceInfo.StatusSTS ?? {};
@@ -69,11 +74,13 @@ class DeviceInfo extends EventEmitter {
69
74
  const obj = {
70
75
  deviceTypes: types,
71
76
  deviceName: deviceName,
77
+ sensorName: sensorName,
72
78
  friendlyNames: friendlyNames,
73
79
  modelName: modelName,
74
80
  serialNumber: addressMac,
75
81
  firmwareRevision: firmwareRevision
76
82
  };
83
+ this.emit('debug', `Sensor: ${JSON.stringify(obj, null, 2)}`)
77
84
  return obj;
78
85
  } catch (error) {
79
86
  throw new Error(`Check info error: ${error}`);
package/src/sensors.js CHANGED
@@ -87,23 +87,22 @@ class Sensors extends EventEmitter {
87
87
  //status SNS
88
88
  if (statusSnsSupported) {
89
89
  this.sensors = [];
90
- const sensor = Object.entries(statusSns)
90
+ const sensorData = Object.entries(statusSns)
91
91
  .filter(([key]) => SensorKeys.some(type => key.includes(type)))
92
92
  .reduce((obj, [key, value]) => {
93
93
  obj[key] = value;
94
94
  return obj;
95
95
  }, {});
96
96
 
97
- for (const [key, value] of Object.entries(sensor)) {
97
+ for (const [key, value] of Object.entries(sensorData)) {
98
98
  const sensorData = value;
99
99
 
100
100
  //sensor
101
101
  const obj = {
102
102
  name: key,
103
103
  time: sensorStatus.Time,
104
- tempUnit: sensorStatus.TempUnit === 'C' ? '°C' : 'F',
105
- pressureUnit: sensorStatus.PressureUnit ?? 'hPa',
106
-
104
+ tempUnit: sensorStatus.TempUnit,
105
+ pressureUnit: sensorStatus.PressureUnit,
107
106
  temperature: sensorData.Temperature,
108
107
  referenceTemperature: sensorData.ReferenceTemperature,
109
108
  objTemperature: sensorData.OBJTMP,
@@ -114,7 +113,10 @@ class Sensors extends EventEmitter {
114
113
  gas: sensorData.Gas,
115
114
  carbonDioxyde: sensorData.CarbonDioxyde,
116
115
  ambientLight: sensorData.Ambient,
117
- motion: sensorData.Motion === 'ON',
116
+ motion: sensorData.Motion
117
+ }
118
+ if (obj.tempUnit === 'C') {
119
+ obj.tempUnit = '°C';
118
120
  }
119
121
 
120
122
  //energy
@@ -132,11 +134,11 @@ class Sensors extends EventEmitter {
132
134
  current: sensorData.Current,
133
135
  load: sensorData.Load,
134
136
  }
135
- obj = key === 'ENERGY' ? { ...obj, ...obj1 } : obj;
136
- this.emit('debug', `Sensors status: ${JSON.stringify(obj, null, 2)}`)
137
+ const sensor = key === 'ENERGY' ? { ...obj, ...obj1 } : obj;
138
+ this.emit('debug', `Sensors status: ${JSON.stringify(sensor, null, 2)}`)
137
139
 
138
140
  //push to array
139
- this.sensors.push(obj);
141
+ this.sensors.push(sensor);
140
142
  }
141
143
  this.sensorsCount = this.sensors.length;
142
144