Fix SPM simulate possible duplicates

This commit is contained in:
Theo Arends 2022-02-20 11:41:51 +01:00
parent 1aa9d9da29
commit 74d17d32c6

View File

@ -1371,7 +1371,6 @@ void SSPMHandleReceivedData(void) {
#endif #endif
power_t relay = (SspmBuffer[31] & 0x0F) << (module * 4); // Relays active power_t relay = (SspmBuffer[31] & 0x0F) << (module * 4); // Relays active
power_t relay_state = (SspmBuffer[31] >> 4) << (module * 4); // Relays state power_t relay_state = (SspmBuffer[31] >> 4) << (module * 4); // Relays state
for (uint32_t i = 1; i <= TasmotaGlobal.devices_present; i++) { for (uint32_t i = 1; i <= TasmotaGlobal.devices_present; i++) {
if (relay &1) { if (relay &1) {
ExecuteCommandPower(i, relay_state &1, SRC_BUTTON); ExecuteCommandPower(i, relay_state &1, SRC_BUTTON);
@ -1453,11 +1452,14 @@ void SSPMHandleReceivedData(void) {
SSPMAddModule(); SSPMAddModule();
#ifdef SSPM_SIMULATE #ifdef SSPM_SIMULATE
if (0 == Sspm->simulate) { if (0 == Sspm->simulate) {
uint8_t current_idh = SspmBuffer[19];
uint8_t current_idl = SspmBuffer[20]; uint8_t current_idl = SspmBuffer[20];
for (Sspm->simulate = 0; Sspm->simulate < SSPM_SIMULATE; Sspm->simulate++) { for (Sspm->simulate = 0; Sspm->simulate < SSPM_SIMULATE; Sspm->simulate++) {
SspmBuffer[19] = Sspm->simulate +1;
SspmBuffer[20] = Sspm->simulate +1; SspmBuffer[20] = Sspm->simulate +1;
SSPMAddModule(); SSPMAddModule();
} }
SspmBuffer[19] = current_idh;
SspmBuffer[20] = current_idl; SspmBuffer[20] = current_idl;
} }
#endif #endif