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:
@@ -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;
|
||||
}
|
||||
|
Reference in New Issue
Block a user