Skip to content

Commit

Permalink
Mqtt: fix panic
Browse files Browse the repository at this point in the history
  • Loading branch information
andig committed Nov 4, 2024
1 parent 92a409c commit 675036a
Show file tree
Hide file tree
Showing 3 changed files with 3 additions and 5 deletions.
2 changes: 1 addition & 1 deletion cmd/setup.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
}
Expand Down
5 changes: 2 additions & 3 deletions provider/mqtt.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand All @@ -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
}

Expand Down Expand Up @@ -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),
}
Expand Down
1 change: 0 additions & 1 deletion provider/mqtt_handler.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@ import (
)

type msgHandler struct {
scale float64
topic string
pipeline *pipeline.Pipeline
val *util.Monitor[string]
Expand Down

0 comments on commit 675036a

Please sign in to comment.