BLE Sensor ========== .. seo:: :description: Fetch numeric values from BLE devices. :image: bluetooth.svg The ``ble_sensor`` component is a sensor platform that can query BLE devices for specific values of service characteristics. For more information on BLE services and characteristics, see :doc:`/components/ble_client`. .. code-block:: yaml esp32_ble_tracker: ble_client: - mac_address: FF:FF:20:00:0F:15 id: itag_black sensor: - platform: ble_client ble_client_id: itag_black name: "iTag battery level" service_uuid: '180f' characteristic_uuid: '2a19' icon: 'mdi:battery' unit_of_measurement: '%' Configuration variables: ------------------------ - **ble_client_id** (**Required**, :ref:`config-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*, :ref:`config-id`): The ID to use for code generation, and for reference by dependent components. - **notify** (*Optional*, boolean): Instruct the server to send notifications for this characteristic. - **update_interval** (*Optional*, :ref:`config-time`): The interval to poll the device. - All other options from :ref:`Sensor `. Automations: - **on_notify** (*Optional*, :ref:`Automation `): An automation to perform when a notify message is received from the device. See :ref:`ble_sensor-on_notify`. BLE Sensor Automation --------------------- .. _ble_sensor-on_notify: ``on_notify`` ************* 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 no effect. A variable ``x`` of type ``float`` is passed to the automation for use in lambdas. Example UUIDs ------------- 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: +----------+------------------+-----------------------+ | Service | Characteristic | Description | +==========+==================+=======================+ | 180F | 2A19 | Battery level | +----------+------------------+-----------------------+ | 181A | 2A6F | Humidity | +----------+------------------+-----------------------+ See Also -------- - :doc:`/components/ble_client` - :ref:`sensor-filters` - :apiref:`ble_sensor/ble_sensor.h` - :ghedit:`Edit`