From ec899817aa84c07faba4f9eb2df9a2e96ce72f0b Mon Sep 17 00:00:00 2001 From: Theo Arends <11044339+arendst@users.noreply.github.com> Date: Wed, 1 Apr 2020 14:05:30 +0200 Subject: [PATCH] Change some deepsleep wake messages - Change remove MQTT Info messages on restart for DeepSleep Wake (#8044) - Add command ``SetOption90 1`` to disable non-json MQTT messages (#8044) --- RELEASENOTES.md | 3 +++ tasmota/CHANGELOG.md | 4 ++- tasmota/settings.h | 2 +- tasmota/xdrv_02_mqtt.ino | 55 ++++++++++++++++++++++------------------ 4 files changed, 38 insertions(+), 26 deletions(-) diff --git a/RELEASENOTES.md b/RELEASENOTES.md index 23bd31fef..864a562e1 100644 --- a/RELEASENOTES.md +++ b/RELEASENOTES.md @@ -56,12 +56,15 @@ The following binary downloads have been compiled with ESP8266/Arduino library c - Change HM-10 sensor type detection and add features (#7962) - Change light scheme 2,3,4 cycle time speed from 24,48,72,... seconds to 4,6,12,24,36,48,... seconds (#8034) +- Change remove floating point libs from IRAM +- Change remove MQTT Info messages on restart for DeepSleep Wake (#8044) - Fix possible Relay toggle on (OTA) restart - Fix Zigbee sending wrong Sat value with Hue emulation - Add Zigbee command ``ZbRestore`` to restore device configuration dumped with ``ZbStatus 2`` - Add Zigbee command ``ZbUnbind`` - Add Zigbee command ``ZbBindState`` and ``manuf``attribute - Add commands ``CounterDebounceLow`` and ``CounterDebounceHigh`` to control debouncing (#8021) +- Add command ``SetOption90 1`` to disable non-json MQTT messages (#8044) - Add support for unreachable (unplugged) Zigbee devices in Philips Hue emulation and Alexa - Add support for 64x48 SSD1306 OLED (#6740) - Add support for up to four MQTT GroupTopics using the same optional Device Group names (#8014) diff --git a/tasmota/CHANGELOG.md b/tasmota/CHANGELOG.md index cf6941a6d..0b4f503bd 100644 --- a/tasmota/CHANGELOG.md +++ b/tasmota/CHANGELOG.md @@ -3,10 +3,12 @@ ### 8.2.0.3 20200329 - Change light scheme 2,3,4 cycle time speed from 24,48,72,... seconds to 4,6,12,24,36,48,... seconds (#8034) +- Change remove floating point libs from IRAM +- Change remove MQTT Info messages on restart for DeepSleep Wake (#8044) - Add support for longer template names - Add Zigbee command ``ZbBindState`` and ``manuf``attribute - Add commands ``CounterDebounceLow`` and ``CounterDebounceHigh`` to control debouncing (#8021) -- Change remove floating point libs from IRAM +- Add command ``SetOption90 1`` to disable non-json MQTT messages (#8044) ### 8.2.0.2 20200328 diff --git a/tasmota/settings.h b/tasmota/settings.h index 95b4779e6..18bd7f1c6 100644 --- a/tasmota/settings.h +++ b/tasmota/settings.h @@ -109,7 +109,7 @@ typedef union { // Restricted by MISRA-C Rule 18.4 bu uint32_t powered_off_led : 1; // bit 5 (v8.1.0.9) - SetOption87 - PWM Dimmer Turn red LED on when powered off uint32_t remote_device_mode : 1; // bit 6 (v8.1.0.9) - SetOption88 - PWM Dimmer Buttons control remote devices uint32_t zigbee_distinct_topics : 1; // bit 7 (v8.1.0.10) - SetOption89 - Distinct MQTT topics per device for Zigbee (#7835) - uint32_t spare08 : 1; + uint32_t only_json_message : 1; // bit 8 (v8.2.0.3) - SetOption90 - Disable non-json MQTT response uint32_t spare09 : 1; uint32_t spare10 : 1; uint32_t spare11 : 1; diff --git a/tasmota/xdrv_02_mqtt.ino b/tasmota/xdrv_02_mqtt.ino index ac3065fe8..912e7c929 100644 --- a/tasmota/xdrv_02_mqtt.ino +++ b/tasmota/xdrv_02_mqtt.ino @@ -440,9 +440,11 @@ void MqttPublishPowerState(uint32_t device) Response_P(S_JSON_COMMAND_SVALUE, scommand, GetStateText(bitRead(power, device -1))); MqttPublish(stopic); - GetTopic_P(stopic, STAT, mqtt_topic, scommand); - Response_P(GetStateText(bitRead(power, device -1))); - MqttPublish(stopic, Settings.flag.mqtt_power_retain); // CMND_POWERRETAIN + if (!Settings.flag4.only_json_message) { // SetOption90 - Disable non-json MQTT response + GetTopic_P(stopic, STAT, mqtt_topic, scommand); + Response_P(GetStateText(bitRead(power, device -1))); + MqttPublish(stopic, Settings.flag.mqtt_power_retain); // CMND_POWERRETAIN + } #ifdef USE_SONOFF_IFAN } #endif // USE_SONOFF_IFAN @@ -503,9 +505,11 @@ void MqttConnected(void) Response_P(PSTR(D_ONLINE)); MqttPublish(stopic, true); - // Satisfy iobroker (#299) - mqtt_data[0] = '\0'; - MqttPublishPrefixTopic_P(CMND, S_RSLT_POWER); + if (!Settings.flag4.only_json_message) { // SetOption90 - Disable non-json MQTT response + // Satisfy iobroker (#299) + mqtt_data[0] = '\0'; + MqttPublishPrefixTopic_P(CMND, S_RSLT_POWER); + } GetTopic_P(stopic, CMND, mqtt_topic, PSTR("#")); MqttSubscribe(stopic); @@ -526,30 +530,33 @@ void MqttConnected(void) } if (Mqtt.initial_connection_state) { - char stopic2[TOPSZ]; - Response_P(PSTR("{\"" D_CMND_MODULE "\":\"%s\",\"" D_JSON_VERSION "\":\"%s%s\",\"" D_JSON_FALLBACKTOPIC "\":\"%s\",\"" D_CMND_GROUPTOPIC "\":\"%s\"}"), - ModuleName().c_str(), my_version, my_image, GetFallbackTopic_P(stopic, ""), GetGroupTopic_P(stopic2, "", SET_MQTT_GRP_TOPIC)); - MqttPublishPrefixTopic_P(TELE, PSTR(D_RSLT_INFO "1")); + if (ResetReason() != REASON_DEEP_SLEEP_AWAKE) { + char stopic2[TOPSZ]; + Response_P(PSTR("{\"" D_CMND_MODULE "\":\"%s\",\"" D_JSON_VERSION "\":\"%s%s\",\"" D_JSON_FALLBACKTOPIC "\":\"%s\",\"" D_CMND_GROUPTOPIC "\":\"%s\"}"), + ModuleName().c_str(), my_version, my_image, GetFallbackTopic_P(stopic, ""), GetGroupTopic_P(stopic2, "", SET_MQTT_GRP_TOPIC)); + MqttPublishPrefixTopic_P(TELE, PSTR(D_RSLT_INFO "1")); #ifdef USE_WEBSERVER - if (Settings.webserver) { + if (Settings.webserver) { #if LWIP_IPV6 - Response_P(PSTR("{\"" D_JSON_WEBSERVER_MODE "\":\"%s\",\"" D_CMND_HOSTNAME "\":\"%s\",\"" D_CMND_IPADDRESS "\":\"%s\",\"IPv6Address\":\"%s\"}"), - (2 == Settings.webserver) ? D_ADMIN : D_USER, my_hostname, WiFi.localIP().toString().c_str(),WifiGetIPv6().c_str()); + Response_P(PSTR("{\"" D_JSON_WEBSERVER_MODE "\":\"%s\",\"" D_CMND_HOSTNAME "\":\"%s\",\"" D_CMND_IPADDRESS "\":\"%s\",\"IPv6Address\":\"%s\"}"), + (2 == Settings.webserver) ? D_ADMIN : D_USER, my_hostname, WiFi.localIP().toString().c_str(),WifiGetIPv6().c_str()); #else - Response_P(PSTR("{\"" D_JSON_WEBSERVER_MODE "\":\"%s\",\"" D_CMND_HOSTNAME "\":\"%s\",\"" D_CMND_IPADDRESS "\":\"%s\"}"), - (2 == Settings.webserver) ? D_ADMIN : D_USER, my_hostname, WiFi.localIP().toString().c_str()); + Response_P(PSTR("{\"" D_JSON_WEBSERVER_MODE "\":\"%s\",\"" D_CMND_HOSTNAME "\":\"%s\",\"" D_CMND_IPADDRESS "\":\"%s\"}"), + (2 == Settings.webserver) ? D_ADMIN : D_USER, my_hostname, WiFi.localIP().toString().c_str()); #endif // LWIP_IPV6 = 1 - MqttPublishPrefixTopic_P(TELE, PSTR(D_RSLT_INFO "2")); - } + MqttPublishPrefixTopic_P(TELE, PSTR(D_RSLT_INFO "2")); + } #endif // USE_WEBSERVER - Response_P(PSTR("{\"" D_JSON_RESTARTREASON "\":")); - if (CrashFlag()) { - CrashDump(); - } else { - ResponseAppend_P(PSTR("\"%s\""), GetResetReason().c_str()); + Response_P(PSTR("{\"" D_JSON_RESTARTREASON "\":")); + if (CrashFlag()) { + CrashDump(); + } else { + ResponseAppend_P(PSTR("\"%s\""), GetResetReason().c_str()); + } + ResponseJsonEnd(); + MqttPublishPrefixTopic_P(TELE, PSTR(D_RSLT_INFO "3")); } - ResponseJsonEnd(); - MqttPublishPrefixTopic_P(TELE, PSTR(D_RSLT_INFO "3")); + MqttPublishAllPowerState(); if (Settings.tele_period) { tele_period = Settings.tele_period -5; // Enable TelePeriod in 5 seconds