Getting Started with Things in Designer


after almost a year of absence from openhab1, I decided to restart with openhab2 and made the following:

  1. On a fresh Raspbian, installed openhab2 via apt-get, configured samba service and installed openhab designer for remote access to the conf folder.
  2. Via PaperUI added Hue binding and was able to find the bulbs and add them as thing.
  3. What I learned now is that there is no openhab.cfg file anymore and the registered things are stored in some database. Also there is a _default sitemap which works perfectly fine and I’m able to control my light bulbs via e.g. Classic UI _default.

I want to use openhab designer and creating *.sitemap, *.items, etc. I’m wondering now that
a. Why does there exist a things folder as all things are registered via Paper UI already.
b. How can I access the things that are already known? Is it best practice to wrap them as Item?
c. Is there a convenient way to extract known things into some file such that I can copy & paste them into a sitemap file ?

If my questions are too basic and too generic, maybe one of you could explain me with a specific example: One of the Lightbulbs has in Paper UI the name “Hue Lamp 1” and a string like hue:0210:0017881687f8:3 In Habmin view I see for the same bulb a label “Extended Color Light” with channel hue_0210_0017881687f8_3_color
How can I use this lamp in designer now? Do I have to register it additionally and also, is this cryptic string somehow static or dynamically assigned, meaning when I reinstall openhab, has the same light bulb the same channel identifier assigned?

Thanks a lot for some background info to grasp the underlying extended idea behind openhab2.

I’m still a beginner in OH2, but here’s what I’ve found out so far:

  1. the thing folder is there if you need to add things manually because the discovery doesn’t work (well)
  2. To “wrap” existing things into items, you need to know the logical name of a thing. You’ll find them on the Configuration / Things page - and at your desired thing you’ll find e.g. the following:
    “network:device:192_168_1_99:online”. This is the channel you need to incorporate in your item definition, like in this example:
String LGTVWZOnline             "LG-TV [MAP(]" { channel="network:device:192_168_1_99:online", autoupdate="false"}

“:online” in this context is the “channel” (=property) of the device.

  1. I guess it’s anwered by 2) already; because if you click on a thing, you’ll get its channels - and every channel has its unique address, like: netatmo:NAModule1:69d18666:Temperature

I hope this helps you a little; since I don’t have a Hue lamp I can’t give you more accurate answers, sorry.

Thanks Boby, that makes sense, and also what I learned is that the channel name is immutable but however I fear that the name is newly assigned with new installation of openhab2. So one would have to go through it’s items definition file and update the channels if changed.

openhab.cfg has been broken up into separate files in the services directory. So where you used to have a section in the giant openhab.cfg now you have a separate file for each addon.

Not all OH 2.0 bindings support automatic discovery of Things. For those you have to manually create Things.

PaperUI’s use is optional. It is perfectly reasonable to manually do everything you want to using only text files (though with Zwave right now defining the Things is a challenge because every Device has its own data and when you do that you cannot configure the device).

Things represent a something external to OH, a device or API or the like. Each Thing has one or more Channels. The combination of Thing and Channel replaces the stuff you used to put in the { } of Item definitions in OH 1.

Things are not intended to be used directly as part of your home automation. The _default sitemap and stuff you can do in PaperUI to control Things are primarily intended for testing purposes. You cannot directly access Things from Rules. You cannot directly put a Thing on your Sitemap. You cannot Persist a Thing.

So indeed, it is a best practice to wrap your Things in an Item.

To reiterate, you do not put Things into your sitemap. You put Items into your sitemap, same as in OH 1. You bind an Item to a Thing by putting one of that Thing’s Channel ID in the curly brackets for the Item.

Create and Item and use the Channel ID of that bulb (it may be the same as the string you are seeing) in the curly brackets of the Item. In PaperUI under Configuration > Things, when you click on the Thing there will be a list of Channels.

In Habmin it looks like it shows the Channels and bound Items in the same place:

Select the ID from one and paste it into your Item config. Here is an example zwave Item I have:

Switch S_L_Front "Front Room Lamp"
        <light> (gLights, gWeatherLights, gMorningLightsON, gMorningLightsOFF, gTwilightLightsON, gEveningLightsOFF)
        { channel="zwave:device:528f7aca:node3:switch_binary" }

I suspect that your Hue bulb will have a separate channel for color, dimmer, and binary switch.

Once a Thing and its Channels are discovered and accepted (i.e. moved out of the Inbox) it gets saved in a database. When you upgrade OH this database is preserved. However if you install a new OH (e.g. move to another machine or reimage your machine) you will have to copy over your userdata folder in addition to your /etc/openhab2 config folders. This will preserve the IDs and keep you from needing to go through the discovery process again.

1 Like

Wow, it’s great reply and makes perfectly sense. Many thanks rlkoshak! Have a nice evening…