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): Allow usage of DPT string representation #15069

Merged
merged 1 commit into from
Mar 27, 2024

Conversation

srebhan
Copy link
Contributor

@srebhan srebhan commented Mar 27, 2024

Summary

Some DPT's, especially DPT1.xxx, do have more speaking values in their string representation. Allow the user to choose between the two by introducing a new as_string flag.

Checklist

  • No AI generated code was used in this PR

Related issues

resolves #15039

@telegraf-tiger telegraf-tiger bot added feat Improvement on an existing feature such as adding a new setting/mode to an existing plugin plugin/input 1. Request for new input plugins 2. Issues/PRs that are related to input plugins labels Mar 27, 2024
@srebhan srebhan added area/iot New plugins or features relating to IoT monitoring feat Improvement on an existing feature such as adding a new setting/mode to an existing plugin and removed feat Improvement on an existing feature such as adding a new setting/mode to an existing plugin labels Mar 27, 2024
@telegraf-tiger
Copy link
Contributor

@srebhan srebhan added the ready for final review This pull request has been reviewed and/or tested by multiple users and is ready for a final review. label Mar 27, 2024
Copy link
Contributor

@powersj powersj left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Since this can be set per measurement, this works for me!

@powersj powersj removed their assignment Mar 27, 2024
@DStrand1 DStrand1 merged commit 212822e into influxdata:master Mar 27, 2024
26 checks passed
@github-actions github-actions bot added this to the v1.31.0 milestone Mar 27, 2024
@userwithoutpassword
Copy link

Works!

@userwithoutpassword
Copy link

userwithoutpassword commented Mar 28, 2024

One problem:

https://github.com/influxdata/telegraf/blob/release-1.29/plugins/inputs/knx_listener/README.md

"NOTE: You should not assign a group-address (GA) to multiple measurements!"

You CAN have a config like this:

[[inputs.knx_listener.measurement]]
  name = "Alarm3"
  dpt = "1.005"
  as_string = false
  addresses = ["0/2/2"] # Windalarm (Markise)


[[inputs.knx_listener.measurement]]
  name = "Alarm3"
  dpt = "1.005"
  as_string = false
  addresses = ["0/2/3",  # Windalarm (Raffstores)
               "0/2/4"] # Regenalarm

Different addresses to the same measurement. But as soon as you set one as_string=true and the other as_string=false

you get an error:

2024-03-28T15:49:41Z E! [outputs.influxdb_v2] Failed to write metric to TESTING (will be dropped: 422 Unprocessable Entity): unprocessable entity: failure writing points to database: partial write: field type conflict: input field "value" on measurement "Alarm2" is type string, already exists as type boolean dropped=2

so this

#   #   ## Use the string representation instead of the numerical value for the
#   #   ## datapoint-type and the addresses below

is not right. for each measurement u must decide if you want to string or boolean. You cannot decide on an address basis. This u should make clear in the comments.
per measurement its string OR boolean.

@srebhan
Copy link
Contributor Author

srebhan commented Apr 2, 2024

This is not true. The problem arises because you try to send a field of the same series with two different types. If you distinguish the two, e.g. by using different measurement names or tag-sets, the configuration works. Furthermore, this is a limitation of the output side and e.g. JSON output will work just fine...

@userwithoutpassword
Copy link

well, pls show me a configuration where u have one (the same) measurement but with different "as_string" settings.

@srebhan
Copy link
Contributor Author

srebhan commented Apr 3, 2024

@userwithoutpassword just a reminder, this is a community driven project, you can ask for help but demanding it the way you do is a bit rude IMO...

Anyway, the error is caused by the fact that your database already has the series Alarm2 for the given GA from previous data-acquisition with the value field as type boolean. Now you are trying to push the same value field as string to the same series and this causes a type conflict in InfluxDB. There are the following ways to resolve it AFAICS:

  1. Drop the existing data in the database. This causes a data-loss, so probably that's not what you want...
  2. Convert the existing data in the database to the new type. You probably need to export the old data, somehow convert it, drop the series involved and reimport the modified data.
  3. Convert the new data to the old type. That's probably not what you want because you asked for the string feature in the first place.
  4. Store the data with the new type in a new series by e.g. choosing a different measurement name.

