Class esphome::ethernet error after update to ESPHome 2024.3.0

Hi,

Today, I encountered an error while compiling my ESPHome code.
The issue seems to be related to the following line:

lambda: return { id(eth).get_ip_address().str() };

The error message points to this part of the configuration. Specifically, it appears that the lambda expression needs adjustment.

Here’s the context:

text_sensor:

  • platform: template
    name: “${friendly_name} IP Address”
    entity_category: diagnostic
    icon: “mdi:ip-network”
    lambda: return { id(eth).get_ip_address().str() };
    update_interval: 60s

Additionally, based on the recent change log for ESPHome, there have been updates related to IPv6 support.

If you are building an external component or using functions like network::get_ip_address(), wifi::global_wifi_component->get_ip_address(), or ethernet::global_eth_component->get_ip_address(), note that these functions have been renamed to ::get_ip_addresses(). They now return a list of all IP addresses.

To achieve the same result as before, do I need to modify the lambda expression as follows?

lambda: return { id(eth).get_ip_addressESS().str() };

that’s correct?

regards

According to the release notes for ESPHome 2024.3.0, network:get_ip_address() has been renamed network::get_ip_addresses().

1 Like

This is my final version

text_sensor:

  • platform: template
    name: “${friendly_name} IP Address”
    entity_category: diagnostic
    icon: “mdi:ip-network”
    lambda: |-
    return id(eth).get_ip_addresses().empty() ? “” : id(eth).get_ip_addresses()[0].str();
    update_interval: 60s