9

I have setup multiple lamps and sensors in my Home Assistant configuration. However, I want to know how to best handle the following scenario.

If there is a problem with my router or a power cut and my router is rebooted. In this case there is a possibility that the multiple IoT devices connected to my network get new IP address assigned to them. If these new IP addresses are different from ones I used in the configuration.yaml setup, I will have to update the file to handle this.

I was wondering if there an automatic/graceful way of handling this?

  • 2
    Don't forget to include your router model so answers can be specifically tailored to your specific router; this will help anyone searching for the question in future. – Aurora0001 Feb 12 '17 at 11:48
  • 2
    Ideally your setup wouldn't depend on IP addresses to being with, the devices should have some sort of discovery scheme for example using mDNS. The kind of DHCP server customizations being suggested are workable for an enthusiast setup, but not a viable way for an end user product to have been designed to work. But if you have assembled a collection of products from different vendors some of which may have software that is a bit "unfinished" and you do control the router in detail, then it's understandable why tying IP addresses to MAC addresses may seem invitingly universal. – Chris Stratton Feb 12 '17 at 19:36
5

The router configuration portal has DHCP-->'Address Reservation' under Advanced settings. This way MAC address to IP address reservation can be achieved.

5

Every networked device connected to your router has a MAC address, which is specifically linked to one device, unlike local IP addresses in your private network, which are assigned by your router and don't have to be permanent.

Generally, local IPs are assigned sequentially, often starting at 192.168.0.1, then 192.168.0.2 and so on, as described by How-To Geek:

Newer routers often have the ability to remember which IP address was assigned to which computer, so if they disconnect and reconnect their IP doesn’t change. Often, though, a router reset will wipe this cache and start assigning IPs on a first-come, first-served basis. Tons of older routers don’t even have this ability, and immediately assign new IP addresses.

That's obviously not great if you want a static local IP for Home Assistant to use. If your router doesn't remember which IP was assigned to each device, you can usually configure this using a DHCP reservation option, which will usually consist of adding the MAC address and desired static IP to a list for your router to use when assigning IPs.

You're probably wondering, though - how can I get the MAC address of my devices anyway? Your router almost certainly has a list of devices connected, their local IPs and MAC addresses, as shown in this answer (although the exact method of viewing this again depends on your router).

I'll update this with device-specific instructions when you include the router model in your answer, but I think these general steps should be enough to help anyone with a similar problem.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.