The best solution strongly depends on your needs. However, there is nothing Telegraf can do about it! If you change a field type, you will always run into the problem above.

@userwithoutpassword
Copy link

userwithoutpassword commented Apr 3, 2024

Exactly. This is i was talking about 2 post earlier. You CANNOT assign different GAs to the same Measurement with different as_string settings. But the comments in the code are suggesting that.

"as_string" setting is per Measurement name

@srebhan
Copy link
Contributor Author

srebhan commented Apr 3, 2024

@userwithoutpassword please run the following config based on your example

[[inputs.knx_listener.measurement]]
  name = "alarm3"
  dpt = "1.005"
  as_string = false
  addresses = ["0/2/2"] # Windalarm (Markise)


[[inputs.knx_listener.measurement]]
  name = "alarm3"
  dpt = "1.005"
  as_string = true
  addresses = ["0/2/3",  "0/2/4"]

[[outputs.file]]
  files = ["stdout"]

with telegraf --config <the config above> --debug until the events come in. You should see three metrics

alarm3,groupaddress=0/2/2,source=0.0.0 value=true 1712145339611845102
alarm3,groupaddress=0/2/3,source=0.0.0 value="No alarm" 1712145339611854177
alarm3,groupaddress=0/2/4,source=0.0.0 value="Alarm" 1712145339611860590

with the correct output. As I said, the error you are seeing is due to the already existing data in your database...
What am I missing here?

@userwithoutpassword
Copy link

userwithoutpassword commented Apr 3, 2024

