Skip to content

Commit

Permalink
Removed flat MQTT hierarchy as filtering with MQTT wildcards has the …
Browse files Browse the repository at this point in the history
…same result
  • Loading branch information
fredlcore committed Dec 5, 2024
1 parent f77487c commit fedeac5
Showing 1 changed file with 0 additions and 9 deletions.
9 changes: 0 additions & 9 deletions BSB_LAN/include/mqtt_handler.h
Original file line number Diff line number Diff line change
Expand Up @@ -52,11 +52,8 @@ void mqtt_sendtoBroker(parameter param) {
StringBuffer sb_topic;
initStringBuffer(&sb_payload, MQTTPayload, sizeof(MQTTPayload));
initStringBuffer(&sb_topic, MQTTTopic, sizeof(MQTTTopic));
#if defined(NO_MQTT_CATEGORY)
appendStringBuffer(&sb_topic, "%s/%d/%g/status", MQTTTopicPrefix, (param.dest_addr==-1?bus->getBusDest():param.dest_addr), param.number);
#else
appendStringBuffer(&sb_topic, "%s/%d/%d/%g/status", MQTTTopicPrefix, (param.dest_addr==-1?bus->getBusDest():param.dest_addr), decodedTelegram.cat, param.number);
#endif
switch(mqtt_mode)
{
// =============================================
Expand Down Expand Up @@ -315,11 +312,8 @@ void mqtt_callback(char* topic, byte* passed_payload, unsigned int length) {

// New get/set hierarchy topic: BSB-LAN/<device id>/<category>/<parameter>/set|inf|poll
// Optional payload will be used for set command
#if defined(NO_MQTT_HIERARCHY)
if (sscanf(topic+topic_len, "/%d/%g/%s", &parsed_device, &parsed_parameter, parsed_command) == 3) {
#else
if (sscanf(topic+topic_len, "/%d/%d/%g/%s", &parsed_device, &parsed_category, &parsed_parameter, parsed_command) == 4) {
#endif
param.dest_addr = parsed_device;
param.number = parsed_parameter;
if (!strcmp(parsed_command, "poll")) {
Expand Down Expand Up @@ -448,11 +442,8 @@ boolean mqtt_send_discovery(boolean create=true) {
loadPrognrElementsFromTable(line, i);
loadCategoryDescAddr();
appendStringBuffer(&sb_topic, "homeassistant/");
#if defined(NO_MQTT_CATEGORY)
appendStringBuffer(&sb_payload, "{\"~\":\"%s/%d/%g\",\"unique_id\":\"%g-%d-%d-%d\",\"state_topic\":\"~/status\",", MQTTTopicPrefix, bus->getBusDest(), line, line, cmdtbl[i].dev_fam, cmdtbl[i].dev_var, my_dev_serial);
#else
appendStringBuffer(&sb_payload, "{\"~\":\"%s/%d/%d/%g\",\"unique_id\":\"%g-%d-%d-%d\",\"state_topic\":\"~/status\",", MQTTTopicPrefix, bus->getBusDest(), decodedTelegram.cat, line, line, cmdtbl[i].dev_fam, cmdtbl[i].dev_var, my_dev_serial);
#endif
if (decodedTelegram.isswitch) {
appendStringBuffer(&sb_payload, "\"icon\":\"mdi:toggle-switch\",");
} else if (!strcmp(decodedTelegram.unit, U_DEG) || !strcmp(decodedTelegram.unit, U_TEMP_PER_MIN) || !strcmp(decodedTelegram.unit, U_CEL_MIN)) {
Expand Down

0 comments on commit fedeac5

Please sign in to comment.