Fix missing gateway name in discovery. (#982)
This commit is contained in:
1 parent
2ece72dd68
commit
4467ef9a17
5 files changed
+11
-5
No files matched your search
@@ -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));
|
||||
}
|
||||
|
||||
|
||||
+1
-1
@@ -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));
|
||||
}
|
||||
|
||||
|
||||
@@ -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);
|
||||
|
||||
@@ -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));
|
||||
}
|
||||
|
||||
|
||||
@@ -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
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user