Yes but it requires more work.
First, you have to disable Zigbee2MQTT’s use of MQTT Discovery. In Zigbee2MQTT’s configuration.yaml file, set homeassistant: false (and restart it). All of the Zigbee devices and entities that have been discovered by Home Assistant will disappear.
Second, you must define the entities. However, as you have already discovered, in YAML you can only create entities manually not devices. In other words you cannot manually create a device (in YAML), with associated entities, it can only be created via MQTT Discovery. In fact, it even mentions that in the documentation for MQTT Sensor:
device map (Optional)
Information about the device this sensor is a part of to tie it into the device registry. Only works through MQTT discovery and when
unique_idis set.
The solution is to create a script that uses MQTT Discovery. In other words, you will use a script to create the device and entities using the same technique that Zigbee2MQTT employs. However, because it’s a script, you have complete control over how it creates a device and entities.
I posted an example of how to make a script that creates devices and entities here:
For your purposes, here’s an example of a script that create two sensor entities that belong to the same device:
example_1:
alias: 'Create one device with two entities'
sequence:
- service: mqtt.publish
data:
topic: homeassistant/sensor/temperature1/config
retain: true
payload: >
{
"name": "Indoor Temperature",
"state_topic": "home/indoor/temp",
"unique_id": "abc123",
"device": {
"identifiers": ["aqara"],
"name": "Aqara Sensor",
"model": "Aqara",
"manufacturer": "xiaomi",
"sw_version": "1.X"
}
}
- service: mqtt.publish
data:
topic: homeassistant/sensor/humidity1/config
retain: true
payload: >
{
"name": "Indoor Humidity",
"state_topic": "home/humidity/temp",
"unique_id": "xyz789",
"device": {
"identifiers": ["aqara"],
"name": "Aqara Sensor",
"model": "Aqara",
"manufacturer": "xiaomi",
"sw_version": "1.X"
}
}