Setting Host Address

  • Platform information:
    • Hardware: Raspberry Pi 3 Model B Plus Rev 1.3
    • Raspbian GNU/Linux 10 (buster)
    • Java Runtime Environment: openjdk version “11.0.11” 2021-04-20 LTS
    • openHAB version: OH 3.0.2

I have some strange issues, I have connected a ConBee 2 zigbee gateway to the raspberry pi, everything works fine I get the devices, I can setup rules, it is running.

However I have used the IP adress of the eth0 of the raspberry pi (none static) to configure the deconz bridge binding (the Conbee 2 gateway). This works as long the rooter the raspberry pi is connected to is powered one. As soon as I switch of the rooter, the pi looses the IP address and the zigbee connection is gone.

So the idea was to use localhost or as host. So this works, however after some time or when the rooter is powered back on, this is beeing changed automatically back to the IP of the eth0 network interface, and again everything crashes.

Is this a bug? Or is there a reason for this behaviour? Are there any other solutions to this other than assigning a static IP address to the eth0 interface?

openHAB does not do anything about IP addresses so it’s the OS setup which is what you caused yourself.
As you chose not to use openHABian please don’t expect any OH expert to debug that for you.

O sorry I have choosen to use openhabian, 32bit version

You chose openHABian but openjdk ??? why didn’t you stay with the Zulu default ?

Can’t tell for sure if that’s related. But for a start I’d set up a proper DHCP server (or in other words: your router is not a proper one. It should run 24/7 so I’d try to keep it running in the first place.
openHABian won’t change IP unless the router does weird stuff.

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.