Two Esphome device to one sensor

Hi,

I have 2 ESPHome devices, which are connects to my car’s voltage meter via bluetooth. I have 2 device, because I am not parking always on the same place and because of bluetooth range.

Code:

# Enable Bluetooth scanning for this ESP32
esp32_ble_tracker:

ble_client:
  - mac_address: F8:30:02
    id: bm2_battery_meter 
    
sensor:
  - platform: ble_client
    type: characteristic
    ble_client_id: bm2_battery_meter
    name: Voltage
    service_uuid: 'fff0'
    characteristic_uuid: 'fff4'
    unit_of_measurement: 'V'
    accuracy_decimals: 2
    state_class: measurement
    device_class: voltage
    notify: true
    lambda: |-
      mbedtls_aes_context aes;
      mbedtls_aes_init(&aes);
      unsigned char output[16];
      unsigned char key[16] = { 108, 101, 97, 103, 101, 110, 100, 255, 254, 49, 56, 56, 50, 52, 54, 54, };
      unsigned char iv[16] = {};
      mbedtls_aes_setkey_dec(&aes, key, 128);
      mbedtls_aes_crypt_cbc(&aes, MBEDTLS_AES_DECRYPT, 16, iv, (uint8_t*)&x[0], output);
      mbedtls_aes_free(&aes);
      return ((output[2] | (output[1] << 8)) >> 4) / 100.0f;  

I would like to write data to same sensor “Voltage” (sensor.voltage), but it is not working. It working only, when I set different name on each ESPHome device “Voltage2” (sensor.voltage2), etc.

Use a template to choose between the 2 sensors.