Fix ESP8266 Energy Export Active

Fix ESP8266 Energy Export Active no update regression from v12.3.1.3
This commit is contained in:
Theo Arends 2023-04-18 15:34:19 +02:00
parent c5e09ef76d
commit 2684141722
3 changed files with 9 additions and 1 deletions

View File

@ -12,6 +12,7 @@ All notable changes to this project will be documented in this file.
### Changed ### Changed
### Fixed ### Fixed
- ESP8266 Energy Export Active no update regression from v12.3.1.3
### Removed ### Removed

View File

@ -119,3 +119,4 @@ The latter links can be used for OTA upgrades too like ``OtaUrl https://ota.tasm
### Changed ### Changed
### Fixed ### Fixed
- ESP8266 Energy Export Active no update regression from v12.3.1.3

View File

@ -99,6 +99,7 @@ typedef struct {
int32_t kWhtoday_delta[ENERGY_MAX_PHASES]; // 1212312345 Wh 10^-5 (deca micro Watt hours) - Overflows to Energy->kWhtoday (HLW and CSE only) int32_t kWhtoday_delta[ENERGY_MAX_PHASES]; // 1212312345 Wh 10^-5 (deca micro Watt hours) - Overflows to Energy->kWhtoday (HLW and CSE only)
int32_t kWhtoday_offset[ENERGY_MAX_PHASES]; // 12312312 Wh * 10^-2 (deca milli Watt hours) - 5764 = 0.05764 kWh = 0.058 kWh = Energy->daily int32_t kWhtoday_offset[ENERGY_MAX_PHASES]; // 12312312 Wh * 10^-2 (deca milli Watt hours) - 5764 = 0.05764 kWh = 0.058 kWh = Energy->daily
int32_t kWhtoday[ENERGY_MAX_PHASES]; // 12312312 Wh * 10^-2 (deca milli Watt hours) - 5764 = 0.05764 kWh = 0.058 kWh = Energy->daily int32_t kWhtoday[ENERGY_MAX_PHASES]; // 12312312 Wh * 10^-2 (deca milli Watt hours) - 5764 = 0.05764 kWh = 0.058 kWh = Energy->daily
int32_t kWhtoday_export[ENERGY_MAX_PHASES]; // 12312312 Wh * 10^-2 (deca milli Watt hours) - 5764 = 0.05764 kWh = 0.058 kWh = Energy->daily
int32_t period[ENERGY_MAX_PHASES]; // 12312312 Wh * 10^-2 (deca milli Watt hours) - 5764 = 0.05764 kWh = 0.058 kWh = Energy->daily int32_t period[ENERGY_MAX_PHASES]; // 12312312 Wh * 10^-2 (deca milli Watt hours) - 5764 = 0.05764 kWh = 0.058 kWh = Energy->daily
char* value; char* value;
@ -278,7 +279,12 @@ void EnergyUpdateToday(void) {
Energy->kWhtoday_delta[i] -= (delta * 1000); Energy->kWhtoday_delta[i] -= (delta * 1000);
Energy->kWhtoday[i] += delta; Energy->kWhtoday[i] += delta;
if (delta < 0) { // Export energy if (delta < 0) { // Export energy
RtcSettings.energy_kWhexport_ph[i] += ((delta / 100) *-1); Energy->kWhtoday_export[i] += (delta *-1);
if (Energy->kWhtoday_export[i] > 100) {
int32_t delta_export = Energy->kWhtoday_export[i] / 100;
Energy->kWhtoday_export[i] -= (delta_export * 100);
RtcSettings.energy_kWhexport_ph[i] += delta_export;
}
} }
} }