def listen(hass, service, callback):
    if isinstance(service, str):
        service = (service,)
    else:
        service = tuple(service)

    def discovery_event_listener(event):
        """Listen for discovery events."""
        if event.data[ATTR_SERVICE] in service:
            callback(event.data[ATTR_SERVICE], event.data.get(ATTR_DISCOVERED))

    hass.bus.listen(EVENT_PLATFORM_DISCOVERED, discovery_event_listener)
Setup listener for discovery of specific service.
dataset/ETHPy150Open home-assistant/home-assistant/homeassistant/components/discovery.py/listen