Get ESPHOME BT Proxy's scanning status

Hi all, is there a way to get into HA status scanning’s status of ESPHOME Bluetooth proxy?

Here my running code.
Is there a way to expose to HA status mentioned above?

> substitutions: #substitute your own values in this section
>   device_name: "esp32-bluetooth-proxy-1"
>   static_ip: 192.168.1.100
>   gateway: 192.168.1.254
>   subnet: 255.255.255.0
>   dns1: 192.168.1.241
> 
> #---------------------------------------------------------------------------------------------
> 
> esphome:
>   name: '${device_name}'
>   friendly_name: '${device_name}'
>   on_boot:
>     priority: -100
>     then:
>       - logger.log: --- BT Scan started ON BOOT!!!! ---
>       - light.turn_on:
>           id: led_gpio2
>           effect: "Fast Pulse"
> 
> esp32:
>   board: esp32dev
>   framework:
>     type: esp-idf
> 
> time:
>   - platform: sntp
>     id: sntp_time
>     timezone: Europe/Rome
>     servers:
>       - 0.pool.ntp.org
>       - 1.pool.ntp.org
>       - 2.pool.ntp.org
>   - platform: homeassistant
>     id: esptime
> 
> logger:
>   level: DEBUG #VERY_VERBOSE
> 
> api:
>   encryption:
>     key: "xxxxxxxxxxxxxxxxxxxx"
> 
> ota:
>   platform: esphome
>   password: "xxxxxxxxxxxxxxxxxxxxx"
> 
> wifi:
>   ssid: !secret wifi_ssid
>   password: !secret wifi_password
>   manual_ip:
>     static_ip: $static_ip
>     gateway: $gateway
>     subnet: $subnet
>     dns1: $dns1
>     
>   ap:
>     ssid: '${device_name}'
>     password: "xxxxxxxxxxxxxxxxx"
> 
> esp32_ble_tracker:
>   id: ble_tracker_1
>   scan_parameters:
>     continuous: true
>   on_ble_advertise:
>     then:
>       - lambda: |-
>           ESP_LOGD("ble_adv", "New BLE device");
>           ESP_LOGD("ble_adv", "  address: %s", x.address_str().c_str());
>           ESP_LOGD("ble_adv", "  name: %s", x.get_name().c_str());
>           ESP_LOGD("ble_adv", "  Advertised service UUIDs:");
>           for (auto uuid : x.get_service_uuids()) {
>               ESP_LOGD("ble_adv", "    - %s", uuid.to_string().c_str());
>           }
>           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());
>           }
>           ESP_LOGD("ble_adv", "  Advertised manufacturer data:");
>           for (auto data : x.get_manufacturer_datas()) {
>               ESP_LOGD("ble_adv", "    - %s: (length %i)", data.uuid.to_string().c_str(), data.data.size());
>           }
>   on_scan_end:
>   - then:
>       - lambda: |-
>             ESP_LOGD("ble_auto", "############ The scan has ended! ###########");
> 
> bluetooth_proxy:
>   active: true
> 
> 
> output:
>   - platform: ledc
>     pin: GPIO2
>     id: gpio2_led
> 
> light:
>   - platform: monochromatic
>     output: gpio2_led
>     name: "LED GPIO2"
>     id: led_gpio2
>     internal: False
>     effects:
>       - pulse:
>           name: "Fast Pulse"
>           transition_length: 1s
>           update_interval: 1s
> 
> 
> binary_sensor:
>   - platform: status
>     name: "Display Status"
> 
> sensor:
>   - platform: wifi_signal
>     name: "Segnale WiFi"
>     update_interval: 60s
> 
>   - platform: uptime
>     name: "Tempo di attività"
> 
> 
> button:
>   - platform: template
>     name: Start scan ESP32 BT Proxy 1
>     id: scan_esp32bt_proxy_1
>     on_press:
>       then:
>         - logger.log: --- BT Scan started ---
>         - light.turn_on:
>             id: led_gpio2
>             effect: "Fast Pulse"
>         - esp32_ble_tracker.start_scan:
>   - platform: template
>     name: Stop scan ESP32 BT Proxy 1
>     id: no_scan_esp32bt_proxy_1
>     on_press:
>       then:
>         - logger.log: --- BT Scan stopped!!! ---
>         - light.turn_off: led_gpio2
>         - esp32_ble_tracker.stop_scan:

If you add a name to your gpio2_led it will appear as an entity in HA, will that do the trick?

Hi, I am using that way to control it, but is not secure 100% that scanning is active or not.
I need to monitor real status of scanning. So I need to find a 100% secure way.
Can you confirm that ESP32 Bluetooth Low Energy Tracker Hub doesn’t expose nativly what I am searching?

Doesn’t look like it does have any status exposed. The on_scan_end action you have writes to the log, are the logs accurate enough? If so you could add an action after the log entry to switch the LED off perhaps.

Found a solution.
Created a

> 
> input_text:
>   stato_scanning_bt_proxy_1:
>     name: Scanning BT attivo o no su esp32-bluetooth-proxy-1
>     initial: "spento"

then an automation:

alias: BT Scanning Status - esp32-bluetooth-proxy-1
description: ''
trigger:
platform: event
event_type: esphome.ble_scanning_state
action:
 - data_template:
 entity_id: input_text.stato_scanning_bt_proxy_1
value: '{{ trigger.event.data.status }}'
action: input_text.set_value

and last in ESPHOME configuration:

> esp32_ble_tracker:
> 	.....
>   on_ble_advertise:
>     then:
> 	.....
>       - homeassistant.event:
>           event: esphome.ble_scanning_state
>           data:
>             status: "acceso"
> 
>   on_scan_end:
>   - then:
> 	.....
>       - homeassistant.event:
>           event: esphome.ble_scanning_state
>           data:
>             status: "spento"
1 Like