Fix zigbee topic when using SO112

Fix zigbee topic when using SO112 ()
This commit is contained in:
Theo Arends 2020-12-23 13:55:54 +01:00
parent 25e3e5a42d
commit 5a29fffcc6
1 changed files with 9 additions and 10 deletions

View File

@ -534,20 +534,19 @@ void Z_Device::jsonPublishAttrList(const char * json_prefix, const Z_attribute_l
}
if (Settings.flag4.zigbee_distinct_topics) {
char subtopic[TOPSZ];
if (Settings.flag4.zb_topic_fname && friendlyName) {
//Clean special characters and check size of friendly name
// Clean special characters and check size of friendly name
char stemp[TOPSZ];
strlcpy(stemp, (!strlen(friendlyName)) ? MQTT_TOPIC : friendlyName, sizeof(stemp));
MakeValidMqtt(0, stemp);
//Create topic with Prefix3 and cleaned up friendly name
char frtopic[TOPSZ];
snprintf_P(frtopic, sizeof(frtopic), PSTR("%s/%s/" D_RSLT_SENSOR), SettingsText(SET_MQTTPREFIX3), stemp);
MqttPublish(frtopic, Settings.flag.mqtt_sensor_retain);
snprintf_P(subtopic, sizeof(subtopic), PSTR("%s/%s"), TasmotaGlobal.mqtt_topic, stemp);
} else {
char subtopic[16];
snprintf_P(subtopic, sizeof(subtopic), PSTR("%04X/" D_RSLT_SENSOR), shortaddr);
MqttPublishPrefixTopic_P(TELE, subtopic, Settings.flag.mqtt_sensor_retain);
snprintf_P(subtopic, sizeof(subtopic), PSTR("%s/%04X"), TasmotaGlobal.mqtt_topic, shortaddr);
}
char stopic[TOPSZ];
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);
}
@ -624,10 +623,10 @@ Z_Device & Z_Devices::parseDeviceFromName(const char * param, uint16_t * parsed_
}
/*********************************************************************************************\
*
*
* Methods below build a JSON representation of device data
* Used by: ZbLight, ZbStatus, ZbInfo
*
*
\*********************************************************************************************/
// Add "Device":"0x1234","Name":"FrienflyName"