diff --git a/main.go b/main.go index b5eca01..7002a09 100644 --- a/main.go +++ b/main.go @@ -33,7 +33,7 @@ func main() { opts.OnConnect = connectHandler opts.SetKeepAlive(20 * time.Second) opts.SetAutoReconnect(true) - opts.SetWill("mqtt2exec/"+os.Args[2]+"/state", "offline", 1, false) + opts.SetWill("mqtt2exec/"+os.Args[2]+"/state", "offline", 1, true) client := mqtt.NewClient(opts) sleep := 1 * time.Second for { @@ -72,5 +72,5 @@ func connectHandler(c mqtt.Client) { if token.Error() != nil { log.Printf("mqtt2exec: Error subscribing to topic: %s", token.Error()) } - c.Publish("mqtt2exec/"+os.Args[2]+"/state", 1, false, "online") + c.Publish("mqtt2exec/"+os.Args[2]+"/state", 1, true, "online") }