From aaa00045e20c9eaf8042dcd8611a18d3cd47b217 Mon Sep 17 00:00:00 2001 From: denisfrench Date: Sun, 16 Feb 2020 09:31:19 +0000 Subject: [PATCH] MQTT_NO_RETAIN option for brokers that will drop connection otherwise --- tasmota/my_user_config.h | 5 +++-- tasmota/xdrv_02_mqtt.ino | 2 +- 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/tasmota/my_user_config.h b/tasmota/my_user_config.h index 753766839..67ab1cf1c 100644 --- a/tasmota/my_user_config.h +++ b/tasmota/my_user_config.h @@ -99,7 +99,8 @@ #define MQTT_POWER_RETAIN false // [PowerRetain] Power status message may send retain flag (false = off, true = on) #define MQTT_SWITCH_RETAIN false // [SwitchRetain] Switch may send retain flag (false = off, true = on) #define MQTT_SENSOR_RETAIN false // [SensorRetain] Sensor may send retain flag (false = off, true = on) -#define MQTT_BUTTON_SWITCH_FORCE_LOCAL false // [SetOption61] Force local operation when button/switch topic is set (false = off, true = on) +#define MQTT_NO_HOLD_RETAIN false // [SetOption62] Disable retain flag on HOLD messages +//#define MQTT_NO_RETAIN // Disable all retain flags (including LWT!) if unsupported by broker (eg Losant) #define MQTT_STATUS_OFF "OFF" // [StateText1] Command or Status result when turned off (needs to be a string like "0" or "Off") #define MQTT_STATUS_ON "ON" // [StateText2] Command or Status result when turned on (needs to be a string like "1" or "On") @@ -139,7 +140,7 @@ #define MQTT_LWT_MESSAGE false // [SetOption10] Switch between MQTT LWT OFFLINE or empty message #define MQTT_POWER_FORMAT false // [SetOption26] Switch between POWER or POWER1 for single power devices #define MQTT_APPEND_TIMEZONE false // [SetOption52] Append timezone to JSON time -#define MQTT_NO_HOLD_RETAIN false // [SetOption62] Disable retain flag on HOLD messages +#define MQTT_BUTTON_SWITCH_FORCE_LOCAL false // [SetOption61] Force local operation when button/switch topic is set (false = off, true = on) #define MQTT_INDEX_SEPARATOR false // [SetOption64] Enable "_" instead of "-" as sensor index separator #define MQTT_TUYA_RECEIVED false // [SetOption66] Enable TuyaMcuReceived messages over Mqtt diff --git a/tasmota/xdrv_02_mqtt.ino b/tasmota/xdrv_02_mqtt.ino index 770170aa3..aadf44f71 100644 --- a/tasmota/xdrv_02_mqtt.ino +++ b/tasmota/xdrv_02_mqtt.ino @@ -314,7 +314,7 @@ void MqttPublish(const char* topic, bool retained) ShowFreeMem(PSTR("MqttPublish")); #endif -#if defined(USE_MQTT_TLS) && defined(USE_MQTT_AWS_IOT) +#if defined(USE_MQTT_TLS) && defined(USE_MQTT_AWS_IOT) || defined(MQTT_NO_RETAIN) // if (retained) { // AddLog_P(LOG_LEVEL_INFO, S_LOG_MQTT, PSTR("Retained are not supported by AWS IoT, using retained = false.")); // }