ASCII string to multiple integer or float values

Hello everybody

I have an Elsner weather station that sends me all their values combined as one single ASCII string every second by TCP.

e.g. W+05.5525280N99921.5N7121117170710N45780x03
(I know the exact positions of each value and the checksum.)

W = Start

0x03 = end marker

I managed to read the string as a whole with the TCP/UDP binding. But as an OH2 newbie I have no clue how to parse the string and save the values to seperate items (types: Number, String and Switch)
I know there are several transformation methods. But which one is the most suitable for me? And on which level should this conversion be performed? As a rule? RegEx?

(I have a working Grafana and InfluxDB setup and would like to store the weather data and control my heat pump.)

I searched this community but now I’m more confused than smarter.

TIA Matthias

Have a look into this thread (How to split a string in a rule)

Hallo Jürgen

I’ll give it a try.

But my content is not separated by a delimiter. Some values consist of 2 others of 8 bytes.
I would like to extract from position x to position y and save the content to an item.

Thanks

Matthias

https://docs.oracle.com/javase/7/docs/api/java/lang/String.html#substring(int)

I would probably use a REGEX though.

Sorry for my delay. I was traveling abroad. Thank you very much for you help.

I found a way to preprocess the output (on the MODBUS master device) of the weather station and separate the values with a delimiter (e.g. ‘;’)
This makes it easier to extract the values I need

e.g. W;+05.5;5;252;80:N; -…

I’ll try to implement this as soon as I find some time during the weekend.

Matthias

Thanks