[OH4] Zigbee2MQTT Bosch smoke detector BSD-2

I am having trouble finding proper documentation on how to create a generic MQTT Thing from a Zigbee Bosch Smoke Detector.
How should the generic MQTT Thing look like and how should I assign the channels of this generic MQTT Thing?
I would like to create a group of smoke detectors to trigger an action when one of the smoke detectors detects smoke.
I have learned that I can use files to create this configuration or use the user interface. But I could not find a complete example yet.

I have a running OH4 docker installation based on the tutorial from here:

The MQTT broker is correctly configured and online.
zigbee2mqtt is successfully logged on to the mqtt server.

Two smoke detectors are recognized by zigbee2mqtt, see the log entries below.

openhab4-zigbee2mqtt-1 | Zigbee2MQTT:info 2024-01-02 18:25:41: Currently 2 devices are joined:
openhab4-zigbee2mqtt-1 | Zigbee2MQTT:info 2024-01-02 18:25:41: smoke_detector_01 (…): BSD-2 - Bosch Smoke alarm detector (EndDevice)
openhab4-zigbee2mqtt-1 | Zigbee2MQTT:info 2024-01-02 18:25:41: smoke_detector_02 (…): BSD-2 - Bosch Smoke alarm detector (EndDevice)
openhab4-zigbee2mqtt-1 | Zigbee2MQTT:info 2024-01-02 18:25:41: Zigbee: disabling joining new devices.
openhab4-zigbee2mqtt-1 | Zigbee2MQTT:info 2024-01-02 18:25:42: Connecting to MQTT server at mqtt://172.17.0.1
openhab4-zigbee2mqtt-1 | Zigbee2MQTT:debug 2024-01-02 18:25:42: Using MQTT login with username: mosquitto
openhab4-zigbee2mqtt-1 | Zigbee2MQTT:info 2024-01-02 18:25:42: Connected to MQTT server
openhab4-zigbee2mqtt-1 | Zigbee2MQTT:info 2024-01-02 18:25:42: MQTT publish: topic ‘zigbee2mqtt/bridge/state’, payload ‘{“state”:“online”}’
openhab4-zigbee2mqtt-1 | Zigbee2MQTT:debug 2024-01-02 18:25:42: Passive device ‘smoke_detector_01’ was last seen ‘0.17’ hours ago.
openhab4-zigbee2mqtt-1 | Zigbee2MQTT:info 2024-01-02 18:25:42: MQTT publish: topic ‘zigbee2mqtt/smoke_detector_01/availability’, payload ‘{“state”:“online”}’
openhab4-zigbee2mqtt-1 | Zigbee2MQTT:debug 2024-01-02 18:25:42: Passive device ‘smoke_detector_02’ was last seen ‘0.18’ hours ago.
openhab4-zigbee2mqtt-1 | Zigbee2MQTT:info 2024-01-02 18:25:42: MQTT publish: topic ‘zigbee2mqtt/smoke_detector_02/availability’, payload ‘{“state”:“online”}’
openhab4-zigbee2mqtt-1 | Zigbee2MQTT:info 2024-01-02 18:25:42: Started frontend on port 0.0.0.0:8181
openhab4-zigbee2mqtt-1 | Zigbee2MQTT:info 2024-01-02 18:25:42: MQTT publish: topic ‘zigbee2mqtt/smoke_detector_01’, payload ‘{“ac_status”:false,“battery”:100,“battery_defect”:false,“battery_low”:false,“linkquality”:91,“restore_reports”:true,“smoke”:false,“supervision_reports”:true,“tamper”:false,“test”:false,“trouble”:false}’
openhab4-zigbee2mqtt-1 | Zigbee2MQTT:info 2024-01-02 18:25:42: MQTT publish: topic ‘zigbee2mqtt/smoke_detector_02’, payload ‘{“ac_status”:false,“battery”:100,“battery_defect”:false,“battery_low”:false,“linkquality”:83,“restore_reports”:true,“smoke”:false,“supervision_reports”:true,“tamper”:false,“test”:false,“trouble”:false}’
openhab4-zigbee2mqtt-1 | Zigbee2MQTT:info 2024-01-02 18:25:42: Zigbee2MQTT started!
openhab4-zigbee2mqtt-1 | Zigbee2MQTT:debug 2024-01-02 18:25:42: Received MQTT message on ‘zigbee2mqtt/Coordinator/availability’ with data ‘{“state”:“online”}’

