Mqtt Auto discovery issue

Hello everyone,
I am trying to make my esp32 to be automatically discovered by home assistant. I am publishing discovery message with the topic: homeassistant/sensor/esp32_device/config and the payload:

{ 
"name": "test_sensor",  
"value_template": "{{ value }}",
  "unique_id": "xyz_test",
  "state_topic": "homeassistant/sensor/esp_test/state",
  "device": {
    "name": "CustomSensor",
    "model": "ESP32Device",
    "sw_version": "1.0",
    "manufacturer": "x",
    "identifiers": [
      "xyz"
    ]
  }
} 

home assistant discovers it as entity but not as device. I couldn’t figure out what am I missing. Any help will be much appreciated.

Thanks in advance
Tugrul

Are you not publishing your actual MQTT messages under the home/… topic, and therefore the state_topic should be as such?