> 2024-04-03T12:08:33Z I! [inputs.knx_listener] Ignoring message {Command:Write Source:1.1.23 Destination:2/1/60 Data:[0 13 165]} for unknown GA "2/1/60"
Alarm4,groupaddress=0/2/2,host=influxdb,source=1.1.50 value=false 1712146109986144837
Windgeschwindigkeit,groupaddress=0/2/1,host=influxdb,source=1.1.50,unit=m/s value=0.699999988079071 1712146110019489939
2024-04-03T12:08:40Z I! [inputs.knx_listener] Ignoring message {Command:Write Source:1.1.115 Destination:13/5/11 Data:[0 12 96]} for unknown GA "13/5/11"
Windgeschwindigkeit,groupaddress=0/2/1,host=influxdb,source=1.1.50,unit=m/s value=1.5 1712146119991097346
Alarm4,groupaddress=0/2/3,host=influxdb,source=1.1.50 value="No alarm" 1712146120019108370
2024-04-03T12:08:44Z E! [outputs.influxdb_v2] Failed to write metric to TESTING (will be dropped: 422 Unprocessable Entity): unprocessable entity: failure writing points to database: partial write: field type conflict: input field "value" on measurement "Alarm4" is type string, already exists as type boolean dropped=1
2024-04-03T12:08:47Z I! [inputs.knx_listener] Ignoring message {Command:Write Source:1.1.110 Destination:10/3/95 Data:[1]} for unknown GA "10/3/95"
Alarm4,groupaddress=0/2/4,host=influxdb,source=1.1.51 value="No alarm" 1712146125283071409
2024-04-03T12:08:54Z E! [outputs.influxdb_v2] Failed to write metric to TESTING (will be dropped: 422 Unprocessable Entity): unprocessable entity: failure writing points to database: partial write: field type conflict: input field "value" on measurement "Alarm4" is type string, already exists as type boolean dropped=1
2024-04-03T12:08:55Z I! [inputs.knx_listener] Ignoring message {Command:Write Source:1.1.112 Destination:12/5/11 Data:[0 12 71]} for unknown GA "12/5/11"
2024-04-03T12:09:00Z I! [inputs.knx_listener] Ignoring message {Command:Write Source:1.1.240 Destination:26/5/11 Data:[0 12 12]} for unknown GA "26/5/11"
2024-04-03T12:09:01Z I! [inputs.knx_listener] Ignoring message {Command:Write Source:1.1.2 Destination:0/1/2 Data:[0 3 4 24]} for unknown GA "0/1/2"
2024-04-03T12:09:01Z I! [inputs.knx_listener] Ignoring message {Command:Write Source:1.1.2 Destination:0/1/1 Data:[0 110 9 0]} for unknown GA "0/1/1"
Alarm4,groupaddress=0/2/2,host=influxdb,source=1.1.50 value=false 1712146139983374738
2024-04-03T12:09:09Z I! [inputs.knx_listener] Ignoring message {Command:Write Source:1.1.109 Destination:13/3/150 Data:[0 83 116 101 108 108 32 86 111 114 108 97 117 102 32]} for unknown GA "13/3/150"
Windgeschwindigkeit,groupaddress=0/2/1,host=influxdb,source=1.1.50,unit=m/s value=2.5399999618530273 1712146149987197313
Alarm4,groupaddress=0/2/3,host=influxdb,source=1.1.50 value="No alarm" 1712146150014985456
2024-04-03T12:09:14Z E! [outputs.influxdb_v2] Failed to write metric to TESTING (will be dropped: 422 Unprocessable Entity): unprocessable entity: failure writing points to database: partial write: field type conflict: input field "value" on measurement "Alarm4" is type string, already exists as type boolean dropped=1
Alarm4,groupaddress=0/2/4,host=influxdb,source=1.1.51 value="No alarm" 1712146157285361391
2024-04-03T12:09:24Z E! [outputs.influxdb_v2] Failed to write metric to TESTING (will be dropped: 422 Unprocessable Entity): unprocessable entity: failure writing points to database: partial write: field type conflict: input field "value" on measurement "Alarm4" is type string, already exists as type boolean dropped=1
2024-04-03T12:09:27Z I! [inputs.knx_listener] Ignoring message {Command:Write Source:1.1.142 Destination:15/5/41 Data:[0 12 6]} for unknown GA "15/5/41"
2024-04-03T12:09:31Z I! [inputs.knx_listener] Ignoring message {Command:Write Source:1.1.131 Destination:11/5/21 Data:[0 7 218]} for unknown GA "11/5/21"
Alarm4,groupaddress=0/2/2,host=influxdb,source=1.1.50 value=false 1712146169979295799
Windgeschwindigkeit,groupaddress=0/2/1,host=influxdb,source=1.1.50,unit=m/s value=1.8700000047683716 1712146170013437314
Windgeschwindigkeit,groupaddress=0/2/1,host=influxdb,source=1.1.50,unit=m/s value=1.659999966621399 1712146179985615670
Alarm4,groupaddress=0/2/3,host=influxdb,source=1.1.50 value="No alarm" 1712146180013612368
2024-04-03T12:09:44Z E! [outputs.influxdb_v2] Failed to write metric to TESTING (will be dropped: 422 Unprocessable Entity): unprocessable entity: failure writing points to database: partial write: field type conflict: input field "value" on measurement "Alarm4" is type string, already exists as type boolean dropped=1
2024-04-03T12:09:50Z I! [inputs.knx_listener] Ignoring message {Command:Write Source:1.1.150 Destination:15/5/11 Data:[0 12 6]} for unknown GA "15/5/11"
Alarm4,groupaddress=0/2/4,host=influxdb,source=1.1.51 value="No alarm" 1712146189276290666
Windgeschwindigkeit,groupaddress=0/2/1,host=influxdb,source=1.1.50,unit=m/s value=1.4499999284744263 1712146189983578282
2024-04-03T12:09:54Z E! [outputs.influxdb_v2] Failed to write metric to TESTING (will be dropped: 422 Unprocessable Entity): unprocessable entity: failure writing points to database: partial write: field type conflict: input field "value" on measurement "Alarm4" is type string, already exists as type boolean dropped=1
2024-04-03T12:09:56Z I! [inputs.knx_listener] Ignoring message {Command:Write Source:1.1.120 Destination:14/5/21 Data:[0 12 16]} for unknown GA "14/5/21"
2024-04-03T12:10:01Z I! [inputs.knx_listener] Ignoring message {Command:Write Source:1.1.220 Destination:25/5/12 Data:[0 21 20]} for unknown GA "25/5/12"
Alarm4,groupaddress=0/2/2,host=influxdb,source=1.1.50 value=false 1712146199976280107
Windgeschwindigkeit,groupaddress=0/2/1,host=influxdb,source=1.1.50,unit=m/s value=3.119999885559082 1712146200010274624
Alarm4,groupaddress=0/2/3,host=influxdb,source=1.1.50 value="No alarm" 1712146209975457553
2024-04-03T12:10:14Z E! [outputs.influxdb_v2] Failed to write metric to TESTING (will be dropped: 422 Unprocessable Entity): unprocessable entity: failure writing points to database: partial write: field type conflict: input field "value" on measurement "Alarm4" is type string, already exists as type boolean dropped=1
2024-04-03T12:10:14Z I! [inputs.knx_listener] Ignoring message {Command:Response Source:1.1.235 Destination:24/2/14 Data:[0 0]} for unknown GA "24/2/14"
2024-04-03T12:10:17Z I! [inputs.knx_listener] Ignoring message {Command:Write Source:1.1.202 Destination:24/3/131 Data:[0 0]} for unknown GA "24/3/131"
2024-04-03T12:10:17Z I! [inputs.knx_listener] Ignoring message {Command:Write Source:1.1.202 Destination:25/3/131 Data:[0 0]} for unknown GA "25/3/131"
2024-04-03T12:10:17Z I! [inputs.knx_listener] Ignoring message {Command:Write Source:1.1.202 Destination:26/3/131 Data:[0 0]} for unknown GA "26/3/131"
2024-04-03T12:10:17Z I! [inputs.knx_listener] Ignoring message {Command:Write Source:1.1.202 Destination:27/3/131 Data:[0 0]} for unknown GA "27/3/131"
2024-04-03T12:10:18Z I! [inputs.knx_listener] Ignoring message {Command:Write Source:1.1.121 Destination:14/5/11 Data:[0 12 36]} for unknown GA "14/5/11"
Alarm4,groupaddress=0/2/4,host=influxdb,source=1.1.51 value="No alarm" 1712146221272928634
2024-04-03T12:10:24Z E! [outputs.influxdb_v2] Failed to write metric to TESTING (will be dropped: 422 Unprocessable Entity): unprocessable entity: failure writing points to database: partial write: field type conflict: input field "value" on measurement "Alarm4" is type string, already exists as type boolean dropped=1
Alarm4,groupaddress=0/2/2,host=influxdb,source=1.1.50 value=false 1712146229972516429
Windgeschwindigkeit,groupaddress=0/2/1,host=influxdb,source=1.1.50,unit=m/s value=2.759999990463257 1712146230005951586
2024-04-03T12:10:41Z I! [inputs.knx_listener] Ignoring message {Command:Write Source:1.1.220 Destination:25/5/11 Data:[0 12 116]} for unknown GA "25/5/11"
Alarm4,groupaddress=0/2/3,host=influxdb,source=1.1.50 value="No alarm" 1712146239972100701
2024-04-03T12:10:44Z E! [outputs.influxdb_v2] Failed to write metric to TESTING (will be dropped: 422 Unprocessable Entity): unprocessable entity: failure writing points to database: partial write: field type conflict: input field "value" on measurement "Alarm4" is type string, already exists as type boolean dropped=1
Windgeschwindigkeit,groupaddress=0/2/1,host=influxdb,source=1.1.50,unit=m/s value=3.3299999237060547 1712146249975471610
Alarm4,groupaddress=0/2/4,host=influxdb,source=1.1.51 value="No alarm" 1712146253271128693
2024-04-03T12:10:54Z E! [outputs.influxdb_v2] Failed to write metric to TESTING (will be dropped: 422 Unprocessable Entity): unprocessable entity: failure writing points to database: partial write: field type conflict: input field "value" on measurement "Alarm4" is type string, already exists as type boolean dropped=1

