1
0
mirror of https://github.com/esphome/esphome.git synced 2025-09-02 19:32:19 +01:00

add wifi.on_connect and wifi.on_disconnect triggers (#3639)

Co-authored-by: Jesse Hills <3060199+jesserockz@users.noreply.github.com>
This commit is contained in:
Charles Johnson
2023-11-07 05:17:13 +00:00
committed by GitHub
parent 888c298d7e
commit 31fec2d692
4 changed files with 44 additions and 5 deletions

View File

@@ -138,9 +138,19 @@ void WiFiComponent::loop() {
ESP_LOGW(TAG, "WiFi Connection lost... Reconnecting...");
this->state_ = WIFI_COMPONENT_STATE_STA_CONNECTING;
this->retry_connect();
if (this->handled_connected_state_) {
this->disconnect_trigger_->trigger();
this->handled_connected_state_ = false;
}
} else {
this->status_clear_warning();
this->last_connected_ = now;
if (!this->handled_connected_state_) {
this->connect_trigger_->trigger();
this->handled_connected_state_ = true;
}
}
break;
}