From 675036a9d77e8d780c17a43ac07c7e7da66dba3e Mon Sep 17 00:00:00 2001 From: andig Date: Mon, 4 Nov 2024 09:55:02 +0100 Subject: [PATCH] Mqtt: fix panic --- cmd/setup.go | 2 +- provider/mqtt.go | 5 ++--- provider/mqtt_handler.go | 1 - 3 files changed, 3 insertions(+), 5 deletions(-) diff --git a/cmd/setup.go b/cmd/setup.go index 57612eb7fb..89cae4c4a3 100644 --- a/cmd/setup.go +++ b/cmd/setup.go @@ -474,7 +474,7 @@ func configureEnvironment(cmd *cobra.Command, conf *globalconfig.All) (err error } // setup machine id - if conf.Plant != "" { + if err == nil && conf.Plant != "" { // TODO decide wrapping err = machine.CustomID(conf.Plant) } diff --git a/provider/mqtt.go b/provider/mqtt.go index fffe132ab0..a1b9d08154 100644 --- a/provider/mqtt.go +++ b/provider/mqtt.go @@ -54,8 +54,6 @@ func NewMqttFromConfig(ctx context.Context, other map[string]interface{}) (Provi m = m.WithRetained() } - m.getter = defaultGetters(m, cc.Scale) - pipe, err := pipeline.New(log, cc.Settings) if err == nil { m = m.WithPipeline(pipe) @@ -73,6 +71,8 @@ func NewMqtt(log *util.Logger, client *mqtt.Client, topic string, timeout time.D timeout: timeout, } + m.getter = defaultGetters(m, 1) + return m } @@ -104,7 +104,6 @@ func (p *Mqtt) WithPipeline(pipeline *pipeline.Pipeline) *Mqtt { func (m *Mqtt) newReceiver() (*msgHandler, error) { h := &msgHandler{ topic: m.topic, - scale: m.scale, pipeline: m.pipeline, val: util.NewMonitor[string](m.timeout), } diff --git a/provider/mqtt_handler.go b/provider/mqtt_handler.go index ebeea2440e..e65f42da8f 100644 --- a/provider/mqtt_handler.go +++ b/provider/mqtt_handler.go @@ -6,7 +6,6 @@ import ( ) type msgHandler struct { - scale float64 topic string pipeline *pipeline.Pipeline val *util.Monitor[string]