There are a number of zigbee2mqtt tutorials on the forum. Here’s one: Zigbee2mqtt revisited: No more ugly transformations

Creating and configuring Generic MQTT Things in the UI is covered in Adding Things - Advanced | openHAB.

At a high level, you create the Thing. Then you create a Channel that represents one of values reported by the device. Configure the Channel to subscribe to the topic (e.g. zigbee2mqtt/smoke_detector_01). Configure a transformation to convert what ever message gets published there to something that can be used by an Item.

Often, as appears to be the case here, you will have one Topic that multiple Channels subscribes to with a different transformation for each Channel to convert that big JSON package to individual Item states.

Thank you for the quick response.

But on the OH4 GUI I see some problems to select the correct identifier.
My mqtt broker has the identifier: mqtt:broker:aad6f354a8

At the mqtt explorer my device rests here: zigbee2mqtt/smoke_detector_01 with that json string:
{
“ac_status”: false,
“battery”: 100,
“battery_defect”: false,
“battery_low”: false,
“linkquality”: 127,
“restore_reports”: true,
“smoke”: false,
“supervision_reports”: true,
“tamper”: false,
“test”: false,
“trouble”: false
}

When I create a “New Generic MQTT Thing” and use zigbee2mqtt I would expect the identifier looks somehow like this:
mqtt:topic:aad6f354a8:zigbee2mqtt:smoke_detector_01

But this type of identifier cannot be set. It is forbidden in the GUI.

So from the documentation it is not fully clear how to add zigbee2mqtt device to a New Generic MQTT Thing.

These are completely unrelated to each other. mqtt:broker:aad6f354a8 is the unique identifier for the Broker Thing. It has nothing to do with anything you see in MQTTExplorer.

If you want the identifier for your new Generic MQTT Thing to look like that, set it to that. It ultimately doesn’t matter. It’s only how OH internally identifies Things so it can keep them all separate. But you only can change this ID when you initially create the Thing. Once the Thing is created, that value is fixed and cannot be changed.

But for all it matters the ID could be mqtt:topic:aad6f354a8:space_tweasers. You will almost never see this ID. You will almost never use this ID. To identify what the Thing represents it’s the label that matters, and you can change that any time you want.

None of this is relevant to adding a zigbee2mqtt device. A Generic MQTT Thing doesn’t know or care anything at all about zigbee2mqtt. All it knows are topics and messages. All it needs to know are topics and messages. And those topics and messages can come from anything, including but not limited to zigbee2mqtt.

The only place where zigbee2mqtt really matters in creating the Generic MQTT Thing is for your benefit so you know the Thing represents something from zigbee2mqtt. And the best place to put that information is in the label, though I would recommend not because it really doesn’t matter that the messages are coming from zigbee2mqtt.

So, again, the process is the same no matter what the source of the MQTT messages are.

At a high level, you create the Thing. Then you create a Channel that represents one of values reported by the device. Configure the Channel to subscribe to the topic (e.g. zigbee2mqtt/smoke_detector_01). Configure a transformation to convert whatever message gets published there to something that can be used by an Item.

All of the steps above are demonstrated in Adding Things - Advanced | openHAB .

Great! so you have all the info you need.

  1. Create a number Channel on your MQTT Thing, label it “Battery Level”.
  2. Set the subscription topic to zigbee2mqtt/smoke_detector_01
  3. Set the incoming transformation to JSONPATH:$.battery
  4. Set the unit to %
  5. Repeat 1-4 for the rest of the values you care about, using the correct Channel type and JSONPATH transform for each value (e.g. if the value is true or false a switch Channel will be used.

Once all the Channels are created, link them to Items.