Get uart data as string with different data formats

Good day all,

This will be my first topic in this community so lets get started :slight_smile:

I try to use ESPHome to send recieve uart messages towards a EVbox charging station. The message is send/recieved as string. Inside the string different data formats are used.

Below a print screen of the used data formats in the string:

When i give a start command (send over uart => RS485 => Charging station) the following response is given.

[00:08:47][D][button:010]: 'Start laden' Pressed.
[00:08:47][D][uart_debug:158]: >>> "\x020180310E046BC38ABF6681000000004A0A\x03\xFF\x02800131018E0A\x03\xFF"
[00:08:47][D][uart_debug:158]: <<< "\x02800131018E0A\x03\xFF"
[00:08:47][D][uart_debug:158]: <<< "\x02800122020E046BC38ABF668100000000AC0A\x03\xFF\x02018022010E046BC38ABF668100000000FFFFC309\x03\xFF"
[00:08:48][D][uart_debug:158]: <<< "\x02800126471500000000141F6100EDC19600000A2EE02F34F07800100010010064000000000000EC00EB00EE000000000000000003E803E803E8000000000000000003841388FB0B\x03\xFF\x020180"
[00:08:48][D][uart_debug:158]: <<< "26000000002E1B2B40737D\x03\xFF"

In oder to check if the start is made i need to get the values from the resonse string so that i can use them as sensor values.

I use the following code to log the communication and give the start command:

uart:
  id: uart_bus
  tx_pin: GPIO1
  rx_pin: GPIO3
  baud_rate: 38400
  debug:
    direction: BOTH
    dummy_receiver: true
    after:
      delimiter: "/n"
    sequence:
      #- lambda: UARTDebug::log_hex(direction, bytes, ':');
      #- lambda: UARTDebug::log_int(direction, bytes, ':');
      #- lambda: UARTDebug::log_binary(direction, bytes, ':'); 
      - lambda: UARTDebug::log_string(direction, bytes); 

- platform: template
    name: "Start laden"
    on_press:
      - output.turn_on: flowcontrol
      - uart.write: "\x020180310E046BC38ABF6681000000004A0A\x03"
      - delay: 1ms
      - uart.write: [0xFF] 
      - delay: 1ms
      - uart.write: "\x02800131018E0A\x03"
      - delay: 1ms
      - uart.write: [0xFF] 
      - output.turn_off: flowcontrol
      - delay: 100ms

You can take a look at this to see if it’s enough for your use case.