reconfigure mqtt when outlet description changed
This commit is contained in:
parent
32006e6598
commit
9aa5e864c7
@ -7,6 +7,7 @@ import (
|
|||||||
"time"
|
"time"
|
||||||
|
|
||||||
"git.openpdu.org/OpenPDU/openpdu/board"
|
"git.openpdu.org/OpenPDU/openpdu/board"
|
||||||
|
"git.openpdu.org/OpenPDU/openpdu/events"
|
||||||
"git.openpdu.org/OpenPDU/openpdu/mqtt"
|
"git.openpdu.org/OpenPDU/openpdu/mqtt"
|
||||||
"git.openpdu.org/OpenPDU/openpdu/outlet"
|
"git.openpdu.org/OpenPDU/openpdu/outlet"
|
||||||
"git.openpdu.org/OpenPDU/openpdu/syslog"
|
"git.openpdu.org/OpenPDU/openpdu/syslog"
|
||||||
@ -45,6 +46,7 @@ func CreateOutlets() {
|
|||||||
|
|
||||||
func init() {
|
func init() {
|
||||||
webui.SetMQTTReconfigFunction(MQTTreconfigure)
|
webui.SetMQTTReconfigFunction(MQTTreconfigure)
|
||||||
|
events.AddListener("outlet_config_changed", MQTTreconfigure)
|
||||||
// mqtt.MQTTReconfig = MQTTreconfigure()
|
// mqtt.MQTTReconfig = MQTTreconfigure()
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -72,10 +74,6 @@ func MQTTSetup() {
|
|||||||
"unique_id": viper.GetString("Mqtt.Prefix") + "_" + fmt.Sprint(o),
|
"unique_id": viper.GetString("Mqtt.Prefix") + "_" + fmt.Sprint(o),
|
||||||
"device": map[string]interface{}{
|
"device": map[string]interface{}{
|
||||||
"identifiers": []string{viper.GetString("Mqtt.Prefix")},
|
"identifiers": []string{viper.GetString("Mqtt.Prefix")},
|
||||||
// "name": viper.GetString("system.hostname"),
|
|
||||||
// "model": "OpenPDU",
|
|
||||||
// "sw_version": version,
|
|
||||||
// "manufacturer": "OpenPDU",
|
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -6,6 +6,7 @@ import (
|
|||||||
"strconv"
|
"strconv"
|
||||||
"strings"
|
"strings"
|
||||||
|
|
||||||
|
"git.openpdu.org/OpenPDU/openpdu/events"
|
||||||
"git.openpdu.org/OpenPDU/openpdu/outlet"
|
"git.openpdu.org/OpenPDU/openpdu/outlet"
|
||||||
"github.com/spf13/viper"
|
"github.com/spf13/viper"
|
||||||
"gopkg.in/macaron.v1"
|
"gopkg.in/macaron.v1"
|
||||||
@ -90,5 +91,7 @@ func outletEditPost(ctx *macaron.Context, f OutletPostForm) {
|
|||||||
|
|
||||||
viper.WriteConfig()
|
viper.WriteConfig()
|
||||||
|
|
||||||
|
events.FireEvent("outlet_config_changed")
|
||||||
|
|
||||||
ctx.Redirect("/outlets")
|
ctx.Redirect("/outlets")
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user