Fix Shelly Dimmer 2 Energy calculation

Fix Shelly Dimmer Energy calculation (#12815)
This commit is contained in:
Theo Arends 2021-08-30 10:53:23 +02:00
parent b35072c1e1
commit 3a85922a94
1 changed files with 2 additions and 2 deletions

View File

@ -536,7 +536,7 @@ bool ShdPacketProcess(void)
Energy.current[0] = current;
Energy.apparent_power[0] = voltage * current;
if ((voltage * current) > wattage)
Energy.reactive_power[0] = sqrt((voltage * current) * (voltage * current) - wattage * wattage);
Energy.reactive_power[0] = sqrtf((voltage * current) * (voltage * current) - wattage * wattage);
else
Energy.reactive_power[0] = 0;
if (wattage > (voltage * current))
@ -552,7 +552,7 @@ bool ShdPacketProcess(void)
#ifdef SHELLY_DIMMER_DEBUG
AddLog(LOG_LEVEL_DEBUG, PSTR(SHD_LOGNAME "Adding %i mWh to todays usage from %lu to %lu"), (int)(kWhused * 10), Shd.last_power_check, Rtc.utc_time);
#endif // SHELLY_DIMMER_DEBUG
Energy.kWhtoday += kWhused;
Energy.kWhtoday_delta += kWhused;
EnergyUpdateToday();
}
Shd.last_power_check = Rtc.utc_time;