Mqtt: fix panic

This commit is contained in:
andig 2024-11-04 09:55:02 +01:00
parent 92a409c722
commit 675036a9d7
3 changed files with 3 additions and 5 deletions

View file

@ -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)
}

View file

@ -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),
}

View file

@ -6,7 +6,6 @@ import (
)
type msgHandler struct {
scale float64
topic string
pipeline *pipeline.Pipeline
val *util.Monitor[string]