<s> """<STR_LIT>""" <EOL> import logging <EOL> from homeassistant . components . notify import ( BaseNotificationService , DOMAIN ) <EOL> from homeassistant . const import ( CONF_HOST , CONF_NAME ) <EOL> from homeassistant . helpers import validate_config <EOL> REQUIREMENTS = [ '<STR_LIT>' <EOL> '<STR_LIT>' <EOL> '<STR_LIT>' ] <EOL> _LOGGER = logging . getLogger ( __name__ ) <EOL> def get_service ( hass , config ) : <EOL> """<STR_LIT>""" <EOL> if not validate_config ( { DOMAIN : config } , { DOMAIN : [ CONF_HOST , CONF_NAME ] } , <EOL> _LOGGER ) : <EOL> return None <EOL> host = config . get ( CONF_HOST , None ) <EOL> if not host : <EOL> _LOGGER . error ( '<STR_LIT>' ) <EOL> return None <EOL> from pylgtv import WebOsClient <EOL> from pylgtv import PyLGTVPairException <EOL> client = WebOsClient ( host ) <EOL> try : <EOL> client . register ( ) <EOL> except PyLGTVPairException : <EOL> _LOGGER . error ( '<STR_LIT>' ) <EOL> return None <EOL> except OSError : <EOL> _LOGGER . error ( '<STR_LIT>' ) <EOL> return None <EOL> return LgWebOSNotificationService ( client ) <EOL> class LgWebOSNotificationService ( BaseNotificationService ) : <EOL> """<STR_LIT>""" <EOL> def __init__ ( self , client ) : <EOL> """<STR_LIT>""" <EOL> self . _client = client <EOL> def send_message ( self , message = "<STR_LIT>" , ** kwargs ) : <EOL> """<STR_LIT>""" <EOL> from pylgtv import PyLGTVPairException <EOL> try : <EOL> self . _client . send_message ( message ) <EOL> except PyLGTVPairException : <EOL> _LOGGER . error ( '<STR_LIT>' ) <EOL> except OSError : <EOL> _LOGGER . error ( '<STR_LIT>' ) </s>
