Help: "Error reading char at handle 14, status=2"

I’ve just bought this medical cooling box which is Bluetooth capable. The vendor provides a very simple and primitive Android app which lets you monitor the cooling box its temperature and the battery status (I’m not interested in battery status as the device is always on 230V power line in my case anyway).
What I would like to do now is to monitor the cooling box its temperature with EPSHome in Home Assistant by using an ESP32 microcontroller with bluetooth capability instead of the Android app.
Now for reverse engineering, what I recently did, is to generate a bluetooth bug report with my Android phone while connected via the Vendor’s Android app by Bluetooth and then imported the bug report into Wireshark. In combination with the vendor’s instructions on GitHub about the Bluetooth communication protocol I could already find out which values I have to write (send) and read (receive) via ESP32 to get the according byte array which contains the according byte, holding the current temperature of the cooling box (I marked it yellow in the following screenshot):

So with this information I set up the following ESPHome testing code:

esp32_ble_tracker:

ble_client:
  - mac_address: f4:b5:ed:bf:10:a9
    id: my_ble_client

time:
  - platform: sntp
    on_time:
      - seconds: /5
        then:
          - ble_client.ble_write:
              id: my_ble_client
              service_uuid: 0000fee9-0000-1000-8000-00805f9b34fb
              characteristic_uuid: d44bc439-abfd-45a2-b575-925416129600
              value: [0xaa, 0x8f, 0x01, 0x55]

sensor:
  - platform: ble_client
    type: characteristic
    ble_client_id: my_ble_client
    update_interval: 5s
    name: "Temperature"
    service_uuid: 0000fee9-0000-1000-8000-00805f9b34fb
    characteristic_uuid: d44bc439-abfd-45a2-b575-925416129601
    unit_of_measurement: '°C'
    lambda: |-
      uint16_t test = x[2];
      float temp = (float)test;
      return temp / 10;

Now the code for the ESP32 device works and as far as I can see I am able to write (send) to the cooling box device but something seems wrong with the read (received) data and I am not able to find out what it is. The ESPHome logs are showing the following message frequently:

[ble_sensor:080]: Error reading char at handle 14, status=2

When I do not insert the sensor’s lambda function then there is no error message appearing so I guess it must have something to do with wrong formatted or wrong parsed values or something.

I feel I am so damn close but I’m at the end of my knowledge with this error.
Any help would be very appreciated.
Thanks in advance!

Edit: Here are the complete ESPHome logfiles for downloading.

Could you maybe print each one of these intermediate values to the log to see which sub-step is causing the error perhaps? Or otherwise break it down? That’s all I’ve got;)

There’s some logging examples here…
https://esphome.io/custom/custom_component.html#generic-custom-component

@Mahko_Mahko Thanks for the hint. Unfortunately I am not able to log anything out of this.
It seems the sensor won’t even enter the lamdba function:

Here’s the code where I tried to log (the return value is jost something random, I only wanted to test the logging code):

sensor:
  - platform: ble_client
    type: characteristic
    ble_client_id: my_ble_client
    update_interval: 5s
    name: "Temperature"
    service_uuid: 0000fee9-0000-1000-8000-00805f9b34fb
    characteristic_uuid: d44bc439-abfd-45a2-b575-925416129601
    unit_of_measurement: '°C'
    lambda: |-
      uint16_t test = x[2];
      char buffer [33];
      itoa(test,buffer,10);
      ESP_LOGD("debug", buffer);
      return 10;

Any hints on what I am doing wrong?
Thank you in advance!

EDIT: I just found out that the same error even occurs when I leave away the whole lambda function like this:

sensor:
  - platform: ble_client
    type: characteristic
    ble_client_id: my_ble_client
    update_interval: 5s
    name: "Temperature"
    service_uuid: 0000fee9-0000-1000-8000-00805f9b34fb
    characteristic_uuid: d44bc439-abfd-45a2-b575-925416129601
    unit_of_measurement: '°C'

So something seems preventing the sensor from reading, I have no idea what it could be :frowning:

Got it finally working with the following code now, the notify option was clearly missing in this case:

ble_client:
  - mac_address: f4:b5:ed:bf:10:a9
    id: LifeinaBox

time:
  - platform: sntp
    on_time:
      - seconds: /30
        then:
          - ble_client.ble_write:
              id: LifeinaBox
              service_uuid: 0000fee9-0000-1000-8000-00805f9b34fb
              characteristic_uuid: d44bc439-abfd-45a2-b575-925416129600
              value: [0xaa, 0x8f, 0x01, 0x55]

sensor:
  - platform: ble_client
    type: characteristic
    ble_client_id: LifeinaBox
    name: "Temperature"
    service_uuid: 0000fee9-0000-1000-8000-00805f9b34fb
    characteristic_uuid: d44bc439-abfd-45a2-b575-925416129601
    unit_of_measurement: '°C'
    accuracy_decimals: 1
    notify: true
    lambda: |-
      uint8_t test = x[2];
      float temp = (float)test;
      return temp / 10;