Setting Host Address

Okay if I type in java -version I get the following response:

openjdk version “11.0.11” 2021-04-20 LTS
OpenJDK Runtime Environment Zulu11.48+21-CA (build 11.0.11+9-LTS)
OpenJDK Client VM Zulu11.48+21-CA (build 11.0.11+9-LTS, mixed mode)

So I have only added the first line, sorry.

I turn of the rooter, so it is not an issue with the rooter.
But why is it resetting the IP from localhost to eth0 IP as soon as rooter is reconnecting. I mean I understand that it is updating the IP if e.g the rooter assignes a new IP, but it shouldn’t do that behaviour for the localhost ?

All sort of weird stuff can happen to any DHCP client if you kill the default gateway (which is what the router is). Possibly that way your box knows that its DHCP server is gone.
Why the heck do you turn a router off? Routers are supposed to run 24/7.

We turn off all electric equipment (except the pi running openhabian) when going to bed, leaving the house,… it dramatically reduces our energy bill, we are at 50% of the average Austrian houshold, living in an old tenemant block…

okay so do I have any possiblitie to tell openhab to stop altering the IP address or is the only possibility to assign a static IP to the eth0?

I don’t know.

I’m definitely in favour of reducing energy consumption, but the real gains are with high-consumption devices. Even at Australia’s high electricity rates, I would guess that turning your router off for ~8 hours per night is saving you maybe 5-10 cents per week. That’s purely speculative though, since I don’t know your actual rate or the energy consumption of your router. Might be worth finding out.

Note that openHAB isn’t doing anything to your IP address. When your RPi can’t reach the DHCP server on your router, it’s defaulting to localhost. When it does find the DHCP server, it gets a new IP. That’s all normal behaviour for a computer.

If you reserve an IP on the router, then it will definitely serve that same IP to the RPi when the two devices reconnect. However, that probably won’t help you when the router is turned off.

I don’t know what will happen if you set a static IP in the RPi’s settings, but the easy way to find out is to do it and see what happens when the router is turned off. It’s no worse than what’s going on right now. My suspicion is that it won’t help, but you might as well try.

This really is a networking question, and the best advice is to check the DHCP range that the router is using. You want to then assign a static ip within the subnet but outside of the DHCP range to your raspberry running Openhab.


IP Address of Router:
Subnet Mask:

DHCP Range: to

Openhab Static IP:

You can also assign or to other devices.

Wrong Continent, Austria not Australia. No Kangoroos. But that acctualy doesn’t matter.
Generaly I get your point, however it is also less blinking lights, so letting the thing run 24/7 is not a personal option. And yes I understand all things with the DHCP, but what I mean is this config from openhab not the pi itselfe:

