Open hachi opened 4 months ago
The problem is this in the client base:
bool connected() { return this->state_ == espbt::ClientState::ESTABLISHED; }
That state doesn't get set until all the "nodes" which includes the triggers are run.
This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.
The problem
According to @jesserockz The problem seems to be that the ble_client triggering the on_connect automation maintains node_state independently of ble_client.ble_write action, and as a result you get told that the client is not connected when you call ble_write
A workaround can include using a delay action before the ble_write, to return control to the scheduler, but in the case I was trying to use it was not working because I wanted on_connect to finish before actions in other automation chains run.
Which version of ESPHome has the issue?
Version: 2024.5.2
What type of installation are you using?
Home Assistant Add-on
Which version of Home Assistant has the issue?
N/A
What platform are you using?
ESP32-IDF
Board
WESP32
Component causing the issue
ble_client
Example YAML snippet
Anything in the logs that might be useful for us?
Additional information
No response