This is what i got. I used alarm4 an "empty" measurement...

The reason is if I set "as_string=false" telegraf will use boolean for DPT1.005. So i cannot push data to the same measurement with as_string=true for another GA but with the same measurement

For each measurement you have to decide if you want boolean OR string OR something else.

But the code works, just the commenting is a little bit missunderstanding.

@userwithoutpassword
Copy link

userwithoutpassword commented Apr 3, 2024

> 
-04-03T12:16:37Z I! Loading config: http://192.168.1.24:8086/api/v2/telegrafs/0cab241a1a975000
2024-04-03T12:16:37Z I! Starting Telegraf 1.31.0-32ef900d brought to you by InfluxData the makers of InfluxDB
2024-04-03T12:16:37Z I! Available plugins: 233 inputs, 9 aggregators, 31 processors, 24 parsers, 60 outputs, 6 secret-stores
2024-04-03T12:16:37Z I! Loaded inputs: knx_listener
2024-04-03T12:16:37Z I! Loaded aggregators: 
2024-04-03T12:16:37Z I! Loaded processors: 
2024-04-03T12:16:37Z I! Loaded secretstores: 
2024-04-03T12:16:37Z I! Loaded outputs: file influxdb_v2
2024-04-03T12:16:37Z I! Tags enabled: host=influxdb
2024-04-03T12:16:37Z I! [agent] Config: Interval:10s, Quiet:false, Hostname:"influxdb", Flush Interval:10s
2024-04-03T12:16:37Z D! [agent] Initializing plugins
2024-04-03T12:16:37Z D! [inputs.knx_listener] Group-address mapping for measurement "":
2024-04-03T12:16:37Z D! [inputs.knx_listener] Group-address mapping for measurement "Windgeschwindigkeit":
2024-04-03T12:16:37Z D! [inputs.knx_listener]   0/2/1 --> 9.005
2024-04-03T12:16:37Z D! [inputs.knx_listener] Group-address mapping for measurement "Außentemperatur(Dach)":
2024-04-03T12:16:37Z D! [inputs.knx_listener]   0/2/0 --> 9.001
2024-04-03T12:16:37Z D! [inputs.knx_listener] Group-address mapping for measurement "Gaszähler(aktueller Zählerstand)":
2024-04-03T12:16:37Z D! [inputs.knx_listener]   2/6/10 --> 14.076
2024-04-03T12:16:37Z D! [inputs.knx_listener] Group-address mapping for measurement "Gaszähler(aktueller Durchfluss)":
2024-04-03T12:16:37Z D! [inputs.knx_listener]   2/6/20 --> 14.1200
2024-04-03T12:16:37Z D! [inputs.knx_listener] Group-address mapping for measurement "Alarm4":
2024-04-03T12:16:37Z D! [inputs.knx_listener]   0/2/2 --> 1.005
2024-04-03T12:16:37Z D! [inputs.knx_listener] Group-address mapping for measurement "Alarm4":
2024-04-03T12:16:37Z D! [inputs.knx_listener]   0/2/3 --> 1.005
2024-04-03T12:16:37Z D! [inputs.knx_listener]   0/2/4 --> 1.005
2024-04-03T12:16:37Z D! [agent] Connecting outputs
2024-04-03T12:16:37Z D! [agent] Attempting connection to [outputs.influxdb_v2]
2024-04-03T12:16:37Z D! [agent] Successfully connected to outputs.influxdb_v2
2024-04-03T12:16:37Z D! [agent] Attempting connection to [outputs.file]
2024-04-03T12:16:37Z D! [agent] Successfully connected to outputs.file
2024-04-03T12:16:37Z D! [agent] Starting service inputs
2024-04-03T12:16:37Z I! [inputs.knx_listener] Trying to connect to "tunnel" at "192.168.1.106:3671"
2024-04-03T12:16:37Z I! [inputs.knx_listener] Connected!
2024-04-03T12:16:37Z I! [inputs.knx_listener] Ignoring message {Command:Write Source:1.1.111 Destination:12/5/21 Data:[0 12 41]} for unknown GA "12/5/21"
2024-04-03T12:16:38Z I! [inputs.knx_listener] Ignoring message {Command:Write Source:1.1.110 Destination:10/3/93 Data:[0 14 209]} for unknown GA "10/3/93"
2024-04-03T12:16:39Z D! [inputs.knx_listener] Matched GA "0/2/1" to measurement "Windgeschwindigkeit" with value 2.41 m/s
2024-04-03T12:16:39Z D! [inputs.knx_listener] Matched GA "0/2/3" to measurement "Alarm4" with value No alarm
2024-04-03T12:16:40Z I! [inputs.knx_listener] Ignoring message {Command:Write Source:1.1.115 Destination:13/5/11 Data:[0 12 96]} for unknown GA "13/5/11"
2024-04-03T12:16:40Z I! [inputs.knx_listener] Ignoring message {Command:Write Source:1.1.150 Destination:15/5/11 Data:[0 12 11]} for unknown GA "15/5/11"
Windgeschwindigkeit,groupaddress=0/2/1,host=influxdb,source=1.1.50,unit=m/s value=2.4099998474121094 1712146599935786216
Alarm4,groupaddress=0/2/3,host=influxdb,source=1.1.50 value="No alarm" 1712146599964414327
2024-04-03T12:16:47Z D! [outputs.file] Wrote batch of 2 metrics in 119.173µs
2024-04-03T12:16:47Z D! [outputs.file] Buffer fullness: 0 / 10000 metrics
2024-04-03T12:16:47Z E! [outputs.influxdb_v2] Failed to write metric to TESTING (will be dropped: 422 Unprocessable Entity): unprocessable entity: failure writing points to database: partial write: field type conflict: input field "value" on measurement "Alarm4" is type string, already exists as type boolean dropped=1
2024-04-03T12:16:47Z D! [outputs.influxdb_v2] Wrote batch of 2 metrics in 3.452136ms
2024-04-03T12:16:47Z D! [outputs.influxdb_v2] Buffer fullness: 0 / 10000 metrics
2024-04-03T12:16:49Z D! [inputs.knx_listener] Matched GA "0/2/1" to measurement "Windgeschwindigkeit" with value 3.12 m/s
2024-04-03T12:16:51Z I! [inputs.knx_listener] Ignoring message {Command:Write Source:1.1.50 Destination:0/2/6 Data:[0 70 135]} for unknown GA "0/2/6"
2024-04-03T12:16:55Z I! [inputs.knx_listener] Ignoring message {Command:Write Source:1.1.112 Destination:12/5/11 Data:[0 12 71]} for unknown GA "12/5/11"
Windgeschwindigkeit,groupaddress=0/2/1,host=influxdb,source=1.1.50,unit=m/s value=3.119999885559082 1712146609935047533
2024-04-03T12:16:57Z D! [outputs.file] Wrote batch of 1 metrics in 42.499µs
2024-04-03T12:16:57Z D! [outputs.file] Buffer fullness: 0 / 10000 metrics
2024-04-03T12:16:57Z D! [outputs.influxdb_v2] Wrote batch of 1 metrics in 2.502226ms
2024-04-03T12:16:57Z D! [outputs.influxdb_v2] Buffer fullness: 0 / 10000 metrics
2024-04-03T12:16:57Z I! [inputs.knx_listener] Ignoring message {Command:Write Source:1.1.109 Destination:13/3/131 Data:[0 66]} for unknown GA "13/3/131"
2024-04-03T12:16:59Z D! [inputs.knx_listener] Matched GA "0/2/2" to measurement "Alarm4" with value No alarm
2024-04-03T12:16:59Z D! [inputs.knx_listener] Matched GA "0/2/1" to measurement "Windgeschwindigkeit" with value 2.56 m/s
2024-04-03T12:17:00Z I! [inputs.knx_listener] Ignoring message {Command:Write Source:1.1.240 Destination:26/5/11 Data:[0 12 10]} for unknown GA "26/5/11"

