diff --git a/transport/mqtt/config.go b/transport/mqtt/config.go index 5003184..ae7ad17 100644 --- a/transport/mqtt/config.go +++ b/transport/mqtt/config.go @@ -8,7 +8,7 @@ import ( "github.com/google/uuid" "net" "os" - "path" + "path/filepath" "strings" "time" ) @@ -49,7 +49,7 @@ func (c *Config) check() error { var id string if len(os.Args) > 0 && len(os.Args[0]) > 0 { // Use executable name as first part of id - id = path.Base(os.Args[0]) + id = filepath.Base(os.Args[0]) } else { id = "htlib" } diff --git a/transport/mqtt/mqtt.go b/transport/mqtt/mqtt.go index 1163515..1171b4c 100644 --- a/transport/mqtt/mqtt.go +++ b/transport/mqtt/mqtt.go @@ -221,6 +221,12 @@ func (m *mqtt) onConnect(server string, _code byte, err error) { } } + if len(m.discoverSub) > 0 { + m.client.Subscribe( + &libmqtt.Topic{Name: m.discoverTopic}, + ) + } + if m.deviceState != nil { m.sendDiscover() }