mirror of
https://github.com/arendst/Tasmota.git
synced 2025-07-25 11:46:31 +00:00
Clean up SPM code
This commit is contained in:
parent
9c1adc2bdc
commit
a995a6e78c
@ -1139,17 +1139,16 @@ void SSPMHandleReceivedData(void) {
|
||||
Sspm->Settings.energy_yesterday[module][channel] = energy_yesterday; // Inital setting
|
||||
Sspm->Settings.energy_total[module][channel] = energy_total; // Initial setting
|
||||
if (Settings->save_data) {
|
||||
TasmotaGlobal.save_data_counter = Settings->save_data +2; // Potspone flash write until all relays are updated
|
||||
TasmotaGlobal.save_data_counter = Settings->save_data +2; // Postpone flash write until all relays are updated
|
||||
}
|
||||
}
|
||||
|
||||
// If received daily energy is below last daily energy then update total energy
|
||||
// This happens around midnight in normal situations
|
||||
if (Sspm->energy_today[module][channel] < last_energy_today) {
|
||||
else if (Sspm->energy_today[module][channel] < last_energy_today) {
|
||||
Sspm->Settings.energy_yesterday[module][channel] = last_energy_today; // Daily save
|
||||
Sspm->Settings.energy_total[module][channel] += last_energy_today; // Daily incremental save
|
||||
if (Settings->save_data) {
|
||||
TasmotaGlobal.save_data_counter = Settings->save_data +2; // Potspone flash write until all relays are updated
|
||||
TasmotaGlobal.save_data_counter = Settings->save_data +2; // Postpone flash write until all relays are updated
|
||||
}
|
||||
}
|
||||
Sspm->energy_total[module][channel] = Sspm->Settings.energy_total[module][channel] + Sspm->energy_today[module][channel];
|
||||
@ -1793,21 +1792,11 @@ void SSPMEvery100ms(void) {
|
||||
case SPM_UPDATE_CHANNELS:
|
||||
// Retrieve Energy status from up to 128 powered on relays (takes 128 * 2s!!)
|
||||
if (Sspm->allow_updates) {
|
||||
|
||||
// Test if this solves midnight timeout
|
||||
|
||||
int32_t time = (RtcTime.hour *3600) + (RtcTime.minute *60) + RtcTime.second;
|
||||
if ((time > 86370) || (time < 30)) { // Between 00:00:29 and 23:59:31 stall updates to satisfy ARM firmware
|
||||
Sspm->get_energy_relay = TasmotaGlobal.devices_present;
|
||||
Sspm->last_totals = 0;
|
||||
} else {
|
||||
/*
|
||||
int32_t time = (RtcTime.hour *60) + RtcTime.minute;
|
||||
if ((time > 1433) || (time < 1)) { // Between 23:54 and 01:00 stall updates to satisfy ARM firmware (flash writes at 23:55)
|
||||
Sspm->get_energy_relay = TasmotaGlobal.devices_present;
|
||||
Sspm->last_totals = 0;
|
||||
} else {
|
||||
*/
|
||||
Sspm->get_energy_relay++;
|
||||
if (Sspm->get_energy_relay >= TasmotaGlobal.devices_present) {
|
||||
Sspm->get_energy_relay = 0;
|
||||
@ -1838,12 +1827,9 @@ void SSPMEvery100ms(void) {
|
||||
Sspm->power_factor[module][channel] = 0;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
break;
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user