Hi
I am trying to use BLE Tracker hub in ESPHome to send values from my custom BLE sensor (power meter) to HA.
BLE sensor sends Service Data advertising for battery state, instant power use, hourly pulse count (watts), daily pulse count (watts).
Need some assistance to get the values out of service data. I am following the BLE Tracker hub example
ESP_LOGD("ble_adv", " Advertised service data:");
for (auto data : x.get_service_datas()) {
ESP_LOGD("ble_adv", " - %s: (length %i)", data.uuid.to_string().c_str(), data.data.size());
}
It gets the reading as per below. I just dont know how to get the actual value for each UUID instead of its size, which I guess is in bytes?
[11:25:34][D][ble_adv:049]: Advertised service data:
[11:25:34][D][ble_adv:051]: - 0x2A03: (length 1)
[11:25:34][D][ble_adv:051]: - 0x2A04: (length 1)
[11:25:34][D][ble_adv:051]: - 0x2A05: (length 1)
[11:25:34][D][ble_adv:051]: - 0x180F: (length 1)
I dont want to be using the BLE_Client to query services, as it would cause the battery to deplete quicker. I just want to parse the advertised service data and update HA
I am using this at the moment:
esp32_ble_tracker:
on_ble_service_data_advertise:
- mac_address: 11:22:33:44:55:66
service_uuid: 181A
then:
- lambda: 'id(ble_sensor).publish_state(x[0]);'
Can I use multiple service_uuids, so that in HA it will be like an entity with multiple attributes?