BLE Client Sensor¶
ble_client component is a sensor platform that can
query BLE devices for RSSI or specific values of service characteristics.
For more information on BLE services and characteristics, see BLE Client.
esp32_ble_tracker: ble_client: - mac_address: FF:FF:20:00:0F:15 id: itag_black sensor: - platform: ble_client type: characteristic ble_client_id: itag_black name: "iTag battery level" service_uuid: '180f' characteristic_uuid: '2a19' icon: 'mdi:battery' unit_of_measurement: '%' - platform: ble_client type: rssi ble_client_id: itag_black name: "iTag RSSI"
type (Required): One of
ble_client_id (Required, ID): ID of the associated BLE client.
service_uuid (Required, UUID): UUID of the service on the device.
characteristic_uuid (Required, UUID): UUID of the service’s characteristic to query.
descriptor_uuid (Optional, UUID): UUID of the characteristic’s descriptor to query.
id (Optional, ID): The ID to use for code generation, and for reference by dependent components.
lambda (Optional, lambda): The lambda to use for converting a raw data reading to a sensor value. See Raw Data Parsing Lambda for more information.
notify (Optional, boolean): Instruct the server to send notifications for this characteristic.
update_interval (Optional, Time): The interval to poll the device.
All other options from Sensor.
on_notify (Optional, Automation): An automation to perform when a notify message is received from the device. See on_notify.
Raw Data Parsing Lambda¶
By default only the first byte of each message received on the service’s characteristic is used
for the sensor reading. For more complex messages, this behavior can be overridden by a custom
lambda function to parse the raw data. The received data bytes are passed to the lambda as a
x of type
std::vector<uint8_t>. The function must return a single
... sensor: - platform: ble_client type: characteristic ble_client_id: t_sensor name: "Temperature Sensor 32bit float" ... device_class: "temperature" lambda: |- return *((float*)(&x));
BLE Sensor Automation¶
This automation is triggered when the device/server sends a notify message for
a characteristic. The config variable notify must be true or this will have
x of type
float is passed to the automation for use in lambdas.
The UUIDs available on a device are dependent on the type of device and the functionality made available. Check the ESPHome device logs for those that are found on the device.
Some common ones: