diff --git a/esphome/components/modem/sensor/modem_sensor.cpp b/esphome/components/modem/sensor/modem_sensor.cpp index 14d9b190a5..d72a5cd1c9 100644 --- a/esphome/components/modem/sensor/modem_sensor.cpp +++ b/esphome/components/modem/sensor/modem_sensor.cpp @@ -64,15 +64,15 @@ std::map get_gnssinfo_tokens(const std::string &gnss_i // for 7600 (16 tokens): // +CGNSSINFO: 2,04,03,00,4836.989133,N,00433.611595,W,060824,102247.0,-13.8,0.0,70.4,1.7,1.4,1.0 - std::string data = gnss_info.substr(12); - std::map gnss_data; - if (data.find(",,,,,,") != std::string::npos) { + if (gnss_info.find(",,,,,,") != std::string::npos) { ESP_LOGW(TAG, "No GNSS location available"); return gnss_data; // empty } + std::string data = gnss_info.substr(12); + std::vector parts; char delimiter = ','; std::istringstream token_stream(data);