(self)
return RESULT_NOT_SUCCESSFUL
Try to connect to device using web sockets on port 8001 and 8002
Try to connect to device using web sockets on port 8001 and 8002
Try to connect to device using web sockets on port 8001 and 8002
def _try_connect_ws(self):
        """Try to connect to device using web sockets on port 8001 and 8002"""

        for port in (8001, 8002):

            try:
                _LOGGER.info(
                    "Try to configure SamsungTV %s using port %s",
                    self._hostname,
                    str(port),
                )
                token_file = get_token_file(self._hass, self._hostname, port, True)
                with SamsungTVWS(
                    name=f"{WS_PREFIX} {self._ws_name}",  # this is the name shown in the TV list of external device.
                    host=self._hostname,
                    port=port,
                    token_file=token_file,
                    timeout=45,  # We need this high timeout because waiting for auth popup is just an open socket
                ) as remote:
                    remote.open()
                _LOGGER.info("Found working configuration using port %s", str(port))
                self._ws_port = port
                return RESULT_SUCCESS
            except (OSError, ConnectionFailure, WebSocketException) as err:
                _LOGGER.info("Configuration failed using port %s, error: %s", str(port), err)

        _LOGGER.error("Web socket connection to SamsungTV %s failed", self._hostname)
        return RESULT_NOT_SUCCESSFUL
def _try_connect_ws ( self ) : for port in ( 8001 , 8002 ) : try : _LOGGER . info ( "Try to configure SamsungTV %s using port %s" , self . _hostname , str ( port ) , ) token_file = get_token_file ( self . _hass , self . _hostname , port , True ) with SamsungTVWS ( name = f"{WS_PREFIX} {self._ws_name}" , # this is the name shown in the TV list of external device. host = self . _hostname , port = port , token_file = token_file , timeout = 45 , # We need this high timeout because waiting for auth popup is just an open socket ) as remote : remote . open ( ) _LOGGER . info ( "Found working configuration using port %s" , str ( port ) ) self . _ws_port = port return RESULT_SUCCESS except ( OSError , ConnectionFailure , WebSocketException ) as err : _LOGGER . info ( "Configuration failed using port %s, error: %s" , str ( port ) , err ) _LOGGER . error ( "Web socket connection to SamsungTV %s failed" , self . _hostname ) return RESULT_NOT_SUCCESSFUL