diff --git a/tasmota/support_tasmota.ino b/tasmota/support_tasmota.ino index 05e6e3974..eb852ca77 100644 --- a/tasmota/support_tasmota.ino +++ b/tasmota/support_tasmota.ino @@ -886,7 +886,7 @@ void PerformEverySecond(void) Settings.last_module = Settings.module; #ifdef USE_DEEPSLEEP - if (!(DeepSleepEnabled() && !Settings.flag3.bootcount_update)) { + if (!(DeepSleepEnabled() && !Settings.flag3.bootcount_update)) { // SetOption76 - (Deepsleep) Enable incrementing bootcount (1) when deepsleep is enabled #endif Settings.bootcount++; // Moved to here to stop flash writes during start-up AddLog(LOG_LEVEL_DEBUG, PSTR(D_LOG_APPLICATION D_BOOT_COUNT " %d"), Settings.bootcount); diff --git a/tasmota/tasmota_template.h b/tasmota/tasmota_template.h index 9b27c12d9..74940db07 100644 --- a/tasmota/tasmota_template.h +++ b/tasmota/tasmota_template.h @@ -176,7 +176,7 @@ typedef union { // Restricted by MISRA-C Rule 18.4 bu struct { // GPIO Option_A1 .. Option_A32 uint32_t pwm1_input : 1; // bit 0 (v9.2.0.1) - Option_A1 - (Light) Change PWM1 to input on power off and no fade running (1) uint32_t dummy_energy : 1; // bit 1 (v9.3.1.2) - Option_A2 - (Energy) Enable dummy values - uint32_t udisplay_driver : 1; // bit 2 Universal display driver + uint32_t udisplay_driver : 1; // bit 2 (v9.3.1.2) - Option_A3 - (Display) Universal display driver uint32_t spare03 : 1; // bit 3 uint32_t spare04 : 1; // bit 4 uint32_t spare05 : 1; // bit 5 diff --git a/tasmota/xdrv_12_discovery.ino b/tasmota/xdrv_12_discovery.ino index f5972ad6b..9a592159a 100644 --- a/tasmota/xdrv_12_discovery.ino +++ b/tasmota/xdrv_12_discovery.ino @@ -25,10 +25,10 @@ * A version of xdrv_12_home_assistant supporting the new Tasmota Discovery be used by * latest versions of Home Assistant or TasmoManager. * - * SetOption19 0 - Enables discovery (default) - * SetOption19 1 - Disables discovery and removes retained message from MQTT server - * SetOption73 1 - Enable discovery for buttons - * SetOption114 1 - Enable discovery for switches + * SetOption19 0 - [DiscoverOff 0] [Discover 1] Enables discovery (default) + * SetOption19 1 - [DiscoverOff 1] [Discover 0] Disables discovery and removes retained message from MQTT server + * SetOption73 1 - [DiscoverButton] Enable discovery for buttons + * SetOption114 1 - [DiscoverSwitch] Enable discovery for switches \*********************************************************************************************/ #define XDRV_12 12 @@ -226,8 +226,41 @@ void TasRediscover(void) { } void TasDiscoverInit(void) { - TasDiscoverData_init_step = 10; // Delayed discovery - Settings.flag.hass_discovery = 0; // SetOption19 - Enable Tasmota discovery and Disable legacy Hass discovery + if (ResetReason() != REASON_DEEP_SLEEP_AWAKE) { + Settings.flag.hass_discovery = 0; // SetOption19 - Enable Tasmota discovery and Disable legacy Hass discovery + TasDiscoverData_init_step = 10; // Delayed discovery + } +} + +/*********************************************************************************************\ + * Commands + * + * Discover 0 - Disables discovery and removes retained message from MQTT server + * Discover 1 - Enables discovery (default) + * DiscoverOff 0 - Enables discovery (default) + * DiscoverOff 1 - Disables discovery and removes retained message from MQTT server + * DiscoverButton 1 - Enable discovery for buttons + * DiscoverSwitch 1 - Enable discovery for switches +\*********************************************************************************************/ + +const char kTasDiscoverCommands[] PROGMEM = "Discover|" // Prefix + // SetOption synonyms + "Off|Button|Switch|" + // Commands + "|"; + +SO_SYNONYMS(kTasDiscoverSynonyms, + 19, 73, 114 ); + +void (* const TasDiscoverCommand[])(void) PROGMEM = { + &CmndTasDiscover }; + +void CmndTasDiscover(void) { + if (XdrvMailbox.payload >= 0) { + Settings.flag.hass_discovery = !(XdrvMailbox.payload & 1); + TasRediscover(); + } + ResponseCmndChar(GetStateText(!Settings.flag.hass_discovery)); } /*********************************************************************************************\ @@ -247,6 +280,9 @@ bool Xdrv12(uint8_t function) { } } break; + case FUNC_COMMAND: + result = DecodeCommand(kTasDiscoverCommands, TasDiscoverCommand, kTasDiscoverSynonyms); + break; case FUNC_MQTT_INIT: TasDiscoverInit(); break;