reconfigure mqtt when outlet description changed

This commit is contained in:
Paolo Asperti 2021-12-09 18:40:14 +01:00
parent 32006e6598
commit 9aa5e864c7
Signed by: paspo
GPG Key ID: 06D46905D19D5182
2 changed files with 5 additions and 4 deletions

View File

@ -7,6 +7,7 @@ import (
"time"
"git.openpdu.org/OpenPDU/openpdu/board"
"git.openpdu.org/OpenPDU/openpdu/events"
"git.openpdu.org/OpenPDU/openpdu/mqtt"
"git.openpdu.org/OpenPDU/openpdu/outlet"
"git.openpdu.org/OpenPDU/openpdu/syslog"
@ -45,6 +46,7 @@ func CreateOutlets() {
func init() {
webui.SetMQTTReconfigFunction(MQTTreconfigure)
events.AddListener("outlet_config_changed", MQTTreconfigure)
// mqtt.MQTTReconfig = MQTTreconfigure()
}
@ -72,10 +74,6 @@ func MQTTSetup() {
"unique_id": viper.GetString("Mqtt.Prefix") + "_" + fmt.Sprint(o),
"device": map[string]interface{}{
"identifiers": []string{viper.GetString("Mqtt.Prefix")},
// "name": viper.GetString("system.hostname"),
// "model": "OpenPDU",
// "sw_version": version,
// "manufacturer": "OpenPDU",
},
}

View File

@ -6,6 +6,7 @@ import (
"strconv"
"strings"
"git.openpdu.org/OpenPDU/openpdu/events"
"git.openpdu.org/OpenPDU/openpdu/outlet"
"github.com/spf13/viper"
"gopkg.in/macaron.v1"
@ -90,5 +91,7 @@ func outletEditPost(ctx *macaron.Context, f OutletPostForm) {
viper.WriteConfig()
events.FireEvent("outlet_config_changed")
ctx.Redirect("/outlets")
}