mirror of https://github.com/arendst/Tasmota.git
Fix SPM total updates for all relays
This commit is contained in:
parent
cb0e9d1316
commit
6835eabc39
|
@ -179,6 +179,7 @@ enum SspmMachineStates { SPM_NONE, // Do nothing
|
||||||
SPM_START_SCAN, // Start module scan sequence
|
SPM_START_SCAN, // Start module scan sequence
|
||||||
SPM_WAIT_FOR_SCAN, // Wait for scan sequence to complete
|
SPM_WAIT_FOR_SCAN, // Wait for scan sequence to complete
|
||||||
SPM_SCAN_COMPLETE, // Scan complete
|
SPM_SCAN_COMPLETE, // Scan complete
|
||||||
|
SPM_STALL_MIDNIGHT, // Stall energy totals around midnight
|
||||||
SPM_GET_ENERGY_TOTALS, // Init available Energy totals registers
|
SPM_GET_ENERGY_TOTALS, // Init available Energy totals registers
|
||||||
SPM_UPDATE_CHANNELS // Update Energy for powered on channels
|
SPM_UPDATE_CHANNELS // Update Energy for powered on channels
|
||||||
};
|
};
|
||||||
|
@ -1773,10 +1774,17 @@ void SSPMEvery100ms(void) {
|
||||||
case SPM_SCAN_COMPLETE:
|
case SPM_SCAN_COMPLETE:
|
||||||
// Scan sequence finished
|
// Scan sequence finished
|
||||||
TasmotaGlobal.discovery_counter = 1; // Force TasDiscovery()
|
TasmotaGlobal.discovery_counter = 1; // Force TasDiscovery()
|
||||||
Sspm->get_energy_relay = 0;
|
|
||||||
Sspm->allow_updates = 1; // Enable requests from 100mSec loop
|
Sspm->allow_updates = 1; // Enable requests from 100mSec loop
|
||||||
|
Sspm->get_energy_relay = 0;
|
||||||
Sspm->mstate = SPM_GET_ENERGY_TOTALS;
|
Sspm->mstate = SPM_GET_ENERGY_TOTALS;
|
||||||
break;
|
break;
|
||||||
|
case SPM_STALL_MIDNIGHT:
|
||||||
|
// Get totals for ALL relays after midnight updating Tasmotas total and yesterday energy
|
||||||
|
if (Sspm->last_totals > 600) { // Continue after 60 seconds
|
||||||
|
Sspm->get_energy_relay = 0;
|
||||||
|
Sspm->mstate = SPM_GET_ENERGY_TOTALS;
|
||||||
|
}
|
||||||
|
break;
|
||||||
case SPM_GET_ENERGY_TOTALS:
|
case SPM_GET_ENERGY_TOTALS:
|
||||||
// Retrieve Energy total status from up to 128 relays
|
// Retrieve Energy total status from up to 128 relays
|
||||||
if (Sspm->allow_updates) {
|
if (Sspm->allow_updates) {
|
||||||
|
@ -1793,9 +1801,9 @@ void SSPMEvery100ms(void) {
|
||||||
// Retrieve Energy status from up to 128 powered on relays (takes 128 * 2s!!)
|
// Retrieve Energy status from up to 128 powered on relays (takes 128 * 2s!!)
|
||||||
if (Sspm->allow_updates) {
|
if (Sspm->allow_updates) {
|
||||||
int32_t time = (RtcTime.hour *3600) + (RtcTime.minute *60) + RtcTime.second;
|
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
|
if (time > 86370) { // Stall updates after 23:59:31 to satisfy ARM firmware
|
||||||
Sspm->get_energy_relay = TasmotaGlobal.devices_present;
|
|
||||||
Sspm->last_totals = 0;
|
Sspm->last_totals = 0;
|
||||||
|
Sspm->mstate = SPM_STALL_MIDNIGHT;
|
||||||
} else {
|
} else {
|
||||||
Sspm->get_energy_relay++;
|
Sspm->get_energy_relay++;
|
||||||
if (Sspm->get_energy_relay >= TasmotaGlobal.devices_present) {
|
if (Sspm->get_energy_relay >= TasmotaGlobal.devices_present) {
|
||||||
|
|
Loading…
Reference in New Issue