From f8254901d095ba40323744120a877fae90fb254a Mon Sep 17 00:00:00 2001 From: Theo Arends <11044339+arendst@users.noreply.github.com> Date: Sat, 16 Apr 2022 18:20:10 +0200 Subject: [PATCH] Add delayed SetPowerOnState Add delayed SetPowerOnState to Sonoff SPM (#13447) --- CHANGELOG.md | 1 + RELEASENOTES.md | 1 + tasmota/xdrv_86_esp32_sonoff_spm.ino | 10 ++++++++++ 3 files changed, 12 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 2c824792b..f98b954bb 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -8,6 +8,7 @@ All notable changes to this project will be documented in this file. - Support for Sonoff MS01 soil moisture sensor (#15335) - Support for daisy chaining MAX7219 displays (#15345) - Command ``EnergyExportActive`` to (p)reset energy export active for supported devices. Currently ADE7880 only (#13515) +- Sonoff SPM delayed SetPowerOnState (#13447) ### Changed diff --git a/RELEASENOTES.md b/RELEASENOTES.md index fd7854b34..a435c2722 100644 --- a/RELEASENOTES.md +++ b/RELEASENOTES.md @@ -109,6 +109,7 @@ The latter links can be used for OTA upgrades too like ``OtaUrl http://ota.tasmo - Command ``EnergyExportActive`` to (p)reset energy export active for supported devices. Currently ADE7880 only [#13515](https://github.com/arendst/Tasmota/issues/13515) - Support for Sonoff MS01 soil moisture sensor [#15335](https://github.com/arendst/Tasmota/issues/15335) - Support for daisy chaining MAX7219 displays [#15345](https://github.com/arendst/Tasmota/issues/15345) +- Sonoff SPM delayed SetPowerOnState [#13447](https://github.com/arendst/Tasmota/issues/13447) ### Breaking Changed diff --git a/tasmota/xdrv_86_esp32_sonoff_spm.ino b/tasmota/xdrv_86_esp32_sonoff_spm.ino index 623d671c0..c2dedfd41 100644 --- a/tasmota/xdrv_86_esp32_sonoff_spm.ino +++ b/tasmota/xdrv_86_esp32_sonoff_spm.ino @@ -251,6 +251,7 @@ typedef struct { uint32_t timeout; power_t old_power; + power_t power_on_state; uint16_t last_totals; uint16_t serial_in_byte_counter; uint16_t expected_bytes; @@ -1097,6 +1098,14 @@ void SSPMHandleReceivedData(void) { } else { AddLog(LOG_LEVEL_DEBUG, PSTR("SPM: Relay scan done")); +#ifndef SSPM_SIMULATE + if (Sspm->power_on_state) { + TasmotaGlobal.power = Sspm->power_on_state; + Sspm->power_on_state = 0; + SetPowerOnState(); + } +#endif + Sspm->mstate = SPM_SCAN_COMPLETE; } break; @@ -1704,6 +1713,7 @@ void SSPMInit(void) { Sspm->history_relay = 255; // Disable display energy history Sspm->log_relay = 255; // Disable display logging Sspm->old_power = TasmotaGlobal.power; + Sspm->power_on_state = TasmotaGlobal.power; Sspm->mstate = SPM_WAIT; // Start init sequence }