diff --git a/esphome/components/wifi/wifi_component.cpp b/esphome/components/wifi/wifi_component.cpp index a1a5699e1e..61d05d7635 100644 --- a/esphome/components/wifi/wifi_component.cpp +++ b/esphome/components/wifi/wifi_component.cpp @@ -480,7 +480,7 @@ bool WiFiComponent::matches_configured_network_(const char *ssid, const uint8_t continue; } // Match by SSID - if (sta.ssid_ == StringRef(ssid)) { + if (sta.ssid_ == ssid) { return true; } } diff --git a/esphome/components/wifi/wifi_component.h b/esphome/components/wifi/wifi_component.h index e146f9a45b..4cf19a8059 100644 --- a/esphome/components/wifi/wifi_component.h +++ b/esphome/components/wifi/wifi_component.h @@ -200,6 +200,8 @@ class CompactString { bool operator!=(const CompactString &other) const { return !(*this == other); } bool operator==(const StringRef &other) const; bool operator!=(const StringRef &other) const { return !(*this == other); } + bool operator==(const char *other) const { return *this == StringRef(other); } + bool operator!=(const char *other) const { return !(*this == other); } protected: char *get_heap_ptr_() const {