Try to fix TuyaMcu powerusage

Try to fix TuyaMcu powerusage (#10005)
This commit is contained in:
Theo Arends 2020-11-29 13:32:13 +01:00
parent 8eacb36f71
commit 4c43ce479d

View File

@ -794,11 +794,13 @@ void TuyaProcessStatePacket(void) {
Energy.active_power[0] = (float)packetValue / 10;
AddLog_P(LOG_LEVEL_DEBUG, PSTR("TYA: Rx ID=%d Active_Power=%d"), Tuya.buffer[dpidStart], packetValue);
if (Tuya.lastPowerCheckTime != 0 && Energy.active_power[0] > 0) {
Energy.kWhtoday += (float)Energy.active_power[0] * (Rtc.utc_time - Tuya.lastPowerCheckTime) / 36;
EnergyUpdateToday();
if (RtcTime.valid) {
if (Tuya.lastPowerCheckTime != 0 && Energy.active_power[0] > 0) {
Energy.kWhtoday += (float)Energy.active_power[0] * (Rtc.utc_time - Tuya.lastPowerCheckTime) / 36;
EnergyUpdateToday();
}
Tuya.lastPowerCheckTime = Rtc.utc_time;
}
Tuya.lastPowerCheckTime = Rtc.utc_time;
}
#endif // USE_ENERGY_SENSOR
}