def setup_bravia(config, pin, hass, add_devices):
 host = config.get(CONF_HOST)
 name = config.get(CONF_NAME)
 if (pin is None):
  request_configuration(config, hass, add_devices)
  return
 else:
  mac = _get_mac_address(host)
  if (mac is not None):
   mac = mac.decode('utf8')
  if (host in _CONFIGURING):
   request_id = _CONFIGURING.pop(host)
   configurator = get_component('configurator')
   configurator.request_done(request_id)
   _LOGGER.info('Discovery configuration done!')
  if (not _config_from_file(hass.config.path(BRAVIA_CONFIG_FILE), {host: {'pin': pin, 'host': host, 'mac': mac}})):
   _LOGGER.error('failed to save config file')
  add_devices([BraviaTVDevice(host, mac, name, pin)])

def setup_bravia ( config , pin , hass , add_devices ) : host = config . get ( CONF_HOST ) name = config . get ( CONF_NAME ) if ( pin is None ) : request_configuration ( config , hass , add_devices ) return else : mac = _get_mac_address ( host ) if ( mac is not None ) : mac = mac . decode ( 'utf8' ) if ( host in _CONFIGURING ) : request_id = _CONFIGURING . pop ( host ) configurator = get_component ( 'configurator' ) configurator . request_done ( request_id ) _LOGGER . info ( 'Discovery configuration done!' ) if ( not _config_from_file ( hass . config . path ( BRAVIA_CONFIG_FILE ) , { host : { 'pin' : pin , 'host' : host , 'mac' : mac } } ) ) : _LOGGER . error ( 'failed to save config file' ) add_devices ( [ BraviaTVDevice ( host , mac , name , pin ) ] )
setup a sony bravia tv based on host parameter .