diff --git a/CHANGELOG.md b/CHANGELOG.md index 88bbfbb1b..5825555a2 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -13,6 +13,7 @@ All notable changes to this project will be documented in this file. ### Changed - Matter refactoring of bridged devices (#21575) - ESP32 Core3 platform update from 2024.05.13 to 2024.06.10 (#21569) +- Optional MQTT_TELE_RETAIN to Energy Margins message replaced by ``SensorRetain`` ### Fixed - Berry `input()` returns empty string and does not crash (#21565) diff --git a/RELEASENOTES.md b/RELEASENOTES.md index 5e2f81d1e..33fce959a 100644 --- a/RELEASENOTES.md +++ b/RELEASENOTES.md @@ -125,6 +125,7 @@ The latter links can be used for OTA upgrades too like ``OtaUrl https://ota.tasm - Matter support for Air Quality sensors [#21559](https://github.com/arendst/Tasmota/issues/21559) ### Changed +- Optional MQTT_TELE_RETAIN to Energy Margins message replaced by ``SensorRetain`` - ESP32 Core3 platform update from 2024.05.13 to 2024.06.10 [#21569](https://github.com/arendst/Tasmota/issues/21569) - Matter refactoring of bridged devices [#21575](https://github.com/arendst/Tasmota/issues/21575) diff --git a/tasmota/tasmota_xdrv_driver/xdrv_02_9_mqtt.ino b/tasmota/tasmota_xdrv_driver/xdrv_02_9_mqtt.ino index 9a793f8d1..6cde49eb3 100644 --- a/tasmota/tasmota_xdrv_driver/xdrv_02_9_mqtt.ino +++ b/tasmota/tasmota_xdrv_driver/xdrv_02_9_mqtt.ino @@ -861,13 +861,19 @@ void MqttPublishPrefixTopicRulesProcess_P(uint32_t prefix, const char* subtopic) MqttPublishPrefixTopicRulesProcess_P(prefix, subtopic, false); } -void MqttPublishTeleSensor(void) { - // Publish tele//SENSOR default ResponseData string with optional retained +void MqttPublishTele(const char* subtopic) { + // Publish tele// default ResponseData string with optional retained // then process rules #ifdef USE_INFLUXDB InfluxDbProcess(1); // Use a copy of ResponseData #endif - MqttPublishPrefixTopicRulesProcess_P(TELE, PSTR(D_RSLT_SENSOR), Settings->flag.mqtt_sensor_retain); // CMND_SENSORRETAIN + MqttPublishPrefixTopicRulesProcess_P(TELE, subtopic, Settings->flag.mqtt_sensor_retain); // CMND_SENSORRETAIN +} + +void MqttPublishTeleSensor(void) { + // Publish tele//SENSOR default ResponseData string with optional retained + // then process rules + MqttPublishTele(PSTR(D_RSLT_SENSOR)); } void MqttPublishPowerState(uint32_t device) { diff --git a/tasmota/tasmota_xdrv_driver/xdrv_03_energy.ino b/tasmota/tasmota_xdrv_driver/xdrv_03_energy.ino index 0d15ffd4f..7f1498278 100644 --- a/tasmota/tasmota_xdrv_driver/xdrv_03_energy.ino +++ b/tasmota/tasmota_xdrv_driver/xdrv_03_energy.ino @@ -29,10 +29,6 @@ //#define USE_ENERGY_MARGIN_DETECTION // #define USE_ENERGY_POWER_LIMIT -#ifndef MQTT_TELE_RETAIN -#define MQTT_TELE_RETAIN 0 -#endif - #define ENERGY_NONE 0 #define ENERGY_WATCHDOG 4 // Allow up to 4 seconds before deciding no valid data present @@ -564,7 +560,7 @@ void EnergyMarginCheck(void) { } if (jsonflg) { ResponseJsonEndEnd(); - MqttPublishPrefixTopicRulesProcess_P(TELE, PSTR(D_RSLT_MARGINS), MQTT_TELE_RETAIN); + MqttPublishTele(PSTR(D_RSLT_MARGINS)); EnergyMqttShow(); Energy->margin_stable = 3; // Allow 2 seconds to stabilize before reporting } diff --git a/tasmota/tasmota_xdrv_driver/xdrv_03_esp32_energy.ino b/tasmota/tasmota_xdrv_driver/xdrv_03_esp32_energy.ino index 64f4f271a..790fc79a6 100644 --- a/tasmota/tasmota_xdrv_driver/xdrv_03_esp32_energy.ino +++ b/tasmota/tasmota_xdrv_driver/xdrv_03_esp32_energy.ino @@ -26,10 +26,6 @@ #define XDRV_03 3 #define XSNS_03 3 -#ifndef MQTT_TELE_RETAIN -#define MQTT_TELE_RETAIN 0 -#endif - #define ENERGY_NONE 0 #define ENERGY_WATCHDOG 4 // Allow up to 4 seconds before deciding no valid data present @@ -787,7 +783,7 @@ void EnergyMarginCheck(void) { } if (jsonflg) { ResponseJsonEndEnd(); - MqttPublishPrefixTopicRulesProcess_P(TELE, PSTR(D_RSLT_MARGINS), MQTT_TELE_RETAIN); + MqttPublishTele(PSTR(D_RSLT_MARGINS)); EnergyMqttShow(); Energy->margin_stable = 3; // Allow 2 seconds to stabilize before reporting }