-
-
Notifications
You must be signed in to change notification settings - Fork 568
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Added new commands app_goto_target and app_zoned_clean #310
Merged
Merged
Changes from 10 commits
Commits
Show all changes
11 commits
Select commit
Hold shift + click to select a range
cc5e70a
Added new app_goto_target command
ciB89 bfe0793
Merge pull request #1 from ciB89/patch-1
ciB89 866969b
added new command app_zoned_clean
ciB89 b5d35ad
updated syntax with new commands
ciB89 ca45feb
removed whitespaces
ciB89 4e8feba
added tests
ciB89 4b8262d
changed variable name for x_coord in zoned_clean
ciB89 b06801a
Update test_vacuum.py
ciB89 554b5fc
Update vacuum.py
ciB89 edd5733
Update test_vacuum.py
ciB89 dd76ada
fixed typing error
ciB89 File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -10,9 +10,11 @@ | |
class DummyVacuum(DummyDevice, Vacuum): | ||
STATE_CHARGING = 8 | ||
STATE_CLEANING = 5 | ||
STATE_ZONED_CLEAN = 9 | ||
STATE_IDLE = 3 | ||
STATE_HOME = 6 | ||
STATE_SPOT = 11 | ||
STATE_GOTO = 4 | ||
STATE_ERROR = 12 | ||
STATE_PAUSED = 10 | ||
STATE_MANUAL = 7 | ||
|
@@ -28,7 +30,7 @@ def __init__(self, *args, **kwargs): | |
'clean_area': 0, | ||
'battery': 100, | ||
'fan_power': 20, | ||
'msg_seq': 320 | ||
'msg_seq': 320, | ||
} | ||
|
||
self.return_values = { | ||
|
@@ -37,6 +39,8 @@ def __init__(self, *args, **kwargs): | |
'app_stop': lambda x: self.change_mode("stop"), | ||
'app_pause': lambda x: self.change_mode("pause"), | ||
'app_spot': lambda x: self.change_mode("spot"), | ||
'app_goto_target': lambda x: self.change_mode("goto"), | ||
'app_zoned_clean': lambda x: self.change_mode("zoned clean"), | ||
'app_charge': lambda x: self.change_mode("charge") | ||
} | ||
|
||
|
@@ -53,6 +57,10 @@ def change_mode(self, new_mode): | |
self.state["state"] = DummyVacuum.STATE_CLEANING | ||
elif new_mode == "stop": | ||
self.state["state"] = DummyVacuum.STATE_IDLE | ||
elif new_mode == "goto": | ||
self.state["state"] = DummyVacuum.STATE_GOTO | ||
elif new_mode == "zoned cleaning": | ||
self.state["state"] = DummyVacuum.STATE_ZONED_CLEAN | ||
elif new_mode == "charge": | ||
self.state["state"] = DummyVacuum.STATE_CHARGING | ||
|
||
|
@@ -128,6 +136,18 @@ def test_home(self): | |
# Another option is to mock that app_stop mode is entered before | ||
# the charging is activated. | ||
|
||
def test_goto(self): | ||
self.device.start() | ||
assert self.status().is_on is True | ||
self.device.goto(24000,24000) | ||
assert self.status().state_code == self.device.STATE_GOTO | ||
|
||
def test_zoned_clean(self): | ||
self.device.start() | ||
assert self.status().is_on is True | ||
self.device.zoned_clean(25000,25000,25500,25500,3) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. missing whitespace after ',' |
||
assert self.status().state_code == self.device.STATE_ZONED_CLEAN | ||
|
||
@pytest.mark.xfail | ||
def test_manual_control(self): | ||
self.fail() | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -73,6 +73,35 @@ def home(self): | |
self.send("app_stop") | ||
return self.send("app_charge") | ||
|
||
@command( | ||
click.argument("x_coord", type=int), | ||
click.argument("y_coord", type=int), | ||
) | ||
def goto(self, x_coord: int, y_coord: int): | ||
"""Go to specific target. | ||
:param int x_coord: x coordinate | ||
:param int y_coord: y coordinate""" | ||
return self.send("app_goto_target", | ||
[x_coord, y_coord]) | ||
|
||
@command( | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. expected 1 blank line, found 0 |
||
click.argument("x1_coord", type=int), | ||
click.argument("y1_coord", type=int), | ||
click.argument("x2_coord", type=int), | ||
click.argument("y2_coord", type=int), | ||
click.argument("iterations", type=int), | ||
) | ||
def zoned_clean(self, x1_coord: int, y1_coord: int, | ||
x2_coord: int, y2_coord: int, iterations: int): | ||
"""Clean a zoned area. | ||
:param int x1_coord: x1 coordinate bottom left corner | ||
:param int y1_coord: y1 coordinate bottom left corner | ||
:param int x2_coord: x2 coordinate top right corner | ||
:param int y2_coord: y2 coordinate top right corner | ||
:param int iterations: How many times the zone should be cleaned""" | ||
return self.send("app_zoned_clean", | ||
[x1_coord, y1_coord, x2_coord, y2_coord, iterations]) | ||
|
||
@command() | ||
def manual_start(self): | ||
"""Start manual control mode.""" | ||
|
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
missing whitespace after ','