How to show ip

Hi I’m Danny, a new Openhab enthusiast. I’m looking for a way to automatically recover and show the ip address of every thing present in Openhab.
I searched for a while but find only systeminfo binding, that’s not what I need.
Is there a way to do it?
The only solution I found is to set all the ip as static and show them with a string , but I don’t like it at all.

How many devices do you have that are IP addressable?

1 Like

You need describe more what you are really trying to accomplish. Just a list of all the IP devices on your Network? How does the IP being static have anything to do with anything? Show them how?

This really feels like an XY Problem and there is probably a more appropriate way to achieve you ultimate goal, a way that may not even involve OH.

Remember OH is a home automation hub, not a network monitoring and administration UI. You need to look at something like Nagios for that.

I actually want to display the ip of the things present in OH (smart tv, sonoff devices, nas, etc…), but thinking about it, maybe the best solution is exactly the string, because even if a device changes its ip, OH wouldn’t be able to recognize it.

For now I added "Text label=“” icon=“ip” to the sitemap, with the ip of the device I’m showing.

Don’t know if I was clear about what I wanted to do.

Part of the confusion is that many/most of the devices that a typical OH configuration uses do not have IP addresses. So putting the IP address into the generic standard for Things doesn’t make sense. That’s where Garry’s question came from.

So to step back a bit, why do you want to display the IP addresses in the sitemap? What do you plan on using this information for? Is it just to have a list of the IP addresses in your system somewhere? If so I might recommend Fing as a better approach. Or even better configure your DHCP to serve out static IPs to the devices and configure a local DNS so you don’t even need to care about IP addresses.

Now, one thing that can be useful with IPs in OH is a way to track the online/offline status of devices. The Network binding is made for this sort of thing and I use it myself as part of my monitoring in OH. This way in Rules when I ask OH to cause a device to do something (e.g. open the garage door), I can get an alert that the garage door opener is offline instead of the command just silently failing.

See Design Patterns: Generic Is Alive

1 Like

Wait, I think I’m doing something wrong:
I added every devices with the Network Binding, so for me every device has its own ip, and then linked the needed items: for example I added a Sonoff switch with network binding and linked an item that works with mqtt.
Isn’t it the right way??
Btw I want to display the ip on the sitemap just as an additional information.

The Network binding only will show online/offline status of a network address. It essentially sends a ping and sets an Item to ON or OFF depending on whether it gets a response.

To control an MQTT device you need to use the MQTT Binding.

I can’t say if what you have done is the right way because you don’t provide enough details and doesn’t really make a lot of sense as written (added a Sonoff switch with network binding and linked an item that works with mqtt???).

This is the item:

Switch sonoff “Switch1”
{ mqtt=">[broker:cmnd/sonoff/POWER1:command:*:default],
<[broker:stat/sonoff/POWER1:state:default]" }

And the Sonoff was added as a network binding.
Sorry if I’m not so clear but I speak english not very well.

Network binding and MQTT binding are completely independent. They have nothing to do with each other.

Since you are just getting started, you should be using the 2.x version of the MQTT binding. You can find details and docs for it here and there are several recent posts. If you limit your searches on the forum to MQTT posts made in the past 60 days you will find plenty of examples.

This article helped me a lot