diff --git a/main/ZgatewaySERIAL.ino b/main/ZgatewaySERIAL.ino index 0fb7ee5cf1..8e4dd22928 100644 --- a/main/ZgatewaySERIAL.ino +++ b/main/ZgatewaySERIAL.ino @@ -205,6 +205,12 @@ void SERIALtoX() { } else { // send as json if (SERIALdata.containsKey("origin") || SERIALdata.containsKey("topic")) { +# ifdef ZmqttDiscovery + // We need to assign the discovery message to the primary module instead of the secondary module + if (SERIALdata.containsKey("device") && SERIALdata["device"].containsKey("via_device")) { + SERIALdata["device"]["via_device"] = gateway_name; + } +# endif enqueueJsonObject(SERIALdata); } else { SERIALdata["origin"] = subjectSERIALtoMQTT;