Ble_client, reading multiple values from the same service_uuid in a decent way

I am reading multiple values via Bluetooth from the same Service UUID of a G32 barbeque unit. The way I am doing this is as follows:

  - platform: ble_client
    ble_client_id: ow_g32
    type: characteristic
    name: "G32 Zone 1"
    id: g32_T_1
    service_uuid: 'dc0f41ea-b6ae-46a8-a19e-1a3bf4342bcb'
    characteristic_uuid: 'dc0f41e2-b6ae-46a8-a19e-1a3bf4342bcb'
    device_class: "temperature"
    unit_of_measurement: "°C"
    update_interval: 10s
    lambda: |-
      return (x[6]*10.0+x[7]/10.0);
    on_value:
      - lambda: id(zone1_value) = x;
      - lvgl.widget.refresh: [zone1_label, zone1_arc, zone1_label2]

  - platform: ble_client
    ble_client_id: ow_g32
    type: characteristic
    name: "G32 Zone 2"
    id: g32_T_2
    service_uuid: 'dc0f41ea-b6ae-46a8-a19e-1a3bf4342bcb'
    characteristic_uuid: 'dc0f41e2-b6ae-46a8-a19e-1a3bf4342bcb'
    device_class: "temperature"
    unit_of_measurement: "°C"
    update_interval: 3000s
    lambda: |-
      return (x[8]*10.0+x[9]/10.0);
    on_value:
      - lambda: id(zone2_value) = x;
      - lvgl.widget.refresh: [zone2_label, zone2_arc, zone2_label2]

The update interval shall be 10 seconds. When reading the Service UUID,
the G32 sends the complete data block with 31 bytes containing all the values I need.
So, reading the first value g32_T_1 (first temperature probe) I will get the full 31 bytes (and all values are updated after this read!) and reading the next value g32_T_2 (second temperature probe) I will receive the same 31 bytes again (and update all values again). Reading all (~12) values will read the same 31 bytes 12 times.
This is the reason why I changed the update interval of all other values to a big number.

This is not very elegant. Is there any other way this could be accomplished?

Jörg.

I have never used ble_client sensor, so there can be more elegant ways for this, but you can simply pass the data on your lambda to multiple template sensors before return.

How would this look like in my example?

I don’t have time to get into it right now, but as an example your zone1 sensor lambda could pass zone 2 sensor value to template sensor like this: (just an example, I don’t know what type of data your device outputs).

I hope I made the concept clear.

1 Like

I changed my code according to your information and it is much cleaner now!
Thank you very much!

Jörg.

Happy to help you.

1 Like