I have this as config:
UID: deconz:deconz:00212E0712F7
label: schaf
thingTypeUID: deconz:deconz
host: localhost (same happens when using
apikey: ********
httpPort: 8081
timeout: 2000

and on the next morning when switching on the router I get:

UID: deconz:deconz:00212E0712F7
label: schaf
thingTypeUID: deconz:deconz
apikey: ********
httpPort: 8081
timeout: 2000

As already stated, openHAB and openHABian do not do anything about IP addresses. DHCP does.
So turning a router (= DHCP server plus default gateway) permanently off is just a bad if not to say dumb idea, let alone for the (non- !) savings this gets you.
And untested of course as noone else would ever do. Don’t expect others to help you with that - sorry.
And you asked for help without stating that you want the router to stay off in the first place, plus quite some more at first misleading information, making all of us victim to the XY problem.
If you ask volunteers for help, you should be willing and able to follow a minimum of rules such as these.

How to ask a good question / Help Us Help You - Tutorials & Examples - openHAB Community

If you want to make the pi a static IP address you edit /etc/dhcpcd.conf

There is a section there for IP address for eth0:

# Example static IP configuration:
interface eth0
static ip_address=
static routers=
static domain_name_servers=

The above example sets eth0
The static_ip_address is the IP address of the pi and the /24 is the bitmask
static routers is the router ip address
static domain_name is the dns servers you want to use.

The reboot the pi. Good luck.

I statically assign all my servers and use dhcp for the clients.

By the way I have kangaroos here as I am in Australia :slightly_smiling_face: :slightly_smiling_face:

To check the address type:
ip address show dev eth0

To check the route type:

To check the dns servers type:
cat /etc/resolv.conf

Make your pi ip address outside of the dhcp reserved address range.

Okay so punchline is:

Keeping the localhost will not work, it will always switch to the current ip Adresse as soon one is dynamically assigned. Only way to be able to connect / disconnect is through a static address.

Not what I hoped for but if this is the way …
Any chance that this could be something that is possible in the future?

The localhost is a loopback address.

If you type:
host localhost
localhost has address

Ya I know but the issue is that it reassignes my setting of to the dynamically assigned address by the rooter e.g.

OK. So it is not the ip of the pi you are talking about then?

Is it like this:

You have stated you know about DHCP, so it should be easy for you to limit the range so that you can use a Static IP on the Pi. With the Static IP it would not change and hence the issue of the IP Address changing will be solved. You may get other issues when you turn the router off since that would be your default gateway.

Oops, sorry. My earlier post still holds, though: instead of asking, try assigning the static IP and tell us what happens.

Or, if you’re comfortable with the energy consumption, move the router so that you can’t see the lights. I’m with you on that. I use LightDims stickers to cover all of the LEDs that are trying to keep me awake at night.

No it is the change in the binding, as far as I understood this specifies the IP address where to look for the conbee 2, and this gets changed from localhost to the current IP address of the Pi after some time which results in a problem when disconnecting the network, sorry if I wasn’t able to correctly address the problem obviously I can’t describe the problem. If I could, I would be close to solving it, since understanding the problem is half the rent ( don’t know if that translates correctly).

And please the initial question was do keep dynamic assignment of IP address and not move to static IP’s.

@rpwong I wil try static assignment and update the post.

Actually, your initial questions were:

It’s clear now that you want to turn off your router and want DHCP to continue working, but it wasn’t in your original post.

Regarding your first two questions, it’s logical to me that the Conbee binding updates to the Pi’s latest IP address when a new one is assigned by the DHCP server. Otherwise, the connection would fail every time the IP changes, and the majority of users would not like that at all. So, I would see it not as a bug, but as a feature that just doesn’t happen to work well in your unusual scenario.

Regarding your third question, the simplest solution is to keep your router turned on. We’ve established that you don’t want to do that.

The second simplest solution (if it works) is to set the static IP on your Raspberry Pi, per my other post and @ubeaut’s instructions. Hopefully this works when you test it.

The third solution I can think of is to move your DHCP server onto your Raspberry Pi. For example, you could install Pi-Hole and use its DHCP server for your network. It’s not recommended to run other software alongside openHAB, but it’s a solution that would probably work. Of course, that could introduce other problems in your network that are even more of a headache.

You can find discussions about connecting Pi-Hole to openHAB here, but if you want help with installing and configuring it, you’ll have to look elsewhere on the Internet (there are lots of articles).

The fourth solution would be to submit a feature request to the binding developer in GitHub asking for one of the following:

  1. add a checkbox to prevent the binding from reacting to IP changes (so that you can set it to localhost permanently)
  2. have the IP default to localhost when there’s no DHCP server available

You would need to communicate that the change is beneficial to more users than just you, but again, most people don’t turn off their routers regularly. In a power outage, everything is off. If you’re rebooting your router, it’s only a few minutes of downtime. So, I can’t see a developer agreeing unless it’s a super easy change to implement (and I have no idea how easy/hard it would be) or something they think has broader utility. Also, there’s still a chance that this isn’t the actual problem, and you’ll be right back where you started.

So there you go. #1 is the guaranteed-to-work scenario that you want to avoid. #2 is the best-case scenario if it works. #3 will probably work, but requires more effort on your part. #4 may or may not be accepted by a developer, may or may not solve your problem, and may or may not take days/weeks/months to be available to you.

1 Like

Hi @rpwong,

thanks a lot that clarified it for me. Well the static IP solution is working, you need to add noLink to it otherwise the interface goes down as soon connection is lost.

# Example static IP configuration:
interface eth0
static ip_address=
static routers=
static domain_name_servers=

Don’t receive link messages for carrier status. You should only have to use this
with buggy device drivers or running dhcpcd through a network manager.

Glad it is working for you.