esphome / esphome/feature-requests

ble_client - disable connect at bootup

Open
#2,315 0 comments 0 reactions 0 assignees View on GitHub
Dominant language
No language data
Stars
450
Forks
29
PR merge metrics
No merged PRs in 30d

Description

**Describe the problem you have/What new integration you would like**
At bootup time the ble_client tries to connect to the device. Sometimes, the device is not reachable, where the ble_client keeps trying to connect.

**Please describe your use case for this integration and alternatives you've tried:**
an alternative is to make sure the device is operational, sometimes that is not possible where it loops until the device is restored.

When data is needed from a ble sensor, the esp ble_client is enabled using the ble_client switch
After the reading the ble_client is disabled again using the same switch.
(this to save battery power on the ble sensor device where it goes in power-save at disconnect)).

When the esp device is booted (upgrade, config change, etc) the ble_client is automatically enabled where it tries to connect to something that is (potentially) unreachable and keeps trying until it can. Sometimes that might be needed, in my case it's something i want to prevent.

It would be great if the ble_client can have the same configurable restore_mode (or similar functionality) as the switch provides preventing it from connecting at bootup.

to reflect this from the ble_client switch to the ble_client itself:

taken from the switch
restore_mode:
ALWAYS_OFF (DEFAULT) - Always initialize the switch as OFF on bootup.
ALWAYS_ON - Always initialize the switch as ON on bootup.

For the BLE_CLIENT the default should be ALWAYS_ON not to break any existing setups

Additional
BLE Client Automation: on_connectfailure (or something like that)
would be helpful to send an error back the front-end (Home Assistant to indicate that the ble device is unreachable
`ble_client:
- mac_address: 11:22:33:44:55:66
id: ble_itag
on_connectfailure:
then:
- lambda: |-
ESP_LOGD("ble_client_lambda", "Unable to connect to BLE device");`

**Additional context**
Some insights in what the use-case is, (231 starts the small discussion on auto-connect at boortup)
https://community.home-assistant.io/t/blue-connect-pool-measurements/118901/231

my esp-32 config: https://github.com/Peerke1/homeassistant-pool

Contributor guide

No contributing guide indexed for this repository

Research direction

Review the ble_client configuration and the switch restore_mode behavior described in the issue; start by tracing how ble_client is enabled at boot. Confirm the intended scope for boot restore behavior and the optional on_connectfailure automation, with ALWAYS_ON preserved as the default and disabled startup preventing connection attempts.

Written by the indexing model from the issue text.

Assessment

Domain
embedded-iot
Issue type
Feature
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.