Skip to content

Commit

Permalink
Mqtt: add FloatSetter (#14246)
Browse files Browse the repository at this point in the history
  • Loading branch information
RenatusRo authored Jun 8, 2024
1 parent 554ce1d commit 133ebf4
Showing 1 changed file with 14 additions and 0 deletions.
14 changes: 14 additions & 0 deletions provider/mqtt.go
Original file line number Diff line number Diff line change
Expand Up @@ -157,6 +157,20 @@ func (m *Mqtt) IntSetter(param string) (func(int64) error, error) {
}, nil
}

var _ SetFloatProvider = (*Mqtt)(nil)

// FloatSetter publishes topic with parameter replaced by float value
func (m *Mqtt) FloatSetter(param string) (func(float64) error, error) {
return func(v float64) error {
payload, err := setFormattedValue(m.payload, param, v)
if err != nil {
return err
}

return m.client.Publish(m.topic, m.retained, payload)
}, nil
}

var _ SetBoolProvider = (*Mqtt)(nil)

// BoolSetter invokes script with parameter replaced by bool value
Expand Down

0 comments on commit 133ebf4

Please sign in to comment.