Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add option to move ZbReceived from json into the mqtt subtopic. #10353

Closed
wants to merge 2 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion tasmota/settings.h
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
9 changes: 6 additions & 3 deletions tasmota/xdrv_23_zigbee_2a_devices_impl.ino
Original file line number Diff line number Diff line change
Expand Up @@ -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?
Expand All @@ -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("}"));
}

Expand All @@ -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);
Expand Down