Using serial binding to catch hex value

  • Platform information:
    • OS: Ubuntu 20.04
    • Java Runtime Environment: openjdk version “1.8.0_275”. OpenJDK Runtime Environment (Zulu (build 1.8.0_275-b01). OpenJDK 64-Bit Server VM (Zulu (build 25.275-b01, mixed mode)
    • openHAB version: 4.2.7
  • Issue of the topic: Hello all! I’m trying to catch a specific string from a serial port by following the serial binding documentation. My serial device is outputting bunch of hex data every second and I can see this content in openhab console by setting log level to DEBUG. An example string that I would like to catch looks like this, #02,00000A8D$\r\n, where A8D is the good part that I would like to get. My first issue is that I don’t seem to get the desired value with my regex and my second issue is to convert the hex value to decimal value.
    • Items configuration:
      String BB_Power "Home power consumption [%s]" { serial="/dev/ttyUSB0@38400,REGEX(^#02,00000([0-9a-fA-F]*).),CHARSET(ASCII)" }

    • Sitemap configuration:
      Frame {
      Text item=BB_Power

I should also add that I’m new here so please let me know If missed anything in my description and thanks in advance.

openhab.log (2.9 KB)