Skip to content

Commit 4467ef9

Browse files
authored
Fix missing gateway name in discovery. (#982)
1 parent 2ece72d commit 4467ef9

File tree

5 files changed

+11
-5
lines changed

5 files changed

+11
-5
lines changed

main/ZgatewayPilight.ino

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -84,7 +84,7 @@ void setupPilight() {
8484
pinMode(RF_EMITTER_GPIO, OUTPUT); // Set this here, because if this is the RX pin it was reset to INPUT by Serial.end();
8585
Log.notice(F("RF_EMITTER_GPIO: %d " CR), RF_EMITTER_GPIO);
8686
Log.notice(F("RF_RECEIVER_GPIO: %d " CR), RF_RECEIVER_GPIO);
87-
Log.trace(F("ZgatewayPilight command topic: %s%s" CR), mqtt_topic, subjectMQTTtoPilight);
87+
Log.trace(F("ZgatewayPilight command topic: %s%s%s" CR), mqtt_topic, gateway_name, subjectMQTTtoPilight);
8888
Log.trace(F("ZgatewayPilight setup done " CR));
8989
}
9090

main/ZgatewayRF.ino

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -70,7 +70,7 @@ void setupRF() {
7070
# endif
7171
mySwitch.setRepeatTransmit(RF_EMITTER_REPEAT);
7272
mySwitch.enableReceive(RF_RECEIVER_GPIO);
73-
Log.trace(F("ZgatewayRF command topic: %s%s" CR), mqtt_topic, subjectMQTTtoRF);
73+
Log.trace(F("ZgatewayRF command topic: %s%s%s" CR), mqtt_topic, gateway_name, subjectMQTTtoRF);
7474
Log.trace(F("ZgatewayRF setup done" CR));
7575
}
7676

main/ZgatewayRF2.ino

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,7 @@ void setupRF2() {
6464
NewRemoteReceiver::init(RF_RECEIVER_GPIO, 2, rf2Callback);
6565
Log.notice(F("RF_EMITTER_GPIO: %d " CR), RF_EMITTER_GPIO);
6666
Log.notice(F("RF_RECEIVER_GPIO: %d " CR), RF_RECEIVER_GPIO);
67-
Log.trace(F("ZgatewayRF2 command topic: %s%s" CR), mqtt_topic, subjectMQTTtoRF2);
67+
Log.trace(F("ZgatewayRF2 command topic: %s%s%s" CR), mqtt_topic, gateway_name, subjectMQTTtoRF2);
6868
Log.trace(F("ZgatewayRF2 setup done " CR));
6969
pinMode(RF_EMITTER_GPIO, OUTPUT);
7070
digitalWrite(RF_EMITTER_GPIO, LOW);

main/ZgatewayRTL_433.ino

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,7 @@ void rtl_433_Callback(char* message) {
6565
void setupRTL_433() {
6666
rtl_433.initReceiver(RF_RECEIVER_GPIO, receiveMhz);
6767
rtl_433.setCallback(rtl_433_Callback, messageBuffer, JSON_MSG_BUFFER);
68-
Log.trace(F("ZgatewayRTL_433 command topic: %s%s" CR), mqtt_topic, subjectMQTTtoRTL_433);
68+
Log.trace(F("ZgatewayRTL_433 command topic: %s%s%s" CR), mqtt_topic, gateway_name, subjectMQTTtoRTL_433);
6969
Log.notice(F("ZgatewayRTL_433 setup done " CR));
7070
}
7171

main/ZmqttDiscovery.ino

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -85,7 +85,12 @@ void createDiscovery(const char* sensor_type,
8585
char state_topic[mqtt_topic_max_size];
8686
// If not an entity belonging to the gateway we put wild card for the location and gateway name
8787
// allowing to have the entity detected by several gateways and a consistent discovery topic among the gateways
88-
gateway_entity ? strcpy(state_topic, mqtt_topic) : strcpy(state_topic, "+/+");
88+
if (gateway_entity) {
89+
strcpy(state_topic, mqtt_topic);
90+
strcat(state_topic, gateway_name);
91+
} else {
92+
strcpy(state_topic, "+/+");
93+
}
8994
strcat(state_topic, st_topic);
9095
sensor.set("stat_t", state_topic);
9196
}
@@ -114,6 +119,7 @@ void createDiscovery(const char* sensor_type,
114119
if (cmd_topic[0]) {
115120
char command_topic[mqtt_topic_max_size];
116121
strcpy(command_topic, mqtt_topic);
122+
strcat(command_topic, gateway_name);
117123
strcat(command_topic, cmd_topic);
118124
sensor.set("cmd_t", command_topic); //command_topic
119125
}

0 commit comments

Comments
 (0)