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

inputs.knx_listener: add support for String data type #15158

Closed
martinvonwittich opened this issue Apr 15, 2024 · 2 comments · Fixed by #15169
Closed

inputs.knx_listener: add support for String data type #15158

martinvonwittich opened this issue Apr 15, 2024 · 2 comments · Fixed by #15169
Labels
feature request Requests for new plugin and for new features to existing plugins

Comments

@martinvonwittich
Copy link
Contributor

Use Case

I'm using the knx_listener input to monitor a KNX bus. On the bus there's an MDT Glass Push-button that can receive a 14 byte Message telegram of type DPT 16.000 (ASCII text). I want to log and all other telegrams to a database.

Expected behavior

knx_listener should convert DPT 16.000 (ASCII text) to string.

Actual behavior

knx_listener fails to convert DPT 16.000 (ASCII text) to string:

Apr 15 11:46:16 hostname telegraf[1058269]: 2024-04-15T09:46:16Z D! [inputs.knx_listener] Matched GA "5/3/5" to measurement "<name of GA>" with value <ASCII contents of the message>
Apr 15 11:46:16 hostname telegraf[1058269]: 2024-04-15T09:46:16Z E! [inputs.knx_listener] Type conversion string failed for address "5/3/5"

This prevents the DPT 16.000 (ASCII text) telegrams from being logged.

Additional info

I'm not really familiar with Go, but this seems to be a simple fix - just add String to the existing conversion table:

hostname ~/telegraf # git diff plugins/inputs/knx_listener/knx_listener.go
diff --git a/plugins/inputs/knx_listener/knx_listener.go b/plugins/inputs/knx_listener/knx_listener.go
index f013fe638..f81dc9e1a 100644
--- a/plugins/inputs/knx_listener/knx_listener.go
+++ b/plugins/inputs/knx_listener/knx_listener.go
@@ -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

This seems to be working for me, knx_listener now successfully produces strings for the message telegrams.

@martinvonwittich martinvonwittich added the feature request Requests for new plugin and for new features to existing plugins label Apr 15, 2024
@srebhan
Copy link
Member

srebhan commented Apr 15, 2024

@martinvonwittich your change looks reasonable. Could you please submit a PR!?

@martinvonwittich
Copy link
Contributor Author

@martinvonwittich your change looks reasonable. Could you please submit a PR!?

Done!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
feature request Requests for new plugin and for new features to existing plugins
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants