Skip to content

Implement XML Position messages#916

Merged
edenhaus merged 6 commits into
DeebotUniverse:devfrom
nanomad:feature/xml-messages-pos
Apr 25, 2025
Merged

Implement XML Position messages#916
edenhaus merged 6 commits into
DeebotUniverse:devfrom
nanomad:feature/xml-messages-pos

Conversation

@nanomad

@nanomad nanomad commented Apr 22, 2025

Copy link
Copy Markdown
Contributor

No description provided.

@nanomad nanomad changed the title Add XML Position messages Implement XML Position messages Apr 22, 2025
@nanomad nanomad marked this pull request as ready for review April 22, 2025 14:27
@codecov

codecov Bot commented Apr 22, 2025

Copy link
Copy Markdown

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 92.50%. Comparing base (6ae62c4) to head (a8efe15).
Report is 3 commits behind head on dev.

✅ All tests successful. No failed tests found.

Additional details and impacted files
@@            Coverage Diff             @@
##              dev     #916      +/-   ##
==========================================
+ Coverage   92.46%   92.50%   +0.03%     
==========================================
  Files         121      122       +1     
  Lines        4644     4668      +24     
  Branches      292      294       +2     
==========================================
+ Hits         4294     4318      +24     
  Misses        288      288              
  Partials       62       62              

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@codspeed-hq

codspeed-hq Bot commented Apr 22, 2025

Copy link
Copy Markdown

CodSpeed Performance Report

Merging #916 will not alter performance

Comparing nanomad:feature/xml-messages-pos (a8efe15) with dev (6ae62c4)

Summary

✅ 6 untouched benchmarks

@pytest.mark.parametrize("position", [(-9, 15, 89)])
def test_Pos(position: tuple[int, int, int]) -> None:
x, y, a = position
xml_message = f'<ctl td="Pos" t="p" p="{x},{y}" a="{a}" valid="1" />'

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Some questions about the message:

  • is t the type and will it be different for the charger position?
  • There is a valid attribute... I would assume that the position is only valid if it is equal to 1. Can you please verify it

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fair point

  • I have no way of checking if valid = 0 ever happens, but I guess one more check doesn't hurt.
  • The app does show the charger position, I just didn't figure out what param it uses. I'll check that tomorrow

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There's a GetChargerPos command, but I didn't find any "Pos" events for it.
Suggestion:

  • Imlpement GetChargerPos
  • Only handle valid="1" t="p" messages as bot position, we'll leave everything else as HandlingResult.analyse() so that they can be eventually debugged further

Comment thread deebot_client/messages/xml/pos.py Outdated
p_x, p_y = p.split(",", 2)
p_a = xml.attrib.get("a", 0)
position = Position(
type=PositionType.DEEBOT, x=int(p_x), y=int(p_y), a=int(p_a)

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is the app not showing where the charger is?

@flubshi flubshi Apr 23, 2025

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

For Deebot 900 it shows the charger position in app.

But it looks like the position is explicitly requested:

Got message: topic=iot/p2p/GetChargerPos/HelperMQClientId-awseu-sts-ngiot-mqsjmq-43/ecosys/<id>/<uuid>/ls1ok3/<..>/q/<...>/x, payload=b'<ctl/>'
[...]
Got message: topic=iot/p2p/GetChargerPos/<uuid>/ls1ok3/<id>/HelperMQClientId-awseu-sts-ngiot-mqsjmq-43/ecosys/<..>/p/<...>/x, payload=b"<ctl ret='ok' p='-200,816' a='-90'/>"

Edit: ahh, noticed that @nanomad already replied in the other comment

@edenhaus edenhaus added the pr: new-feature PR, which adds a new feature label Apr 22, 2025
@nanomad nanomad force-pushed the feature/xml-messages-pos branch 2 times, most recently from 8dc8739 to a64ff99 Compare April 24, 2025 09:04
Comment thread deebot_client/commands/xml/pos.py Outdated
"""Support class for producing Pos events."""

@classmethod
def _parse_xml(

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Move this function to the Pos message. No need for an additional class

Comment thread deebot_client/commands/xml/pos.py Outdated
return HandlingResult.analyse()


class GetPos(XmlCommandWithMessageHandling, PosParser):

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
class GetPos(XmlCommandWithMessageHandling, PosParser):
class GetPos(XmlCommandWithMessageHandling, Pos):

Comment thread deebot_client/commands/xml/pos.py Outdated

return HandlingResult.analyse()

class GetChargerPos(XmlCommandWithMessageHandling, PosParser):

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
class GetChargerPos(XmlCommandWithMessageHandling, PosParser):
class GetChargerPos(XmlCommandWithMessageHandling, Pos):

Comment thread deebot_client/commands/xml/pos.py Outdated
cls, position_type: PositionType, event_bus: EventBus, xml: Element
) -> HandlingResult:
"""Handle xml message and notify the correct event subscribers."""
if (p := xml.attrib.get("p")) and (xml.attrib.get("valid", "1")) == "1":

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
if (p := xml.attrib.get("p")) and (xml.attrib.get("valid", "1")) == "1":
if (p := xml.attrib.get("p")) and xml.attrib.get("valid") == "1":

We currently have tests, where always valid is present. Therefore we should analyse the message, when its missing instead assuming it's valid

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

valid=1 is missing from GetChargerPos though, I can either move the check to GetPos and Pos and remove it from the parser or assume it's "1" if the attribute is missing

@nanomad nanomad force-pushed the feature/xml-messages-pos branch from aa14cca to a8efe15 Compare April 24, 2025 18:32
@edenhaus edenhaus merged commit 17e3186 into DeebotUniverse:dev Apr 25, 2025
25 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

pr: new-feature PR, which adds a new feature

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants