How to detect when a ESPhome device gets another IP address?

Hi folks!

I built a word watch using ESPHome. The configuration allows for the integration of the device into other WLAN networks that do not have a home assistant server…

The user needs to know the new IP adress of the device to access its configuration page. To facilitate this I created a function that uses the clock to display the IP adress.

My question is now: I need to detect when the assigned IP adress changes so IP adress needs to be shown again. Is the a buildin function or doe I have to store the IP adress and do the comparison in code?

Thanks for your support

Can’t you give the device a fixed IP?
That way you tackle the problem by the root instead of searching for ways to circumvent the problem…

WiFi Component - ESPHome - Smart Home Made Simple → manual_ip

I use code like this.

text_sensor:
    ip_address:
      id: ip_address
      name: "IP Address"
      icon: mdi:ip-network
      entity_category: diagnostic
      on_value:
        then:
          - lvgl.label.update:
              id: ip_address_label
              text:
                format: "%s"
                args: [ 'id(ip_address).state.c_str()' ]

to update my screen when the IP changes. You could do the same thing. Why not just access it but name instead of IP address. The name will not change unless you change it.

I doubt it compiles like that…

Missing a line - I assume a cut & paste error?

text_sensor:
  - platform: wifi_info
    ip_address:
      id: ip_address

Also known as DNS.

Your photo is so blurred I cannot see anything except a mass of colored blobs.

Does the access point mode functionality of ESPHome provide for your reconfiguration needs if the IP Address is not contactible?

Blobs that say 192.168.2.175 - so that bit works for him…

See ap mode here.

Thanks for the interest in my issue.

The usecase is: I develop and build a clock in my network. The clock is a gift to a friend. He can incorporate the clock in his network → that is working. Now I want to save him the hassle to go to his router and get the IP adress from the router so he can access the configuration page.

Therefor a fixed IP adress is not possible.

You got it!!

You are so right! Thanks!

That is the easy way. Call the clock by its name, then you can read if necessary the IP Adress from the device info.

This is actually mDNS. This protocol is used by Linux , macOS, iOS, and Windows 10/11 to locate devices on your local network. It saves a lot of time finding devices!

If that doesn’t work you need to use an IP scanner or the DHCP table on your router.