Skip to content

Commit

Permalink
Allow setup to continue past mqtt if network/wifi is disabled (esphom…
Browse files Browse the repository at this point in the history
  • Loading branch information
jesserockz authored Nov 14, 2023
1 parent ae0e481 commit 2754dde
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 1 deletion.
2 changes: 1 addition & 1 deletion esphome/components/mqtt/mqtt_client.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -147,7 +147,7 @@ void MQTTClientComponent::dump_config() {
ESP_LOGCONFIG(TAG, " Availability: '%s'", this->availability_.topic.c_str());
}
}
bool MQTTClientComponent::can_proceed() { return this->is_connected(); }
bool MQTTClientComponent::can_proceed() { return network::is_disabled() || this->is_connected(); }

void MQTTClientComponent::start_dnslookup_() {
for (auto &subscription : this->subscriptions_) {
Expand Down
8 changes: 8 additions & 0 deletions esphome/components/network/util.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,14 @@ bool is_connected() {
return false;
}

bool is_disabled() {
#ifdef USE_WIFI
if (wifi::global_wifi_component != nullptr)
return wifi::global_wifi_component->is_disabled();
#endif
return false;
}

network::IPAddress get_ip_address() {
#ifdef USE_ETHERNET
if (ethernet::global_eth_component != nullptr)
Expand Down
2 changes: 2 additions & 0 deletions esphome/components/network/util.h
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,8 @@ namespace network {

/// Return whether the node is connected to the network (through wifi, eth, ...)
bool is_connected();
/// Return whether the network is disabled (only wifi for now)
bool is_disabled();
/// Get the active network hostname
std::string get_use_address();
IPAddress get_ip_address();
Expand Down

0 comments on commit 2754dde

Please sign in to comment.