-
-
Notifications
You must be signed in to change notification settings - Fork 197
OZMO 905 Support #883
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
Closed
Closed
OZMO 905 Support #883
Changes from all commits
Commits
Show all changes
28 commits
Select commit
Hold shift + click to select a range
dd996da
Add legacy GetNetInfo JSON command
nanomad 192b023
Initial Ozmo 900 support
nanomad fe04e13
Implement XML message handling
nanomad ae3309a
Ignore ruff error
nanomad 9c5e88d
Do not go idle while cleaning
nanomad 28544b8
Use correct Charge and PlaySound commands
nanomad db9af4f
Always notify idle and paused states
nanomad 30642f9
Add clean logs capability
nanomad f3a0b60
Convert CleanAction to CleanState
nanomad 677616e
Apply suggestions from code review
nanomad 12fd347
Fix bytes and bytearray decoding
nanomad 7b6e737
Ignore MapP word as it is a message type
nanomad 935b92a
Run ruff format
nanomad ee9a687
2pv572: Disable volume configuration (unsupported in ecovacs app)
nanomad b520287
Fix cleaning tests
nanomad 47aa64d
Fix charge state tests
nanomad ea6060c
Make volume capability optional
nanomad f448abe
Add 2pv572 LifeSpan Capabilities
nanomad cfb095f
Fix type linting error in device.py
nanomad ca44b20
Add legacy GetNetInfo JSON command
nanomad 75ad3a4
Add more XML commands and messages
nanomad a204679
Add decoding for ReportStatsEvent
nanomad 0d5fa49
Add water capability
nanomad e0ce03f
Map workflow
nanomad ffc41fc
Handle MapTrace events
nanomad 895a635
Realtime map updates
nanomad b22f593
Enable trace reporting from the bot.
nanomad e241f9e
Rollback deprecated change
nanomad 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 hidden or 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
This file contains hidden or 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
This file contains hidden or 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
This file contains hidden or 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
This file contains hidden or 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
This file contains hidden or 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
This file contains hidden or 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 |
|---|---|---|
| @@ -0,0 +1,97 @@ | ||
| """Clean commands.""" | ||
|
|
||
| from __future__ import annotations | ||
|
|
||
| from typing import TYPE_CHECKING | ||
|
|
||
| from deebot_client.events import FanSpeedEvent, FanSpeedLevel, StateEvent | ||
| from deebot_client.logging_filter import get_logger | ||
| from deebot_client.message import HandlingResult | ||
| from deebot_client.models import CleanAction, CleanMode, State | ||
|
|
||
| from .common import ExecuteCommand, XmlCommandWithMessageHandling | ||
|
|
||
| if TYPE_CHECKING: | ||
| from xml.etree.ElementTree import Element | ||
|
|
||
| from deebot_client.event_bus import EventBus | ||
|
|
||
| _LOGGER = get_logger(__name__) | ||
|
|
||
|
|
||
| class Clean(ExecuteCommand): | ||
| """Generic start/pause/stop cleaning command.""" | ||
|
|
||
| NAME = "Clean" | ||
| HAS_SUB_ELEMENT = True | ||
|
|
||
| def __init__( | ||
| self, action: CleanAction, speed: FanSpeedLevel = FanSpeedLevel.NORMAL | ||
| ) -> None: | ||
| # <ctl><clean type='SpotArea' act='s' speed='standard' deep='1' mid='4,5'/></ctl> | ||
|
|
||
| super().__init__( | ||
| { | ||
| "type": CleanMode.AUTO.xml_value, | ||
| "act": action.xml_value, | ||
| "speed": speed.xml_value, | ||
| } | ||
| ) | ||
|
|
||
|
|
||
| class CleanArea(ExecuteCommand): | ||
| """Clean area command.""" | ||
|
|
||
| NAME = "Clean" | ||
| HAS_SUB_ELEMENT = True | ||
|
|
||
| def __init__( | ||
| self, | ||
| mode: CleanMode, | ||
| area: str, | ||
| cleanings: int = 1, | ||
| speed: FanSpeedLevel = FanSpeedLevel.NORMAL, | ||
| ) -> None: | ||
| # <ctl><clean type='SpotArea' act='s' speed='standard' deep='1' mid='4,5'/></ctl> | ||
|
|
||
| super().__init__( | ||
| { | ||
| "type": mode.xml_value, | ||
| "act": CleanAction.START.xml_value, | ||
| "speed": speed.xml_value, | ||
| "deep": str(cleanings), | ||
| "mid": area, | ||
| } | ||
| ) | ||
|
|
||
|
|
||
| class GetCleanState(XmlCommandWithMessageHandling): | ||
| """GetCleanState command.""" | ||
|
|
||
| NAME = "GetCleanState" | ||
|
|
||
| @classmethod | ||
| def _handle_xml(cls, event_bus: EventBus, xml: Element) -> HandlingResult: | ||
| """Handle xml message and notify the correct event subscribers. | ||
|
|
||
| :return: A message response | ||
| """ | ||
| if xml.attrib.get("ret") != "ok" or (clean := xml.find("clean")) is None: | ||
| return HandlingResult.analyse() | ||
|
|
||
| speed_attrib = clean.attrib.get("speed") | ||
| if speed_attrib is not None: | ||
| fan_speed_level = FanSpeedLevel.from_xml(speed_attrib) | ||
| event_bus.notify(FanSpeedEvent(fan_speed_level)) | ||
|
|
||
| clean_attrib = clean.attrib.get("st") | ||
| if clean_attrib is not None: | ||
| clean_action = CleanAction.from_xml(clean_attrib) | ||
| if clean_action == CleanAction.START: | ||
| event_bus.notify(StateEvent(State.CLEANING)) | ||
| elif clean_action == CleanAction.PAUSE: | ||
| event_bus.notify(StateEvent(State.PAUSED)) | ||
| else: | ||
| _LOGGER.debug("Ignored CleanState %s", clean_action) | ||
|
Member
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. Why are we ignoring this state? If we don't know what this state means, then we should return |
||
|
|
||
| return HandlingResult.success() | ||
This file contains hidden or 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 |
|---|---|---|
| @@ -0,0 +1,75 @@ | ||
| """Clean Logs commands.""" | ||
|
|
||
| from __future__ import annotations | ||
|
|
||
| from typing import TYPE_CHECKING | ||
|
|
||
| from deebot_client.command import CommandResult | ||
| from deebot_client.events import ( | ||
| CleanLogEntry, | ||
| CleanLogEvent, | ||
| ) | ||
| from deebot_client.logging_filter import get_logger | ||
| from deebot_client.message import HandlingResult | ||
| from deebot_client.util import get_enum | ||
|
|
||
| from .common import XmlCommandWithMessageHandling | ||
| from .enum import XmlStopReason | ||
|
|
||
| if TYPE_CHECKING: | ||
| from xml.etree.ElementTree import Element | ||
|
|
||
| from deebot_client.event_bus import EventBus | ||
|
|
||
| _LOGGER = get_logger(__name__) | ||
|
|
||
|
|
||
| class GetCleanLogs(XmlCommandWithMessageHandling): | ||
| """GetCleanLogs command.""" | ||
|
|
||
| NAME = "GetCleanLogs" | ||
|
|
||
| def __init__(self, count: int = 0) -> None: | ||
| super().__init__({"count": str(count)}) | ||
|
|
||
| @classmethod | ||
| def _handle_xml(cls, event_bus: EventBus, xml: Element) -> HandlingResult: | ||
| """Handle xml message and notify the correct event subscribers. | ||
|
|
||
| :return: A message response | ||
| """ | ||
| if ( | ||
| xml.attrib.get("ret") != "ok" | ||
| or (resp_logs := xml.findall("CleanSt")) is None | ||
| ): | ||
| return HandlingResult.analyse() | ||
|
|
||
| if len(resp_logs) >= 0: | ||
| logs: list[CleanLogEntry] = [] | ||
| for log in resp_logs: | ||
| xml_stop_reason_attrib = str(log.attrib["f"]) | ||
| stop_reason = XmlStopReason.FINISHED | ||
| try: | ||
| stop_reason = get_enum(XmlStopReason, xml_stop_reason_attrib) | ||
| except Exception as e: | ||
| _LOGGER.error( | ||
| "Could not decode stop reason: %s", | ||
| xml_stop_reason_attrib, | ||
| exc_info=e, | ||
| ) | ||
| try: | ||
| logs.append( | ||
| CleanLogEntry( | ||
| timestamp=int(log.attrib["s"]), | ||
| image_url="", # Missing | ||
| type=log.attrib["t"], | ||
| area=int(log.attrib["a"]), | ||
| stop_reason=stop_reason.to_clean_job_status(), # To be extracted | ||
| duration=int(log.attrib["l"]), | ||
| ) | ||
| ) | ||
| except Exception: # pylint: disable=broad-except | ||
| _LOGGER.warning("Skipping log entry: %s", log, exc_info=True) | ||
| event_bus.notify(CleanLogEvent(logs)) | ||
| return CommandResult.success() | ||
| return HandlingResult.analyse() |
Oops, something went wrong.
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.
Why are you changing this line?