Skip to content

Commit 9059bb3

Browse files
martinvonwittichpull[bot]
authored andcommitted
feat(inputs.knx_listener): Add support for string data type (#15169)
1 parent 10f5229 commit 9059bb3

2 files changed

Lines changed: 5 additions & 0 deletions

File tree

plugins/inputs/knx_listener/knx_listener.go

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -187,6 +187,8 @@ func (kl *KNXListener) listen(acc telegraf.Accumulator) {
187187
value = vi.Uint()
188188
case reflect.Float32, reflect.Float64:
189189
value = vi.Float()
190+
case reflect.String:
191+
value = vi.String()
190192
default:
191193
kl.Log.Errorf("Type conversion %v failed for address %q", vi.Kind(), ga)
192194
continue

plugins/inputs/knx_listener/knx_listener_test.go

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,8 @@ func setValue(data dpt.DatapointValue, value interface{}) error {
3030
d.SetInt(v)
3131
case uint64:
3232
d.SetUint(v)
33+
case string:
34+
d.SetString(v)
3335
default:
3436
return fmt.Errorf("unknown type '%T' when setting value for DPT", value)
3537
}
@@ -104,6 +106,7 @@ func TestRegularReceives_DPT(t *testing.T) {
104106
{"14/0/4", "14.004", false, 1.00794, 1.00794},
105107
{"14/1/0", "14.010", false, 5963.78, 5963.78},
106108
{"14/1/1", "14.011", false, 150.95, 150.95},
109+
{"16/0/0", "16.000", false, "hello world", "hello world"},
107110
}
108111
acc := &testutil.Accumulator{}
109112

0 commit comments

Comments
 (0)