homebridge-tasmota-control 1.6.2-beta.0 → 1.6.2-beta.2

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/package.json +1 -1
  2. package/src/sensors.js +29 -32
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "displayName": "Tasmota Control",
3
3
  "name": "homebridge-tasmota-control",
4
- "version": "1.6.2-beta.0",
4
+ "version": "1.6.2-beta.2",
5
5
  "description": "Homebridge plugin to control Tasmota flashed devices.",
6
6
  "license": "MIT",
7
7
  "author": "grzegorz914",
package/src/sensors.js CHANGED
@@ -114,13 +114,25 @@ class Sensors extends EventEmitter {
114
114
  gas: sensorData.Gas,
115
115
  carbonDioxyde: sensorData.CarbonDioxyde,
116
116
  ambientLight: sensorData.Ambient,
117
- motion: sensorData.Motion
117
+ motion: sensorData.Motion,
118
+ power: sensorData.Power,
119
+ apparentPower: sensorData.ApparentPower,
120
+ reactivePower: sensorData.ReactivePower,
121
+ energyToday: sensorData.Today,
122
+ energyLastDay: sensorData.Yesterday,
123
+ energyLifetime: sensorData.Total,
124
+ energyLifeTimeStartTime: sensorData.TotalStartTime,
125
+ energyPeriod: sensorData.Period,
126
+ current: sensorData.Current,
127
+ voltage: sensorData.Voltage,
128
+ factor: sensorData.Factor,
129
+ frequency: sensorData.Frequency,
130
+ load: sensorData.Load
118
131
  }
119
132
  if (obj.tempUnit === 'C') {
120
133
  obj.tempUnit = '°C';
121
134
  }
122
135
 
123
- this.emit('warn', `Sensors status: ${JSON.stringify(obj, null, 2)}`)
124
136
  //update characteristics
125
137
  this.sensorTemperatureServices?.[i]?.Characteristic?.CurrentTemperature?.updateCharacteristic(Characteristic.CurrentTemperature, obj.temperature);
126
138
  this.sensorReferenceTemperatureServices?.[i]?.Characteristic?.CurrentTemperature?.updateCharacteristic(Characteristic.CurrentTemperature, obj.referenceTemperature);
@@ -136,42 +148,27 @@ class Sensors extends EventEmitter {
136
148
 
137
149
  //energy
138
150
  const isEnergy = key === 'ENERGY';
139
- const energy = {
140
- power: sensorData.Power,
141
- apparentPower: sensorData.ApparentPower,
142
- reactivePower: sensorData.ReactivePower,
143
- energyToday: sensorData.Today,
144
- energyLastDay: sensorData.Yesterday,
145
- energyLifetime: sensorData.Total,
146
- energyLifeTimeStartTime: sensorData.TotalStartTime,
147
- energyPeriod: sensorData.Period,
148
- current: sensorData.Current,
149
- voltage: sensorData.Voltage,
150
- factor: sensorData.Factor,
151
- frequency: sensorData.Frequency,
152
- load: sensorData.Load,
153
- }
154
-
155
151
  if (isEnergy) {
152
+ this.emit('warn', `Energy: ${JSON.stringify(obj, null, 2)}`)
156
153
  //update characteristics
157
- this.sensorEnergyServices?.[i]?.Characteristic?.Power?.updateCharacteristic(Characteristic.Power, energy.power);
158
- this.sensorEnergyServices?.[i]?.Characteristic?.ApparentPower?.updateCharacteristic(Characteristic.ApparentPower, energy.apparentPower);
159
- this.sensorEnergyServices?.[i]?.Characteristic?.ReactivePower?.updateCharacteristic(Characteristic.ReactivePower, energy.reactivePower);
160
- this.sensorEnergyServices?.[i]?.Characteristic?.EnergyToday?.updateCharacteristic(Characteristic.EnergyToday, energy.energyToday);
161
- this.sensorEnergyServices?.[i]?.Characteristic?.EnergyLastDay?.updateCharacteristic(Characteristic.EnergyLastDay, energy.energyLastDay);
162
- this.sensorEnergyServices?.[i]?.Characteristic?.EnergyLifetime?.updateCharacteristic(Characteristic.EnergyLifetime, energy.energyLifetime);
163
- this.sensorEnergyServices?.[i]?.Characteristic?.Current?.updateCharacteristic(Characteristic.Current, energy.current);
164
- this.sensorEnergyServices?.[i]?.Characteristic?.Voltage?.updateCharacteristic(Characteristic.Voltage, energy.voltage);
165
- this.sensorEnergyServices?.[i]?.Characteristic?.Factor?.updateCharacteristic(Characteristic.Factor, energy.factor);
166
- this.sensorEnergyServices?.[i]?.Characteristic?.Frequency?.updateCharacteristic(Characteristic.Frequency, energy.frequency);
167
- this.sensorEnergyServices?.[i]?.Characteristic?.ReadingTime?.updateCharacteristic(Characteristic.ReadingTime, energy.time);
154
+ this.sensorEnergyServices?.[i]?.Characteristic?.Power?.updateCharacteristic(Characteristic.Power, obj.power);
155
+ this.sensorEnergyServices?.[i]?.Characteristic?.ApparentPower?.updateCharacteristic(Characteristic.ApparentPower, obj.apparentPower);
156
+ this.sensorEnergyServices?.[i]?.Characteristic?.ReactivePower?.updateCharacteristic(Characteristic.ReactivePower, obj.reactivePower);
157
+ this.sensorEnergyServices?.[i]?.Characteristic?.EnergyToday?.updateCharacteristic(Characteristic.EnergyToday, obj.energyToday);
158
+ this.sensorEnergyServices?.[i]?.Characteristic?.EnergyLastDay?.updateCharacteristic(Characteristic.EnergyLastDay, obj.energyLastDay);
159
+ this.sensorEnergyServices?.[i]?.Characteristic?.EnergyLifetime?.updateCharacteristic(Characteristic.EnergyLifetime, obj.energyLifetime);
160
+ this.sensorEnergyServices?.[i]?.Characteristic?.Current?.updateCharacteristic(Characteristic.Current, obj.current);
161
+ this.sensorEnergyServices?.[i]?.Characteristic?.Voltage?.updateCharacteristic(Characteristic.Voltage, obj.voltage);
162
+ this.sensorEnergyServices?.[i]?.Characteristic?.Factor?.updateCharacteristic(Characteristic.Factor, obj.factor);
163
+ this.sensorEnergyServices?.[i]?.Characteristic?.Frequency?.updateCharacteristic(Characteristic.Frequency, obj.frequency);
164
+ this.sensorEnergyServices?.[i]?.Characteristic?.ReadingTime?.updateCharacteristic(Characteristic.ReadingTime, obj.time);
168
165
  }
169
166
 
170
- const sensor = isEnergy ? { ...obj, ...energy } : obj;
171
- const debug1 = this.enableDebugMode ? this.emit('debug', `Sensor: ${JSON.stringify(sensor, null, 2)}`) : false;
167
+ const debug1 = this.enableDebugMode ? this.emit('debug', `Sensor: ${JSON.stringify(obj, null, 2)}`) : false;
168
+ this.emit('warn', `Sensor: ${JSON.stringify(obj, null, 2)}`)
172
169
 
173
170
  //push to array
174
- this.sensors.push(sensor);
171
+ this.sensors.push(obj);
175
172
  i++;
176
173
  }
177
174
  this.sensorsCount = this.sensors.length;