Either auto-detection (doesn’t work well for many devices), UI (as @ubeaut described above) or text file.
While the UI is great for almost anything I still like to define my zigbee2mqtt things in a.thing file. This is because you have to define the channels anyway which makes it quicker (for me).
A good start with many examples is:
This way you don’t need JSON transformations anymore as all attributes are sent separately and can be directly attached to a channel.
Here is an example for a smart plug:
Thing mqtt:topic:PlugWaschmaschine "PlugWaschmaschine" (mqtt:broker:MosquittoMqttBroker) { Channels:
Type switch : state "state" [ stateTopic = "zigbee2mqtt/PlugWaschmaschine/state", commandTopic = "zigbee2mqtt/PlugWaschmaschine/set/state", on="ON", off="OFF" ]
Type datetime : last_seen "last_seen" [ stateTopic = "zigbee2mqtt/PlugWaschmaschine/last_seen" ]
Type number : power "power" [ stateTopic = "zigbee2mqtt/PlugWaschmaschine/power" ]
Type number : energy "energy" [ stateTopic = "zigbee2mqtt/PlugWaschmaschine/energy" ]
Type number : current "current" [ stateTopic = "zigbee2mqtt/PlugWaschmaschine/current" ]
}
You save this as anyName.things under …openHAB-conf/things.
Then I usually create all items with “Add Equipment to Model” that you find in the channel tab of your new thing.