code: def connection_made(self, transport):
          
          randomness = os.urandom(16)
          key = base64encode(randomness).decode('utf-8').strip()
          self.transport = transport
          message = "GET / HTTP/1.1\r\n"
          message += "Host: " + self.host + ':' + str(self.port) + '\r\n'
          message += "User-Agent: Python/3.5 websockets/3.4\r\n"
          message += "Upgrade: Websocket\r\n"
          message += "Connection: Upgrade\r\n"
          message += "Sec-WebSocket-Key: " + key + "\r\n"
          message += "Sec-WebSocket-Version: 13\r\n"
          message += "\r\n"
          _LOGGER.debug('Websocket handshake: %s', message)
          self.transport.write(message.encode())
docs: Do the websocket handshake.
  
          According to https://tools.ietf.org/html/rfc6455