Reusing Things, Channels and Items with MQTT bridge

Hi!

I got the tasmota zbbridge working and now I am defining custom things as files.

It seems to be working fine, however, as I add more and more things I find myself copying and pasting everywhere, so how do I reuse definitions?

For example all things have LinkQuality channel, can I define it and reference it later?

Also I have many things of the same type, how can I reuse a definition for multiple instances?

And with items? do I have to pick the items for each individual thing? Even if I have 3 instances of the same thing?

How do I reuse definitions?

In general, you can’t reuse anything because your devices are different physical objects. Your Thing defines this physical object, and the Channels define the properties of this physical object (relay, temperature etc).

Items are openHAB’s internal variables which attach to the Channels. You can attach more than one Channel to an Item if you want, but really the idea is that you have one Item per Channel.

So whilst your physical objects may have the same model number, they will be located in different places, and have different functions, and most importantly have different identifications. So they need individual Things, Channels and Items. That’s not too say you can’t copy/paste the configurations for these - but you’ll have to modify at least the names of the Thing and Item, as these need to be unique. Channels can have the same name between Things as they are referenced via the Thing name.

I am after an “object” and “instance” pattern.

I 3x xiaomi plugs, everything is the same except its ID, or something.

the documentation mentions “standalone” channels defined by bindings.

I guess in openHAB land this is a Thing and Channel respectively. Kind of. But you need to configure these per physical device.

Can you provide a link? Probably some misunderstanding here.

openHAB text based configs do not support the object and instance pattern. You have to define each instance individually.

You are probably referring to Event Channels. These are Channels that can trigger a Rule directly and are not (and indeed cannot be) linked to an Item.

the concept kind of exists, but not exactly:

“referencing existing channels”: