diff --git a/tasmota/include/tasmota_globals.h b/tasmota/include/tasmota_globals.h index 3fe15e195..7a7492877 100644 --- a/tasmota/include/tasmota_globals.h +++ b/tasmota/include/tasmota_globals.h @@ -314,6 +314,9 @@ String EthernetMacAddress(void); #ifndef MQTT_LWT_ONLINE #define MQTT_LWT_ONLINE "Online" // MQTT LWT online topic message #endif +#ifndef MQTT_DISABLE_MODBUSRECEIVED +#define MQTT_DISABLE_MODBUSRECEIVED 0 // 1 = Disable ModbusReceived mqtt messages, 0 = Enable ModbusReceived mqtt messages (default) +#endif #ifndef MESSZ #define MESSZ 1040 // Max number of characters in JSON message string (Hass discovery and nice MQTT_MAX_PACKET_SIZE = 1200) diff --git a/tasmota/include/tasmota_types.h b/tasmota/include/tasmota_types.h index b2df33857..6df44ec1c 100755 --- a/tasmota/include/tasmota_types.h +++ b/tasmota/include/tasmota_types.h @@ -191,7 +191,7 @@ typedef union { // Restricted by MISRA-C Rule 18.4 bu uint32_t zcfallingedge : 1; // bit 9 (v13.0.0.1) - SetOption155 - (ZCDimmer) Enable rare falling Edge dimmer instead of leading edge uint32_t sen5x_passive_mode : 1; // bit 10 (v13.1.0.1) - SetOption156 - (Sen5x) Run in passive mode when there is another I2C master (e.g. Ikea Vindstyrka), i.e. do not set up Sen5x sensor, higher polling interval uint32_t neopool_outputsensitive : 1; // bit 11 (v13.2.0.1) - SetOption157 - (NeoPool) Output sensitive data (1) - uint32_t spare12 : 1; // bit 12 + uint32_t mqtt_disable_modbus : 1; // bit 12 (v13.2.0.1) - SetOption158 - (MQTT) Disable publish ModbusReceived MQTT messages, you must use event trigger rules instead. uint32_t spare13 : 1; // bit 13 uint32_t spare14 : 1; // bit 14 uint32_t spare15 : 1; // bit 15 diff --git a/tasmota/my_user_config.h b/tasmota/my_user_config.h index 530a4199c..45fca83a1 100644 --- a/tasmota/my_user_config.h +++ b/tasmota/my_user_config.h @@ -418,6 +418,7 @@ #define MQTT_TELE_RETAIN 0 // Tele messages may send retain flag (0 = off, 1 = on) #define MQTT_CLEAN_SESSION 1 // Mqtt clean session connection (0 = No clean session, 1 = Clean session (default)) #define MQTT_DISABLE_SSERIALRECEIVED 0 // 1 = Disable sserialreceived mqtt messages, 0 = Enable sserialreceived mqtt messages (default) +#define MQTT_DISABLE_MODBUSRECEIVED 0 // 1 = Disable ModbusReceived mqtt messages, 0 = Enable ModbusReceived mqtt messages (default) // -- MQTT - Domoticz ----------------------------- #define USE_DOMOTICZ // Enable Domoticz (+6k code, +0.3k mem) diff --git a/tasmota/tasmota_support/settings.ino b/tasmota/tasmota_support/settings.ino index 987192320..cd31f2ee3 100644 --- a/tasmota/tasmota_support/settings.ino +++ b/tasmota/tasmota_support/settings.ino @@ -1121,6 +1121,7 @@ void SettingsDefaultSet2(void) { flag5.mqtt_persistent |= ~MQTT_CLEAN_SESSION; flag6.mqtt_disable_sserialrec |= MQTT_DISABLE_SSERIALRECEIVED; // flag.mqtt_serial |= 0; + flag6.mqtt_disable_modbus |= MQTT_DISABLE_MODBUSRECEIVED; flag.device_index_enable |= MQTT_POWER_FORMAT; flag3.time_append_timezone |= MQTT_APPEND_TIMEZONE; flag3.button_switch_force_local |= MQTT_BUTTON_SWITCH_FORCE_LOCAL; diff --git a/tasmota/tasmota_xdrv_driver/xdrv_63_modbus_bridge.ino b/tasmota/tasmota_xdrv_driver/xdrv_63_modbus_bridge.ino index ed82cd0ff..bc3f78bbf 100644 --- a/tasmota/tasmota_xdrv_driver/xdrv_63_modbus_bridge.ino +++ b/tasmota/tasmota_xdrv_driver/xdrv_63_modbus_bridge.ino @@ -380,7 +380,11 @@ void ModbusBridgeHandle(void) } ResponseAppend_P(PSTR("]}")); ResponseJsonEnd(); - MqttPublishPrefixTopicRulesProcess_P(RESULT_OR_TELE, PSTR(D_JSON_MODBUS_RECEIVED)); + if (Settings->flag6.mqtt_disable_modbus ) { // SetOption158 If it is activated, Tasmota will not publish ModbusReceived MQTT messages, but it will proccess event trigger rules + XdrvRulesProcess(0); + } else { + MqttPublishPrefixTopicRulesProcess_P(RESULT_OR_TELE, PSTR(D_JSON_MODBUS_RECEIVED)); + } } else if (modbusBridge.type == ModbusBridgeType::mb_hex) { @@ -394,7 +398,11 @@ void ModbusBridgeHandle(void) } ResponseAppend_P(PSTR("]}")); ResponseJsonEnd(); - MqttPublishPrefixTopicRulesProcess_P(RESULT_OR_TELE, PSTR(D_JSON_MODBUS_RECEIVED)); + if (Settings->flag6.mqtt_disable_modbus ) { // SetOption158 If it is activated, Tasmota will not publish ModbusReceived MQTT messages, but it will proccess event trigger rules + XdrvRulesProcess(0); + } else { + MqttPublishPrefixTopicRulesProcess_P(RESULT_OR_TELE, PSTR(D_JSON_MODBUS_RECEIVED)); + } } else if ((modbusBridge.buffer[1] > 0) && (modbusBridge.buffer[1] < 7)) { @@ -556,7 +564,11 @@ void ModbusBridgeHandle(void) ResponseAppend_P(PSTR("}")); ResponseJsonEnd(); if (errorcode == ModbusBridgeError::noerror) - MqttPublishPrefixTopicRulesProcess_P(RESULT_OR_TELE, PSTR(D_JSON_MODBUS_RECEIVED)); + if (Settings->flag6.mqtt_disable_modbus ) { // SetOption158 If it is activated, Tasmota will not publish ModbusReceived MQTT messages, but it will proccess event trigger rules + XdrvRulesProcess(0); + } else { + MqttPublishPrefixTopicRulesProcess_P(RESULT_OR_TELE, PSTR(D_JSON_MODBUS_RECEIVED)); + } } else errorcode = ModbusBridgeError::wrongfunctioncode;