diff --git a/sucks/__init__.py b/sucks/__init__.py
index e535d29..323eb08 100644
--- a/sucks/__init__.py
+++ b/sucks/__init__.py
@@ -792,26 +792,16 @@ class Stop(Clean):
super().__init__('stop', 'normal')
class SpotArea(Clean):
- def __init__(self, **kwargs):
- self.action='start'
- self.mid=''
- self.p=''
- self.deep=''
- if kwargs is not None:
- for kkey, kvalue in kwargs.items():
- if kkey == 'action':
- self.action = kvalue
- elif kkey == 'mid':
- self.mid = kvalue
- elif kkey == 'p':
- self.p = kvalue
- elif kkey == 'deep':
- self.deep = kvalue
+ def __init__(self, action='start', namedarea='', customarea='', cleanings='1'):
+
- if self.mid != '': #For cleaning specified map area
- super().__init__('spotarea', 'normal', act=CLEAN_ACTION_TO_ECOVACS[self.action], mid=self.mid)
- elif self.p != '': #For cleaning custom map area, and specify deep amount 1x/2x
- super().__init__('spotarea' ,'normal',act=CLEAN_ACTION_TO_ECOVACS[self.action], p=self.p, deep=self.deep)
+ if namedarea != '': #For cleaning specified map area
+ super().__init__('spotarea', 'normal', act=CLEAN_ACTION_TO_ECOVACS[action], mid=namedarea)
+ elif customarea != '': #For cleaning custom map area, and specify deep amount 1x/2x
+ super().__init__('spotarea' ,'normal',act=CLEAN_ACTION_TO_ECOVACS[action], p=customarea, deep=cleanings)
+ else:
+ #no valid entries
+ raise ValueError("must provide namedarea or customarea for spotarea clean")
class Charge(VacBotCommand):
def __init__(self):
diff --git a/sucks/cli.py b/sucks/cli.py
index 88b6e24..727b730 100644
--- a/sucks/cli.py
+++ b/sucks/cli.py
@@ -216,7 +216,7 @@ def run(actions, debug):
#vacbot.connect_and_wait_until_ready()(
- vacbot.run(SpotArea(action='start', mid='0'))
+ vacbot.run(SpotArea('start'))
#vacbot.request_all_statuses()
diff --git a/tests/test_commands.py b/tests/test_commands.py
index 6ed18cc..a1f020e 100644
--- a/tests/test_commands.py
+++ b/tests/test_commands.py
@@ -33,6 +33,42 @@ def test_clean_command():
c = Clean('edge', 'high')
assert_equals(ElementTree.tostring(c.to_xml()),
b'') # protocol has attribs in other order
+
+
+def test_spotarea_command():
+ assert_raises(ValueError, SpotArea, 'start') #Value error if SpotArea doesn't include a mid or p
+
+ c = SpotArea('start', '0')
+ assert_equals(ElementTree.tostring(c.to_xml()),
+ b'') #Test namedarea clean
+
+ c = SpotArea('start', namedarea='0')
+ assert_equals(ElementTree.tostring(c.to_xml()),
+ b'') #Test namedarea keyword clean
+
+ c = SpotArea('start', '', '01234,56789')
+ assert_equals(ElementTree.tostring(c.to_xml()),
+ b'') #Test customarea clean
+
+ c = SpotArea('start', '', '01234,56789', '2')
+ assert_equals(ElementTree.tostring(c.to_xml()),
+ b'') #Test customarea clean with deep 2
+
+ c = SpotArea('start', '', customarea='01234,56789')
+ assert_equals(ElementTree.tostring(c.to_xml()),
+ b'') #Test customarea keyword clean with deep default
+
+ c = SpotArea('start', customarea='01234,56789', cleanings='2')
+ assert_equals(ElementTree.tostring(c.to_xml()),
+ b'') #Test customarea keyword and cleanings keyword clean with deep default
+
+ c = SpotArea('start', namedarea='0', customarea='01234,56789', cleanings='2')
+ assert_equals(ElementTree.tostring(c.to_xml()),
+ b'') #Test all keywords specified, should default to only mid
+
+ c = SpotArea('start', '0', '01234,56789','2')
+ assert_equals(ElementTree.tostring(c.to_xml()),
+ b'') #Test all keywords specified, should default to only mid
def test_edge_command():