Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(inputs.knx_listener): Add support for string data type #15169

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading