#NEWLINE# def listen( hass , service , callback ) : #NEWLINE# #INDENT# 'Setup listener for discovery of specific service.\n\n    Service can be a string or a list/tuple.\n    ' #NEWLINE# if isinstance ( discovery_event_listener , str ) : #NEWLINE# #INDENT# service = ( service , ) #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# service = tuple ( service ) #NEWLINE# #UNINDENT# def discovery_event_listener( event ) : #NEWLINE# #INDENT# 'Listen for discovery events.' #NEWLINE# if ( event . data [ ATTR_SERVICE ] in service ) : #NEWLINE# #INDENT# callback ( event . data [ ATTR_SERVICE ] , event . data . get ( ATTR_DISCOVERED ) ) #NEWLINE# #UNINDENT# #UNINDENT# hass . bus . listen ( EVENT_PLATFORM_DISCOVERED , discovery_event_listener )