Fix esp32_improv authorizer with no binary sensors in config (#5546)

This commit is contained in:
Jesse Hills 2023-10-17 20:03:39 +13:00
parent 61cf566560
commit fd7d3c4332
No known key found for this signature in database
GPG key ID: BEAAE804EFD8E83A

View file

@ -107,6 +107,7 @@ void ESP32ImprovComponent::loop() {
break; break;
} }
case improv::STATE_AUTHORIZED: { case improv::STATE_AUTHORIZED: {
#ifdef USE_BINARY_SENSOR
if (this->authorizer_ != nullptr) { if (this->authorizer_ != nullptr) {
if (now - this->authorized_start_ > this->authorized_duration_) { if (now - this->authorized_start_ > this->authorized_duration_) {
ESP_LOGD(TAG, "Authorization timeout"); ESP_LOGD(TAG, "Authorization timeout");
@ -114,6 +115,7 @@ void ESP32ImprovComponent::loop() {
return; return;
} }
} }
#endif
if (!this->check_identify_()) { if (!this->check_identify_()) {
this->set_status_indicator_state_((now % 1000) < 500); this->set_status_indicator_state_((now % 1000) < 500);
} }
@ -290,8 +292,10 @@ void ESP32ImprovComponent::process_incoming_data_() {
void ESP32ImprovComponent::on_wifi_connect_timeout_() { void ESP32ImprovComponent::on_wifi_connect_timeout_() {
this->set_error_(improv::ERROR_UNABLE_TO_CONNECT); this->set_error_(improv::ERROR_UNABLE_TO_CONNECT);
this->set_state_(improv::STATE_AUTHORIZED); this->set_state_(improv::STATE_AUTHORIZED);
#ifdef USE_BINARY_SENSOR
if (this->authorizer_ != nullptr) if (this->authorizer_ != nullptr)
this->authorized_start_ = millis(); this->authorized_start_ = millis();
#endif
ESP_LOGW(TAG, "Timed out trying to connect to given WiFi network"); ESP_LOGW(TAG, "Timed out trying to connect to given WiFi network");
wifi::global_wifi_component->clear_sta(); wifi::global_wifi_component->clear_sta();
} }