diff --git a/tasmota/settings.h b/tasmota/settings.h index 4842103b42bb..9016b01921f5 100644 --- a/tasmota/settings.h +++ b/tasmota/settings.h @@ -143,7 +143,7 @@ typedef union { // Restricted by MISRA-C Rule 18.4 bu uint32_t mi32_enable : 1; // bit 1 (v9.1.0.1) - SetOption115 - (ESP32 BLE) Enable ESP32 MI32 BLE (1) uint32_t zb_disable_autoquery : 1; // bit 2 (v9.1.0.1) - SetOption116 - (Zigbee) Disable auto-query of zigbee lights and devices (1) uint32_t fade_fixed_duration : 1; // bit 3 (v9.1.0.2) - SetOption117 - (Light) run fading at fixed duration instead of fixed slew rate - uint32_t spare04 : 1; // bit 4 + uint32_t zb_received_as_subtopic : 1; // bit 4 (v9.2.0.3) - SetOption118 - (Zigbee) Move ZbReceived form JSON message and into the subtopic replacing "SENSOR" default uint32_t spare05 : 1; // bit 5 uint32_t spare06 : 1; // bit 6 uint32_t spare07 : 1; // bit 7 diff --git a/tasmota/xdrv_23_zigbee_2a_devices_impl.ino b/tasmota/xdrv_23_zigbee_2a_devices_impl.ino index 0a97a9938fe5..0f175e688473 100644 --- a/tasmota/xdrv_23_zigbee_2a_devices_impl.ino +++ b/tasmota/xdrv_23_zigbee_2a_devices_impl.ino @@ -511,7 +511,7 @@ void Z_Device::jsonPublishAttrList(const char * json_prefix, const Z_attribute_l TasmotaGlobal.mqtt_data[0] = 0; // clear string // Do we prefix with `ZbReceived`? - if (!Settings.flag4.remove_zbreceived) { + if (!Settings.flag4.remove_zbreceived && !Settings.flag5.zb_received_as_subtopic) { Response_P(PSTR("{\"%s\":"), json_prefix); } // What key do we use, shortaddr or name? @@ -529,7 +529,7 @@ void Z_Device::jsonPublishAttrList(const char * json_prefix, const Z_attribute_l // Add all other attributes ResponseAppend_P(PSTR("%s}}"), attr_list.toString(false).c_str()); - if (!Settings.flag4.remove_zbreceived) { + if (!Settings.flag4.remove_zbreceived && !Settings.flag5.zb_received_as_subtopic) { ResponseAppend_P(PSTR("}")); } @@ -545,7 +545,10 @@ void Z_Device::jsonPublishAttrList(const char * json_prefix, const Z_attribute_l snprintf_P(subtopic, sizeof(subtopic), PSTR("%s/%04X"), TasmotaGlobal.mqtt_topic, shortaddr); } char stopic[TOPSZ]; - GetTopic_P(stopic, TELE, subtopic, D_RSLT_SENSOR); + if (Settings.flag5.zb_received_as_subtopic) + GetTopic_P(stopic, TELE, subtopic, json_prefix); + else + GetTopic_P(stopic, TELE, subtopic, D_RSLT_SENSOR); MqttPublish(stopic, Settings.flag.mqtt_sensor_retain); } else { MqttPublishPrefixTopic_P(TELE, PSTR(D_RSLT_SENSOR), Settings.flag.mqtt_sensor_retain);