'Detect if local client and adjust url to allow control.'

def _local_client_control_fix(self):

    if (self.device is None):
        return
    for client in self.device.server.clients():
        if (('127.0.0.1' in client.baseurl) and (client.machineIdentifier == self.device.machineIdentifier)):
            _LOGGER.debug('Local    client    detected,    redirecting    controls    to    Plex    server:    %s', self.entity_id)
            server_url = self.device.server.baseurl
            client_url = self.device.baseurl
            self.device.baseurl = '{}://{}:{}'.format(urlparse(client_url).scheme, urlparse(server_url).hostname, str(urlparse(client_url).port))
