diff --git a/tasmota/support_command.ino b/tasmota/support_command.ino index 6f70e7359..24ef2051c 100644 --- a/tasmota/support_command.ino +++ b/tasmota/support_command.ino @@ -338,7 +338,8 @@ void CmndStatus(void) char stemp2[TOPSZ]; // Workaround MQTT - TCP/IP stack queueing when SUB_PREFIX = PUB_PREFIX - if (!strcmp(SettingsText(SET_MQTTPREFIX1), SettingsText(SET_MQTTPREFIX2)) && (!payload)) { option++; } // TELE + // Commented on 20200118 as it seems to be no longer needed +// if (!strcmp(SettingsText(SET_MQTTPREFIX1), SettingsText(SET_MQTTPREFIX2)) && (!payload)) { option++; } // TELE if ((!Settings.flag.mqtt_enabled) && (6 == payload)) { payload = 99; } // SetOption3 - Enable MQTT if (!energy_flg && (9 == payload)) { payload = 99; } diff --git a/tasmota/support_tasmota.ino b/tasmota/support_tasmota.ino index 551f5b2c6..9095a09bf 100644 --- a/tasmota/support_tasmota.ino +++ b/tasmota/support_tasmota.ino @@ -692,7 +692,12 @@ void MqttPublishSensor(void) } } -/********************************************************************************************/ +/*********************************************************************************************\ + * State loops +\*********************************************************************************************/ +/*-------------------------------------------------------------------------------------------*\ + * Every second +\*-------------------------------------------------------------------------------------------*/ void PerformEverySecond(void) { @@ -715,6 +720,13 @@ void PerformEverySecond(void) #endif } + if (mqtt_cmnd_blocked_reset) { + mqtt_cmnd_blocked_reset--; + if (!mqtt_cmnd_blocked_reset) { + mqtt_cmnd_blocked = 0; // Clean up MQTT cmnd loop block + } + } + if (seriallog_timer) { seriallog_timer--; if (!seriallog_timer) { @@ -763,9 +775,6 @@ void PerformEverySecond(void) } } -/*********************************************************************************************\ - * State loops -\*********************************************************************************************/ /*-------------------------------------------------------------------------------------------*\ * Every 0.1 second \*-------------------------------------------------------------------------------------------*/ @@ -822,8 +831,6 @@ void Every250mSeconds(void) state_250mS++; state_250mS &= 0x3; - if (mqtt_cmnd_publish) mqtt_cmnd_publish--; // Clean up - if (!Settings.flag.global_state) { // Problem blinkyblinky enabled - SetOption31 - Control link led blinking if (global_state.data) { // Any problem if (global_state.mqtt_down) { blinkinterval = 7; } // MQTT problem so blink every 2 seconds (slowest) diff --git a/tasmota/tasmota.ino b/tasmota/tasmota.ino index 721c2f4ac..15375e338 100644 --- a/tasmota/tasmota.ino +++ b/tasmota/tasmota.ino @@ -110,12 +110,13 @@ float global_temperature = 9999; // Provide a global temperature to b float global_humidity = 0; // Provide a global humidity to be used by some sensors float global_pressure = 0; // Provide a global pressure to be used by some sensors uint16_t tele_period = 9999; // Tele period timer -uint16_t mqtt_cmnd_publish = 0; // ignore flag for publish command uint16_t blink_counter = 0; // Number of blink cycles uint16_t seriallog_timer = 0; // Timer to disable Seriallog uint16_t syslog_timer = 0; // Timer to re-enable syslog_level int16_t save_data_counter; // Counter and flag for config save to Flash RulesBitfield rules_flag; // Rule state flags (16 bits) +uint8_t mqtt_cmnd_blocked = 0; // Ignore flag for publish command +uint8_t mqtt_cmnd_blocked_reset = 0; // Count down to reset if needed uint8_t state_250mS = 0; // State 250msecond per second flag uint8_t latching_relay_pulse = 0; // Latching relay pulse timer uint8_t sleep; // Current copy of Settings.sleep diff --git a/tasmota/xdrv_02_mqtt.ino b/tasmota/xdrv_02_mqtt.ino index d489606d4..a5d90f49a 100644 --- a/tasmota/xdrv_02_mqtt.ino +++ b/tasmota/xdrv_02_mqtt.ino @@ -225,10 +225,8 @@ bool MqttPublishLib(const char* topic, bool retained) if (!strcmp(SettingsText(SET_MQTTPREFIX1), SettingsText(SET_MQTTPREFIX2))) { char *str = strstr(topic, SettingsText(SET_MQTTPREFIX1)); if (str == topic) { - if (0 == mqtt_cmnd_publish) { - mqtt_cmnd_publish += 3; - } - mqtt_cmnd_publish += 3; + mqtt_cmnd_blocked_reset = 4; // Allow up to four seconds before resetting residual cmnd blocks + mqtt_cmnd_blocked++; } } @@ -249,12 +247,8 @@ void MqttDataHandler(char* mqtt_topic, uint8_t* mqtt_data, unsigned int data_len // Do not execute multiple times if Prefix1 equals Prefix2 if (!strcmp(SettingsText(SET_MQTTPREFIX1), SettingsText(SET_MQTTPREFIX2))) { char *str = strstr(mqtt_topic, SettingsText(SET_MQTTPREFIX1)); - if ((str == mqtt_topic) && mqtt_cmnd_publish) { - if (mqtt_cmnd_publish > 3) { - mqtt_cmnd_publish -= 3; - } else { - mqtt_cmnd_publish = 0; - } + if ((str == mqtt_topic) && mqtt_cmnd_blocked) { + mqtt_cmnd_blocked--; return; } }