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.
- package/package.json +1 -1
- package/src/sensors.js +29 -32
package/package.json
CHANGED
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,
|
|
158
|
-
this.sensorEnergyServices?.[i]?.Characteristic?.ApparentPower?.updateCharacteristic(Characteristic.ApparentPower,
|
|
159
|
-
this.sensorEnergyServices?.[i]?.Characteristic?.ReactivePower?.updateCharacteristic(Characteristic.ReactivePower,
|
|
160
|
-
this.sensorEnergyServices?.[i]?.Characteristic?.EnergyToday?.updateCharacteristic(Characteristic.EnergyToday,
|
|
161
|
-
this.sensorEnergyServices?.[i]?.Characteristic?.EnergyLastDay?.updateCharacteristic(Characteristic.EnergyLastDay,
|
|
162
|
-
this.sensorEnergyServices?.[i]?.Characteristic?.EnergyLifetime?.updateCharacteristic(Characteristic.EnergyLifetime,
|
|
163
|
-
this.sensorEnergyServices?.[i]?.Characteristic?.Current?.updateCharacteristic(Characteristic.Current,
|
|
164
|
-
this.sensorEnergyServices?.[i]?.Characteristic?.Voltage?.updateCharacteristic(Characteristic.Voltage,
|
|
165
|
-
this.sensorEnergyServices?.[i]?.Characteristic?.Factor?.updateCharacteristic(Characteristic.Factor,
|
|
166
|
-
this.sensorEnergyServices?.[i]?.Characteristic?.Frequency?.updateCharacteristic(Characteristic.Frequency,
|
|
167
|
-
this.sensorEnergyServices?.[i]?.Characteristic?.ReadingTime?.updateCharacteristic(Characteristic.ReadingTime,
|
|
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
|
|
171
|
-
|
|
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(
|
|
171
|
+
this.sensors.push(obj);
|
|
175
172
|
i++;
|
|
176
173
|
}
|
|
177
174
|
this.sensorsCount = this.sensors.length;
|