-
-
Notifications
You must be signed in to change notification settings - Fork 150
Add DEEBOT Neo (z0gd1j) #667
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
Conversation
WalkthroughThe changes in this pull request introduce a new file, Changes
Possibly related PRs
Suggested labels
Suggested reviewers
Thank you for using CodeRabbit. We offer it for free to the OSS community and would appreciate your support in helping us grow. If you find it useful, would you consider giving us a shout-out on your favorite social media? 🪧 TipsChatThere are 3 ways to chat with CodeRabbit:
Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments. CodeRabbit Commands (Invoked using PR comments)
Other keywords and placeholders
CodeRabbit Configuration File (
|
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.
Actionable comments posted: 1
🧹 Outside diff range and nitpick comments (2)
tests/hardware/test_init.py (2)
Line range hint
103-153: Include'z0gd1j'in capability event extraction testsThe device
'z0gd1j'is added to theDEVICESdictionary but is not included in the parameterized tests intest_capabilities_event_extraction. To ensure that'z0gd1j'capabilities are correctly validated, add it to the list of device classes being tested.Apply this diff to include
'z0gd1j'in the tests:@pytest.mark.parametrize( ("class_", "expected"), [ # Existing device tests... ( "p95mgv", { # Existing expected events and commands }, ), + ( + "z0gd1j", + { + # Expected events and commands for 'z0gd1j' + # Add the appropriate expected events and commands here + }, + ), ], - ids=["5xu9h3", "itk04l", "yna5xi", "p95mgv"], + ids=["5xu9h3", "itk04l", "yna5xi", "p95mgv", "z0gd1j"], ) async def test_capabilities_event_extraction( class_: str, expected: dict[type[Event], list[Command]] ) -> None: info = await get_static_device_info(class_) assert info is not None capabilities = info.capabilities assert capabilities._events.keys() == expected.keys() for event, expected_commands in expected.items(): assert ( capabilities.get_refresh_commands(event) == expected_commands ), f"Refresh commands don't match for {event}"
303-303: Ensure device list is sorted if requiredThe device list now includes
"z0gd1j"at the end. If the order of devices matters (e.g., for readability or consistency), consider sorting the list alphabetically.Apply this diff to sort the device list:
assert list(DEVICES) == [ # Existing devices... "x5d34r", "yna5xi", + "z0gd1j", "z4lvk7", "zjavof", "zwkcqc", - "z0gd1j", ]
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
📒 Files selected for processing (2)
deebot_client/hardware/deebot/z0gd1j.py(1 hunks)tests/hardware/test_init.py(1 hunks)
🔇 Additional comments (2)
deebot_client/hardware/deebot/z0gd1j.py (2)
1-1: Verify that short_name(__name__) returns the correct device identifier
In DEVICES[short_name(__name__)] = StaticDeviceInfo(...), ensure that short_name(__name__) correctly returns 'z0gd1j' as intended. Since __name__ includes the module path, short_name must extract the correct device identifier to properly register the device.
Run the following script to confirm the value returned by short_name(__name__):
✅ Verification successful
short_name function implementation is correct and consistently used
The short_name function in deebot_client/util/__init__.py is correctly implemented to extract the last part of a dotted path:
def short_name(value: str) -> str:
"""Return value after last dot."""
return value.rsplit(".", maxsplit=1)[-1]This implementation will correctly return 'z0gd1j' from 'deebot_client.hardware.deebot.z0gd1j'. The pattern is consistently used across multiple device modules (e.g., '5xu9h3', 'umwv6z', 'yna5xi', etc.) for registering device capabilities in the DEVICES dictionary.
🏁 Scripts executed
The following scripts were executed for the analysis:
Script:
#!/bin/bash
# Description: Verify that short_name(__name__) returns 'z0gd1j'
# Test: Extract the device identifier using short_name and print it
python -c "from deebot_client.util import short_name; print(short_name('deebot_client.hardware.deebot.z0gd1j'))"
Length of output: 217
Script:
#!/bin/bash
# Let's first locate the short_name function definition
ast-grep --pattern 'def short_name($_) { $$$ }'
# Also search for any usage of short_name function
rg "short_name" -A 2
# Find the device registration code
rg "DEVICES\[.*\].*=.*StaticDeviceInfo" -A 2
Length of output: 8847
Line range hint 75-83: Confirm the validity of WaterAmount.ULTRAHIGH
In the water capability, the types include WaterAmount.ULTRAHIGH. Verify that ULTRAHIGH is a valid member of the WaterAmount enum. If it doesn't exist, this will cause an AttributeError at runtime.
Run the following script to list all members of the WaterAmount enum:
✅ Verification successful
WaterAmount.ULTRAHIGH is a valid enum member
WaterAmount.ULTRAHIGH is correctly defined in the WaterAmount enum with a value of 4, and it's being used consistently across multiple device-specific implementations. The code is safe from potential AttributeError at runtime.
🏁 Scripts executed
The following scripts were executed for the analysis:
Script:
#!/bin/bash
# Description: List the members of the WaterAmount enum to verify 'ULTRAHIGH' exists
# Test: Display the members of the WaterAmount enum
grep -A 5 'class WaterAmount(Enum):' $(fd WaterInfoEvent.py)
Length of output: 62
Script:
#!/bin/bash
# Let's first find where WaterAmount enum is defined
rg -l "class WaterAmount"
# Then search for any references to WaterAmount.ULTRAHIGH
rg "WaterAmount\.ULTRAHIGH"
# Also search for enum definition with different patterns
rg "WaterAmount.*Enum"
Length of output: 1244
Script:
#!/bin/bash
# Let's check the actual enum definition to see its members
rg -A 10 "class WaterAmount\(IntEnum\):" deebot_client/events/water_info.py
Length of output: 253
| @@ -0,0 +1 @@ | |||
| x5d34r.py No newline at end of file | |||
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.
Inconsistency between filename and device identifier
The filename is z0gd1j.py, but line 1 references x5d34r.py. Ensure that the device identifier within the code matches the filename and the intended device (z0gd1j). This inconsistency might lead to confusion or incorrect device configurations.
Codecov ReportAll modified and coverable lines are covered by tests ✅
Additional details and impacted files@@ Coverage Diff @@
## dev #667 +/- ##
=======================================
Coverage 86.01% 86.01%
=======================================
Files 93 93
Lines 3454 3454
Branches 307 307
=======================================
Hits 2971 2971
Misses 429 429
Partials 54 54 ☔ View full report in Codecov by Sentry. |
edenhaus
left a comment
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.
Thanks @josh-sanders 👍
Base on the Deebot OZMO T8 AIVI, class 'x5d34r'
Summary by CodeRabbit
New Features
Bug Fixes
Tests