Update SpotArea

Update SpotArea and CLI command to more closely reflect the app
Library:
SpotArea namedarea -> area
SpotArea customarea -> map_position

CLI Commands:
spotclean -> area
Ex: sucks area 0,1
  - will clean areas 0 and 1 / A and B

area options:
--map-postion|-p
  - will clean a specified map coordinate
Ex: sucks area -p "-602,1812,800,723"
  - will clean the specified custom map coordinates
This commit is contained in:
Brian Martin
2019-02-20 10:45:24 -05:00
parent bfca7e9e82
commit b7341b0735
3 changed files with 26 additions and 21 deletions
+6 -6
View File
@@ -1020,14 +1020,14 @@ class Stop(Clean):
super().__init__('stop', 'normal')
class SpotArea(Clean):
def __init__(self, action='start', namedarea='', customarea='', cleanings='1'):
if namedarea != '': #For cleaning specified map area
super().__init__('spot_area', 'normal', act=CLEAN_ACTION_TO_ECOVACS[action], mid=namedarea)
elif customarea != '': #For cleaning custom map area, and specify deep amount 1x/2x
super().__init__('spot_area' ,'normal',act=CLEAN_ACTION_TO_ECOVACS[action], p=customarea, deep=cleanings)
def __init__(self, action='start', area='', map_position='', cleanings='1'):
if area != '': #For cleaning specified area
super().__init__('spot_area', 'normal', act=CLEAN_ACTION_TO_ECOVACS[action], mid=area)
elif map_position != '': #For cleaning custom map area, and specify deep amount 1x/2x
super().__init__('spot_area' ,'normal',act=CLEAN_ACTION_TO_ECOVACS[action], p=map_position, deep=cleanings)
else:
#no valid entries
raise ValueError("must provide namedarea or customarea for spotarea clean")
raise ValueError("must provide area or map_position for spotarea clean")
class Charge(VacBotCommand):
def __init__(self):
+9 -4
View File
@@ -179,10 +179,15 @@ def edge(frequency, minutes):
return CliAction(Edge(), wait=TimeWait(minutes * 60))
@cli.command(help='spotcleans provided room(s)')
@click.argument('room', type=click.STRING)
def spotclean(room):
return CliAction(SpotArea('start', room), wait=StatusWait('charge_status', 'returning'))
@cli.command(help='cleans provided area(s), ex: "0,1"',context_settings={"ignore_unknown_options": True}) #ignore_unknown for map coordinates with negatives
@click.option("--map-position","-p", is_flag=True, help='clean provided map position instead of area, ex: "-602,1812,800,723"')
@click.argument('area', type=click.STRING, required=True)
def area(area, map_position):
if map_position:
return CliAction(SpotArea('start', map_position=area), wait=StatusWait('charge_status', 'returning'))
else:
return CliAction(SpotArea('start', area=area), wait=StatusWait('charge_status', 'returning'))
@cli.command(help='returns to charger')
def charge():
+11 -11
View File
@@ -61,31 +61,31 @@ def test_spotarea_command():
assert_equals(ElementTree.tostring(c.to_xml()),
b'<ctl td="Clean"><clean act="s" mid="0" speed="standard" type="SpotArea" /></ctl>') #Test namedarea clean
c = SpotArea('start', namedarea='0')
c = SpotArea('start', area='0')
assert_equals(ElementTree.tostring(c.to_xml()),
b'<ctl td="Clean"><clean act="s" mid="0" speed="standard" type="SpotArea" /></ctl>') #Test namedarea keyword clean
c = SpotArea('start', '', '01234,56789')
c = SpotArea('start', '', '-602,1812,800,723')
assert_equals(ElementTree.tostring(c.to_xml()),
b'<ctl td="Clean"><clean act="s" deep="1" p="01234,56789" speed="standard" type="SpotArea" /></ctl>') #Test customarea clean
b'<ctl td="Clean"><clean act="s" deep="1" p="-602,1812,800,723" speed="standard" type="SpotArea" /></ctl>') #Test customarea clean
c = SpotArea('start', '', '01234,56789', '2')
c = SpotArea('start', '', '-602,1812,800,723', '2')
assert_equals(ElementTree.tostring(c.to_xml()),
b'<ctl td="Clean"><clean act="s" deep="2" p="01234,56789" speed="standard" type="SpotArea" /></ctl>') #Test customarea clean with deep 2
b'<ctl td="Clean"><clean act="s" deep="2" p="-602,1812,800,723" speed="standard" type="SpotArea" /></ctl>') #Test customarea clean with deep 2
c = SpotArea('start', '', customarea='01234,56789')
c = SpotArea('start', '', map_position='-602,1812,800,723')
assert_equals(ElementTree.tostring(c.to_xml()),
b'<ctl td="Clean"><clean act="s" deep="1" p="01234,56789" speed="standard" type="SpotArea" /></ctl>') #Test customarea keyword clean with deep default
b'<ctl td="Clean"><clean act="s" deep="1" p="-602,1812,800,723" speed="standard" type="SpotArea" /></ctl>') #Test customarea keyword clean with deep default
c = SpotArea('start', customarea='01234,56789', cleanings='2')
c = SpotArea('start', map_position='-602,1812,800,723', cleanings='2')
assert_equals(ElementTree.tostring(c.to_xml()),
b'<ctl td="Clean"><clean act="s" deep="2" p="01234,56789" speed="standard" type="SpotArea" /></ctl>') #Test customarea keyword and cleanings keyword clean with deep default
b'<ctl td="Clean"><clean act="s" deep="2" p="-602,1812,800,723" speed="standard" type="SpotArea" /></ctl>') #Test customarea keyword and cleanings keyword clean with deep default
c = SpotArea('start', namedarea='0', customarea='01234,56789', cleanings='2')
c = SpotArea('start', area='0', map_position='-602,1812,800,723', cleanings='2')
assert_equals(ElementTree.tostring(c.to_xml()),
b'<ctl td="Clean"><clean act="s" mid="0" speed="standard" type="SpotArea" /></ctl>') #Test all keywords specified, should default to only mid
c = SpotArea('start', '0', '01234,56789','2')
c = SpotArea('start', '0', '-602,1812,800,723','2')
assert_equals(ElementTree.tostring(c.to_xml()),
b'<ctl td="Clean"><clean act="s" mid="0" speed="standard" type="SpotArea" /></ctl>') #Test all keywords specified, should default to only mid