the same with --debug

@srebhan
Copy link
Contributor Author

srebhan commented Apr 3, 2024

@userwithoutpassword I think you do have a misunderstanding here. Let me try again to explain my point.

As you can see in your first output the metrics are produced correctly on the input side:

Alarm4,groupaddress=0/2/2,host=influxdb,source=1.1.50 value=false 1712146109986144837
Alarm4,groupaddress=0/2/3,host=influxdb,source=1.1.50 value="No alarm" 1712146120019108370
Alarm4,groupaddress=0/2/4,host=influxdb,source=1.1.51 value="No alarm" 1712146125283071409
Alarm4,groupaddress=0/2/2,host=influxdb,source=1.1.50 value=false 1712146139983374738
Alarm4,groupaddress=0/2/3,host=influxdb,source=1.1.50 value="No alarm" 1712146150014985456
Alarm4,groupaddress=0/2/4,host=influxdb,source=1.1.51 value="No alarm" 1712146157285361391
Alarm4,groupaddress=0/2/2,host=influxdb,source=1.1.50 value=false 1712146169979295799
Alarm4,groupaddress=0/2/3,host=influxdb,source=1.1.50 value="No alarm" 1712146180013612368
Alarm4,groupaddress=0/2/4,host=influxdb,source=1.1.51 value="No alarm" 1712146189276290666
Alarm4,groupaddress=0/2/2,host=influxdb,source=1.1.50 value=false 1712146199976280107
Alarm4,groupaddress=0/2/3,host=influxdb,source=1.1.50 value="No alarm" 1712146209975457553
Alarm4,groupaddress=0/2/4,host=influxdb,source=1.1.51 value="No alarm" 1712146221272928634
Alarm4,groupaddress=0/2/2,host=influxdb,source=1.1.50 value=false 1712146229972516429
Alarm4,groupaddress=0/2/3,host=influxdb,source=1.1.50 value="No alarm" 1712146239972100701
Alarm4,groupaddress=0/2/4,host=influxdb,source=1.1.51 value="No alarm" 1712146253271128693

