<SYSTEM_TASK:>
Solve the following problem using Python, implementing the functions described below, one line at a time
<END_TASK>
<USER_TASK:>
Description:
 def __query_cmd(self, command, device=None):
 """Calls a command"""

        base_url = u'%s&switchcmd=%s' % (self.__homeauto_url_with_sid(), command)

        if device is None:
            url = base_url
        else:
            url = '%s&ain=%s' % (base_url, device)

        if self.__debug:
            print(u'Query Command URI: ' + url)

        return self.__query(url)