mqtt status

This commit is contained in:
Paolo Asperti 2021-10-01 16:56:50 +02:00
parent d37b7d08e7
commit 5c8960d8d2
Signed by: paspo
GPG Key ID: 06D46905D19D5182
2 changed files with 14 additions and 0 deletions

View File

@ -3,6 +3,7 @@ package webui
import (
"strings"
"git.openpdu.org/OpenPDU/openpdu/mqtt"
"github.com/spf13/viper"
"gopkg.in/macaron.v1"
)
@ -25,6 +26,12 @@ func mqttPage(ctx *macaron.Context) {
ctx.Data["password"] = viper.GetString("Mqtt.Password")
ctx.Data["homeassistant"] = viper.GetString("Mqtt.homeassistant")
if mqtt.Connected() {
ctx.Data["mqttstatus"] = "Connected"
} else {
ctx.Data["mqttstatus"] = "Disconnected"
}
ctx.Data["schemas"] = []string{"tcp", "ssl", "ws"}
ctx.HTML(200, "mqtt")
}

View File

@ -29,6 +29,13 @@
<form class="form-horizontal" method="post">
<div class="box-body">
<div class="form-group">
<label for="mqttstatus" class="col-sm-2 control-label">Status</label>
<div class="col-sm-10">
<input type="text" class="form-control" id="mqttstatus" disabled="" value="{{ mqttstatus }}">
</div>
</div>
<div class="form-group">
<label for="schema" class="col-sm-2 control-label">Schema</label>
<div class="col-sm-10">