Stop capitilization adjustment on commands, allow None for args
The capitalization adjustment was breaking any commands that required CamelCase, such as GetChargeState. Args are not needed for commands such as GetChargeState, so the xml will no longer build that array if it's set to None.
This commit is contained in:
+8
-6
@@ -194,6 +194,7 @@ class VacBot(ClientXMPP):
|
||||
|
||||
def send_command(self, xml):
|
||||
c = self.wrap_command(xml)
|
||||
logging.debug('Sending command {0}'.format(c))
|
||||
c.send()
|
||||
|
||||
def wrap_command(self, ctl):
|
||||
@@ -227,7 +228,7 @@ class VacBot(ClientXMPP):
|
||||
|
||||
|
||||
class VacBotCommand:
|
||||
def __init__(self, name, args, wait=None, terminal=False):
|
||||
def __init__(self, name, args=None, wait=None, terminal=False):
|
||||
self.name = name
|
||||
self.args = args
|
||||
self.wait = wait
|
||||
@@ -239,7 +240,8 @@ class VacBotCommand:
|
||||
time.sleep(self.wait)
|
||||
|
||||
def to_xml(self):
|
||||
ctl = ET.Element('ctl', {'td': self.name.capitalize()})
|
||||
ctl = ET.Element('ctl', {'td': self.name})
|
||||
if self.args:
|
||||
inner = ET.Element(self.name, self.args)
|
||||
ctl.append(inner)
|
||||
return ctl
|
||||
@@ -253,17 +255,17 @@ class VacBotCommand:
|
||||
|
||||
class Clean(VacBotCommand):
|
||||
def __init__(self, wait):
|
||||
super().__init__('clean', {'type': 'auto', 'speed': 'standard'}, wait)
|
||||
super().__init__('Clean', {'type': 'auto', 'speed': 'standard'}, wait)
|
||||
|
||||
|
||||
class Edge(VacBotCommand):
|
||||
def __init__(self, wait):
|
||||
super().__init__('clean', {'type': 'border', 'speed': 'strong'}, wait)
|
||||
super().__init__('Clean', {'type': 'border', 'speed': 'strong'}, wait)
|
||||
|
||||
|
||||
class Charge(VacBotCommand):
|
||||
def __init__(self):
|
||||
super().__init__('charge', {'type': 'go'}, terminal=True)
|
||||
super().__init__('Charge', {'type': 'go'}, terminal=True)
|
||||
|
||||
def wait_for_completion(self, bot):
|
||||
logging.debug("waiting in " + self.name)
|
||||
@@ -275,7 +277,7 @@ class Charge(VacBotCommand):
|
||||
|
||||
class Stop(VacBotCommand):
|
||||
def __init__(self):
|
||||
super().__init__('clean', {'type': 'stop', 'speed': 'standard'}, terminal=True)
|
||||
super().__init__('Clean', {'type': 'stop', 'speed': 'standard'}, terminal=True)
|
||||
|
||||
def wait_for_completion(self, bot):
|
||||
logging.debug("waiting in " + self.name)
|
||||
|
||||
Reference in New Issue
Block a user