Skip to content

Commit d172bed

Browse files
authored
Implement multi gateway discovery (#819)
Enable HASS to retrieve data of remote sensors from multiple gateways by using wildcards for the location (instead of default:home) and the gateway name (instead of default:OpenMQTTGateway)
1 parent 979211a commit d172bed

File tree

1 file changed

+4
-2
lines changed

1 file changed

+4
-2
lines changed

main/ZmqttDiscovery.ino

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -80,9 +80,11 @@ void createDiscovery(char* sensor_type,
8080
// the ACM-300.
8181
if (st_topic[0]) {
8282
char state_topic[mqtt_topic_max_size];
83-
strcpy(state_topic, mqtt_topic);
83+
// If not an entity belonging to the gateway we put wild card for the location and gateway name
84+
// allowing to have the entity detected by several gateways and a consistent discovery topic among the gateways
85+
child_device ? strcpy(state_topic, mqtt_topic) : strcpy(state_topic, "+/+");
8486
strcat(state_topic, st_topic);
85-
sensor.set("stat_t", state_topic); // state_topic
87+
sensor.set("stat_t", state_topic);
8688
}
8789

8890
sensor.set("name", s_name); //name

0 commit comments

Comments
 (0)