From 90afef99daa77e7f5eb6732149c0ccdb59bcceac Mon Sep 17 00:00:00 2001 From: Stephan Hadinger Date: Thu, 28 Jan 2021 19:52:08 +0100 Subject: [PATCH] Zibee add ``SetOption120 1`` or ``ZbEndpointTopic`` to add the endpoint as suffix in topic when using ``SetOption89 1`` --- tasmota/i18n.h | 1 + tasmota/settings.h | 2 +- tasmota/xdrv_23_zigbee_2a_devices_impl.ino | 5 +++++ tasmota/xdrv_23_zigbee_A_impl.ino | 4 ++-- 4 files changed, 9 insertions(+), 3 deletions(-) diff --git a/tasmota/i18n.h b/tasmota/i18n.h index 28b1ea20d..49a7ea347 100644 --- a/tasmota/i18n.h +++ b/tasmota/i18n.h @@ -539,6 +539,7 @@ #define D_SO_ZIGBEE_ENDPOINTSUFFIX "EndpointSuffix" #define D_SO_ZIGBEE_NOAUTOBIND "NoAutoBind" #define D_SO_ZIGBEE_NAMETOPIC "NameTopic" +#define D_SO_ZIGBEE_ENDPOINTTOPIC "EndpointTopic" #define D_ZIGBEE_NOT_STARTED "Zigbee not started" #define D_CMND_ZIGBEE_PERMITJOIN "PermitJoin" #define D_CMND_ZIGBEE_STATUS "Status" diff --git a/tasmota/settings.h b/tasmota/settings.h index ae81668fd..b10c972a6 100644 --- a/tasmota/settings.h +++ b/tasmota/settings.h @@ -145,7 +145,7 @@ typedef union { // Restricted by MISRA-C Rule 18.4 bu 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 zb_received_as_subtopic : 1; // bit 4 (v9.2.0.3) - SetOption118 - (Zigbee) Move ZbReceived from JSON message and into the subtopic replacing "SENSOR" default uint32_t zb_omit_json_addr : 1; // bit 5 (v9.2.0.3) - SetOption119 - (Zigbee) Remove the device addr from json payload, can be used with zb_topic_fname where the addr is already known from the topic - uint32_t spare06 : 1; // bit 6 + uint32_t zb_topic_endpoint : 1; // bit 6 (v9.2.0.4) - SetOption120 - (Zigbee) Append endpoint number to topic if device dependent (use with SetOption89) uint32_t spare07 : 1; // bit 7 uint32_t spare08 : 1; // bit 8 uint32_t spare09 : 1; // bit 9 diff --git a/tasmota/xdrv_23_zigbee_2a_devices_impl.ino b/tasmota/xdrv_23_zigbee_2a_devices_impl.ino index b70a7edda..775621ffa 100644 --- a/tasmota/xdrv_23_zigbee_2a_devices_impl.ino +++ b/tasmota/xdrv_23_zigbee_2a_devices_impl.ino @@ -561,6 +561,11 @@ void Z_Device::jsonPublishAttrList(const char * json_prefix, const Z_attribute_l } else { snprintf_P(subtopic, sizeof(subtopic), PSTR("%s/%04X"), TasmotaGlobal.mqtt_topic, shortaddr); } + if (Settings.flag5.zb_topic_endpoint) { + if (attr_list.isValidSrcEp()) { + snprintf_P(subtopic, sizeof(subtopic), PSTR("%s_%d"), subtopic, attr_list.src_ep); + } + } char stopic[TOPSZ]; if (Settings.flag5.zb_received_as_subtopic) GetTopic_P(stopic, TELE, subtopic, json_prefix); diff --git a/tasmota/xdrv_23_zigbee_A_impl.ino b/tasmota/xdrv_23_zigbee_A_impl.ino index ddc0a1358..4c6bfa214 100644 --- a/tasmota/xdrv_23_zigbee_A_impl.ino +++ b/tasmota/xdrv_23_zigbee_A_impl.ino @@ -26,7 +26,7 @@ const char kZbCommands[] PROGMEM = D_PRFX_ZB "|" // prefix // SetOption synonyms D_SO_ZIGBEE_NAMEKEY "|" D_SO_ZIGBEE_DEVICETOPIC "|" D_SO_ZIGBEE_NOPREFIX "|" D_SO_ZIGBEE_ENDPOINTSUFFIX "|" D_SO_ZIGBEE_NOAUTOBIND "|" - D_SO_ZIGBEE_NAMETOPIC "|" + D_SO_ZIGBEE_NAMETOPIC "|" D_SO_ZIGBEE_ENDPOINTTOPIC "|" #ifdef USE_ZIGBEE_ZNP D_CMND_ZIGBEEZNPSEND "|" D_CMND_ZIGBEEZNPRECEIVE "|" #endif // USE_ZIGBEE_ZNP @@ -44,7 +44,7 @@ const char kZbCommands[] PROGMEM = D_PRFX_ZB "|" // prefix SO_SYNONYMS(kZbSynonyms, 83, 89, 100, 101, 110, - 112, + 112, 120, ); void (* const ZigbeeCommand[])(void) PROGMEM = {