def setup_tv(host, mac, name, customize, hass, add_devices):
 from pylgtv import WebOsClient
 from pylgtv import PyLGTVPairException
 from websockets.exceptions import ConnectionClosed
 client = WebOsClient(host)
 if (not client.is_registered()):
  if (host in _CONFIGURING):
   try:
    client.register()
   except PyLGTVPairException:
    _LOGGER.warning('Connected to LG webOS TV %s but not paired', host)
    return
   except (OSError, ConnectionClosed):
    _LOGGER.error('Unable to connect to host %s', host)
    return
  else:
   _LOGGER.warning('LG webOS TV %s needs to be paired', host)
   request_configuration(host, mac, name, customize, hass, add_devices)
   return
 if (client.is_registered() and (host in _CONFIGURING)):
  request_id = _CONFIGURING.pop(host)
  configurator = get_component('configurator')
  configurator.request_done(request_id)
 add_devices([LgWebOSDevice(host, mac, name, customize)], True)

def setup_tv ( host , mac , name , customize , hass , add_devices ) : from pylgtv import WebOsClient from pylgtv import PyLGTVPairException from websockets . exceptions import ConnectionClosed client = WebOsClient ( host ) if ( not client . is_registered ( ) ) : if ( host in _CONFIGURING ) : try : client . register ( ) except PyLGTVPairException : _LOGGER . warning ( 'Connected to LG webOS TV %s but not paired' , host ) return except ( OSError , ConnectionClosed ) : _LOGGER . error ( 'Unable to connect to host %s' , host ) return else : _LOGGER . warning ( 'LG webOS TV %s needs to be paired' , host ) request_configuration ( host , mac , name , customize , hass , add_devices ) return if ( client . is_registered ( ) and ( host in _CONFIGURING ) ) : request_id = _CONFIGURING . pop ( host ) configurator = get_component ( 'configurator' ) configurator . request_done ( request_id ) add_devices ( [ LgWebOSDevice ( host , mac , name , customize ) ] , True )
setup a lg webos tv based on host parameter .