Custom component Mqtt subscribe

Hi, I’m developing a custom component for an homemade esp8266 based AC control unit. I successfully publish message on mqtt topic but I need to subscribe to a topic to read the actual status of AC unit. How can I subscribe to a topic and update the custom component status? Thank you

Subscribe to a topic in HA ?
Subscribe to a topic on your esp8266 ?

It’s not clear what you are asking.

Sorry I not explain correctly. I want to subscribe to a mqtt topic inside custom component code.

I got it:

def message_received(msg):
           print(msg.payload)
        
 # Subscribe our listener to a topic.
mqtt.subscribe(self._hass, self._topic, message_received, 0, "utf-8")