diff --git a/main/ZgatewayPilight.ino b/main/ZgatewayPilight.ino index dcafbd2..8fe8d69 100644 --- a/main/ZgatewayPilight.ino +++ b/main/ZgatewayPilight.ino @@ -84,7 +84,7 @@ void setupPilight() { pinMode(RF_EMITTER_GPIO, OUTPUT); // Set this here, because if this is the RX pin it was reset to INPUT by Serial.end(); Log.notice(F("RF_EMITTER_GPIO: %d " CR), RF_EMITTER_GPIO); Log.notice(F("RF_RECEIVER_GPIO: %d " CR), RF_RECEIVER_GPIO); - Log.trace(F("ZgatewayPilight command topic: %s%s" CR), mqtt_topic, subjectMQTTtoPilight); + Log.trace(F("ZgatewayPilight command topic: %s%s%s" CR), mqtt_topic, gateway_name, subjectMQTTtoPilight); Log.trace(F("ZgatewayPilight setup done " CR)); } diff --git a/main/ZgatewayRF.ino b/main/ZgatewayRF.ino index d9c897e..733722f 100644 --- a/main/ZgatewayRF.ino +++ b/main/ZgatewayRF.ino @@ -70,7 +70,7 @@ void setupRF() { # endif mySwitch.setRepeatTransmit(RF_EMITTER_REPEAT); mySwitch.enableReceive(RF_RECEIVER_GPIO); - Log.trace(F("ZgatewayRF command topic: %s%s" CR), mqtt_topic, subjectMQTTtoRF); + Log.trace(F("ZgatewayRF command topic: %s%s%s" CR), mqtt_topic, gateway_name, subjectMQTTtoRF); Log.trace(F("ZgatewayRF setup done" CR)); } diff --git a/main/ZgatewayRF2.ino b/main/ZgatewayRF2.ino index e3b249f..6cf679a 100644 --- a/main/ZgatewayRF2.ino +++ b/main/ZgatewayRF2.ino @@ -64,7 +64,7 @@ void setupRF2() { NewRemoteReceiver::init(RF_RECEIVER_GPIO, 2, rf2Callback); Log.notice(F("RF_EMITTER_GPIO: %d " CR), RF_EMITTER_GPIO); Log.notice(F("RF_RECEIVER_GPIO: %d " CR), RF_RECEIVER_GPIO); - Log.trace(F("ZgatewayRF2 command topic: %s%s" CR), mqtt_topic, subjectMQTTtoRF2); + Log.trace(F("ZgatewayRF2 command topic: %s%s%s" CR), mqtt_topic, gateway_name, subjectMQTTtoRF2); Log.trace(F("ZgatewayRF2 setup done " CR)); pinMode(RF_EMITTER_GPIO, OUTPUT); digitalWrite(RF_EMITTER_GPIO, LOW); diff --git a/main/ZgatewayRTL_433.ino b/main/ZgatewayRTL_433.ino index b124a4c..decf14e 100644 --- a/main/ZgatewayRTL_433.ino +++ b/main/ZgatewayRTL_433.ino @@ -65,7 +65,7 @@ void rtl_433_Callback(char* message) { void setupRTL_433() { rtl_433.initReceiver(RF_RECEIVER_GPIO, receiveMhz); rtl_433.setCallback(rtl_433_Callback, messageBuffer, JSON_MSG_BUFFER); - Log.trace(F("ZgatewayRTL_433 command topic: %s%s" CR), mqtt_topic, subjectMQTTtoRTL_433); + Log.trace(F("ZgatewayRTL_433 command topic: %s%s%s" CR), mqtt_topic, gateway_name, subjectMQTTtoRTL_433); Log.notice(F("ZgatewayRTL_433 setup done " CR)); } diff --git a/main/ZmqttDiscovery.ino b/main/ZmqttDiscovery.ino index 57423a3..59d4546 100644 --- a/main/ZmqttDiscovery.ino +++ b/main/ZmqttDiscovery.ino @@ -85,7 +85,12 @@ void createDiscovery(const char* sensor_type, char state_topic[mqtt_topic_max_size]; // If not an entity belonging to the gateway we put wild card for the location and gateway name // allowing to have the entity detected by several gateways and a consistent discovery topic among the gateways - gateway_entity ? strcpy(state_topic, mqtt_topic) : strcpy(state_topic, "+/+"); + if (gateway_entity) { + strcpy(state_topic, mqtt_topic); + strcat(state_topic, gateway_name); + } else { + strcpy(state_topic, "+/+"); + } strcat(state_topic, st_topic); sensor.set("stat_t", state_topic); } @@ -114,6 +119,7 @@ void createDiscovery(const char* sensor_type, if (cmd_topic[0]) { char command_topic[mqtt_topic_max_size]; strcpy(command_topic, mqtt_topic); + strcat(command_topic, gateway_name); strcat(command_topic, cmd_topic); sensor.set("cmd_t", command_topic); //command_topic }