Skip to content

Commit

Permalink
Fixed problem in paused state and cancel_cleaning method
Browse files Browse the repository at this point in the history
  • Loading branch information
BenjaminPaap committed Oct 14, 2022
1 parent a2f745a commit 8d20528
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 6 deletions.
3 changes: 3 additions & 0 deletions pyneato/enum.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,13 +7,16 @@ class RobotAbilityEnum(str, Enum):
class RobotStateEnum(Enum):
BUSY = 'busy'
IDLE = 'idle'
PAUSED = 'paused'

@staticmethod
def from_str(state: str):
if state == 'busy':
return RobotStateEnum.BUSY
elif state == 'idle':
return RobotStateEnum.IDLE
elif state == 'paused':
return RobotStateEnum.PAUSED
else:
raise NotImplementedError('RobotState %s'%state)

Expand Down
12 changes: 7 additions & 5 deletions pyneato/robot.py
Original file line number Diff line number Diff line change
Expand Up @@ -249,7 +249,7 @@ def _base_message(self, message: str, schema: Schema):
def pause_cleaning(self) -> bool:
result = self._base_message("cleaning.pause", ABILITY_SCHEMA)

return result.success
return result["success"]

def get_state(self) -> RobotState:
result = self._base_message(RobotAbilityEnum.STATE_SHOW.value, STATE_SCHEMA)
Expand Down Expand Up @@ -294,16 +294,18 @@ def info_robot(self):
def resume_cleaning(self) -> bool:
result = self._base_message("cleaning.resume", ABILITY_SCHEMA)

return result.success
return result["success"]

def cancel_cleaning(self) -> bool:
pause_result = self.pause_cleaning()
return_to_base_result = self.return_to_base()

return pause_result.success and return_to_base_result.success
return pause_result and return_to_base_result

def return_to_base(self):
return self._base_message("navigation.return_to_base", ABILITY_SCHEMA)
def return_to_base(self) -> bool:
result = self._base_message("navigation.return_to_base", ABILITY_SCHEMA)

return result["success"]

@property
def state(self):
Expand Down
2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ build-backend = "hatchling.build"

[project]
name = "pyneato"
version = "0.0.2"
version = "0.0.3"
authors = [
{ name="Benjamin Paap", email="[email protected]" },
]
Expand Down

0 comments on commit 8d20528

Please sign in to comment.