From 4c43ce479dc17f0939c9152bc1c55e05421f4215 Mon Sep 17 00:00:00 2001 From: Theo Arends <11044339+arendst@users.noreply.github.com> Date: Sun, 29 Nov 2020 13:32:13 +0100 Subject: [PATCH] Try to fix TuyaMcu powerusage Try to fix TuyaMcu powerusage (#10005) --- tasmota/xdrv_16_tuyamcu.ino | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/tasmota/xdrv_16_tuyamcu.ino b/tasmota/xdrv_16_tuyamcu.ino index a7b9f27ec..6eab26f08 100644 --- a/tasmota/xdrv_16_tuyamcu.ino +++ b/tasmota/xdrv_16_tuyamcu.ino @@ -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 }