Td::string esphome::network::IPAddress::str() const' is deprecated

How to properly report this ?

/config/esphome/common/device_TTGO_POE.yaml:38:83: warning: 'std::string esphome::network::IPAddress::str() const' is deprecated: Use str_to() instead. Removed in 2026.8.0 [-Wdeprecated-declarations]
   38 |       return id(eth).get_ip_addresses().empty() ? "" : id(eth).get_ip_addresses()[0].str();
      |                                                     ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^~
In file included from src/esphome/components/ethernet/ethernet_component.h:8,
                 from src/esphome.h:26,
                 from src/main.cpp:3:
src/esphome/components/network/ip_address.h:154:15: note: declared here
  154 |   std::string str() const {
      |               

check line 38 and 154 of the yaml. what do you have there?

look like IP address missing maybe? or its looking for a value?
possilby formating or spacing error or missing some punctuation

Got it

    lambda: |-
      return id(eth).get_ip_addresses().empty() ? "" : id(eth).get_ip_addresses()[0].str();

this should be the fix

    lambda: |- 
      if (id(eth).get_ip_addresses().empty()) { 
        return std::string(""); }
      char buf[64]; 
      id(eth).get_ip_addresses()[0].str_to(buf); 
      return std::string(buf);  

Wasn’t this mentioned in the breaking changes for ESPHome recently? As the IP address for IPv4 always is 32 bits, no point in allocating and wasting string space for it.

Sorry, I missed it
something like that?

lambda: |-
auto ips = id(eth).get_ip_addresses();
if (ips.empty()) {
return esphome::optionalstd::string();
}
char buf[32];
ips[0].str_to(buf);
return std::string(buf);

1 Like