OH3: webURL for an thing/item

Many of my devices have an own webInterface. A tasmota, a Shelly etc. I always have to find out somehow what IP-Adress belongs to what device to reach it and change settings.

I am looking for a way to store that IP-address to the thing, but how?
for extra-bonus: clickable, so it jumps to that URL.
Thanks!

I use OH3 and want to use the fancy new WebUI/MainUI?

Don’t know about Shelly, and I’m presuming you’re using the MQTT binding: in your Tasmota console type:

status 5

You’ll see one of the key/value pairs is the IP address of the device.

If you send an empty message to

cmnd/<device name>/STATUS5

you’ll get the JSON string back on

stat/<device name>/STATUS5

If it was me, I would create a Thing Channel which subscribes to that stat topic, which is then linked to a String Item. And I would trigger the command from a periodic rule using the MQTT action.

What user interface are you using? What version of openHAB?

Thanks, didn’t know that. This would work for Tasmota.
And then I have shellys, they support mqtt… will check
And then I have easyESP devices, they support mqtt… will check

It’s not really a direction I thought about, to ask the devices via some channel for it’s IP-adress - but it has benefits, thanks for the direction.
PS: Oh, sorry, updated the topic, I use the new OH3-Webui

There might be a setoption for Tasmota where it periodically publishes its IP address, so you don’t have to ask for it, but I prefer to keep as many of my devices as close to un-configured as possible to simplify maintenance, and then just use openHAB to sort out all the faff.

Was playing around a bit and before I go to bed, I leave my notes here:

Not all my stuff can communicate it’s IP Address via MQTT. But they all have some sort of json http call that has that information.
I now use a combination of http binding and network binding to get:


and could build a widget like:
image

All my IP Addresses are fixed, so that helps. but that is quite some work here…

So this is a little bit an XY Problem. Why solve this Problem with OH in the first place? There are a whole host of ways to address this problem, all of which is outside OH and some of which is beneficial to OH itself.

  • define static ip addresses in your router and assign a meaningful host names in the router

  • define static ip addresses and assign meaningful names in the hosts files on relevant machines

  • create a series of named bookmarks in your browser

  • set up dns on your lan, again using meaningful host names.

When you use hostnames like this then not only is it easier for you to remember which device is which, OH will have that information you. mbr-sensors in the hostname field is way more meaningful compared to 192.168.1.123.

another shot into another different direction, thanks.
I do have pfsense in place, so I am able to override hostnames of devices on DNS level!
So I just use the thing name from here:


and use that as the hostname here:

and I am able to access the device’s webinterface like that:

  • way less “work” then adding the devices as things and items
  • feels organized
  • cannot just click it, (haha).

Thanks!

That’s what I use. Definitely set static IPs and assign host names there. Then you can use a meaninful and memerable hostname in your OH configs and the browser and won’t ever need a mapping in the first place. In a worst case scenario you might need to open pfSense to remember the hostname you chose. :wink:

It’s a bit of work up front but then it’s really easy to keep it up after that.

A suggestion, since you appear to have Equipment groups to represent your things.

Make a page, add a list card in it, and change the YAML to:

component: oh-list-card
config: {}
slots:
  default:
    - component: oh-repeater
      config:
        fragment: true
        for: equipment
        sourceType: itemsWithTags
        itemTags: HasWebInterface
        fetchMetadata: webinterface
      slots:
        default:
          - component: oh-list-item
            config:
              title: =loop.equipment.label
              action: url
              actionUrl: =loop.equipment.metadata.webinterface.value
              actionUrlSameWindow: false

Now go add a non-semantic “HasWebInterface” tag and custom metadata (“webinterface” namespace) with the value set to the address of the web interface, to all your relevant items.
The repeater will enumerate all items with the tag, and if the metadata is present, the “url” action on the item will open the link from the metadata.

2 Likes

Oh, that is actually what I started with! But I wasn’t able to get it working then, and I still think something might be broken here, let me show:

When I add the meta-data for webinterface, that metadata (“webinterface”) it is not listed afterwards. It is not gone, I can repeat the process and the value is still there, but I was expecting an entry in the meta-data tab.
Here, this item, I clicked on “add metadata”, selected “custom namespace”, enter “webinterface”, give it a value, press save and then it looks like this:

but …it is working!
I now have a generic item that automatically lists all items with that tag and points to the url of the namespace tag. wonderful. thanks for pointing this out, very powerful.
image

I have combined both suggestions from @rlkoshak and @ysc by changing the actionURL to

actionUrl: =('http://' + loop.equipment.name)

Had to bruteforce and try&error heavy on the syntax. Hope you guys are working on this, I love it and want to use it more, but need more documentation.