with grep '^Alarm4 on your output. So the input side works as described in the KNX plugin!

Now you get the error messages like

2024-04-03T12:09:14Z E! [outputs.influxdb_v2] Failed to write metric to TESTING (will be dropped: 422 Unprocessable Entity): unprocessable entity: failure writing points to database: partial write: field type conflict: input field "value" on measurement "Alarm4" is type string, already exists as type boolean dropped=1

This error is produced by the InfluxDB instance not by Telegraf! So you do have an issue with the output side because InfluxDB insists you provide the same type, but this has NOTHING to with the KNX plugin besides that it produces the data by chance. We cannot fix this on the input side because there are other outputs that support this kind of mixed types!

This being said, testing InfluxDBv2 you seemingly cannot used mixed types for a field of the same measurement, but again, other outputs work.

@userwithoutpassword
Copy link

userwithoutpassword commented Apr 3, 2024

I know this.
Only this comment

#   #   ## Use the string representation instead of the numerical value for the
#   #   ## datapoint-type and the addresses below

is confusing because it's suggesting that you can have different as_string settings for the same measurment, but u cannot.
For InfluxDB they all have to be the same for the same measurement.

You cannot set as_string per GA, only per measurement. If you want to have one GA as string and the other not u have so use a different measurement.

The plugin is working as it should.

Its just a hint ;) I have no intend using this in that way. I was only testing with different settings

Maybe u add in the comment this limitation when using togehter with influxdb

@srebhan
Copy link
Contributor Author

srebhan commented Apr 3, 2024

For InfluxDB they all have to be the same for the same measurement.

But this is true for InfluxDB only and it's not even fully true for v1 which can have different types, one per series IIRC!!! That's why I'm so hesitant to follow your argumentation because then we load input documentation with the limitations of all possible output plugins (and we do have many of those). This would create a precedence-case...

@userwithoutpassword
Copy link

userwithoutpassword commented Apr 3, 2024

yeah I understand. The most important thing is that its actually working. And thats the case

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area/iot New plugins or features relating to IoT monitoring feat Improvement on an existing feature such as adding a new setting/mode to an existing plugin plugin/input 1. Request for new input plugins 2. Issues/PRs that are related to input plugins ready for final review This pull request has been reviewed and/or tested by multiple users and is ready for a final review.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

inputs.knx_listener is ignoring "String-Value" for 1Bit DPTs
4 participants