Skip to content

Commit

Permalink
feat(inputs.knx_listener): Add support for string data type (#15169)
Browse files Browse the repository at this point in the history
  • Loading branch information
martinvonwittich authored Apr 16, 2024
1 parent 47e4d45 commit 583e7cd
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 0 deletions.
2 changes: 2 additions & 0 deletions plugins/inputs/knx_listener/knx_listener.go
Original file line number Diff line number Diff line change
Expand Up @@ -187,6 +187,8 @@ func (kl *KNXListener) listen(acc telegraf.Accumulator) {
value = vi.Uint()
case reflect.Float32, reflect.Float64:
value = vi.Float()
case reflect.String:
value = vi.String()
default:
kl.Log.Errorf("Type conversion %v failed for address %q", vi.Kind(), ga)
continue
Expand Down
3 changes: 3 additions & 0 deletions plugins/inputs/knx_listener/knx_listener_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,8 @@ func setValue(data dpt.DatapointValue, value interface{}) error {
d.SetInt(v)
case uint64:
d.SetUint(v)
case string:
d.SetString(v)
default:
return fmt.Errorf("unknown type '%T' when setting value for DPT", value)
}
Expand Down Expand Up @@ -104,6 +106,7 @@ func TestRegularReceives_DPT(t *testing.T) {
{"14/0/4", "14.004", false, 1.00794, 1.00794},
{"14/1/0", "14.010", false, 5963.78, 5963.78},
{"14/1/1", "14.011", false, 150.95, 150.95},
{"16/0/0", "16.000", false, "hello world", "hello world"},
}
acc := &testutil.Accumulator{}

Expand Down

0 comments on commit 583e7cd

Please sign in to comment.