Merge remote branch 'go-rewrite' into go-rewrite

This commit is contained in:
Paolo Asperti 2021-10-01 14:42:06 +02:00
commit c50d17a497
Signed by: paspo
GPG Key ID: 06D46905D19D5182
2 changed files with 7 additions and 1 deletions

View File

@ -57,6 +57,6 @@ func InitBoards() {
var b board.Board var b board.Board
for i := range boards { for i := range boards {
b = *boards[i] b = *boards[i]
b.Initialize() go b.Initialize()
} }
} }

View File

@ -90,12 +90,18 @@ func Disconnect() {
} }
func Publish(topic string, value string) { func Publish(topic string, value string) {
if MQTTclient == nil {
return
}
if MQTTclient.IsConnected() { if MQTTclient.IsConnected() {
MQTTclient.Publish(viper.GetString("Mqtt.Prefix")+"/switch/"+topic, 0, false, value) MQTTclient.Publish(viper.GetString("Mqtt.Prefix")+"/switch/"+topic, 0, false, value)
} }
} }
func PublishRoot(topic string, value string) { func PublishRoot(topic string, value string) {
if MQTTclient == nil {
return
}
if MQTTclient.IsConnected() { if MQTTclient.IsConnected() {
MQTTclient.Publish(topic, 0, false, value) MQTTclient.Publish(topic, 0, false, value)
} }