-
-
Notifications
You must be signed in to change notification settings - Fork 150
Add Support for Deebot N8+ Black Variant #644
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
Create b2jqs4.py to add support for Deebot N8+ Black variant.
WalkthroughThe changes 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 (
|
Codecov ReportAll modified and coverable lines are covered by tests ✅
Additional details and impacted files@@ Coverage Diff @@
## dev #644 +/- ##
==========================================
+ Coverage 86.68% 86.81% +0.12%
==========================================
Files 90 91 +1
Lines 3365 3397 +32
Branches 298 298
==========================================
+ Hits 2917 2949 +32
Misses 394 394
Partials 54 54 ☔ View full report in Codecov by Sentry. |
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 (1)
tests/hardware/test_init.py (1)
268-268: Automate the device list to reduce maintenance overheadThe current test hardcodes the list of device class IDs, which requires manual updates whenever a new device is added. Consider generating the list dynamically from the
DEVICESdictionary to prevent test failures due to missing updates.You can modify the test function as follows:
def test_all_models_loaded() -> None: """Test that all models are loaded.""" _load() - assert list(DEVICES) == [ - "1vxt52", - "2ap5uq", - # ... other device IDs ... - "zjavof", - "zwkcqc", - ] + expected_devices = [ + "1vxt52", + "2ap5uq", + # ... other device IDs ... + "zjavof", + "zwkcqc", + ] + assert set(DEVICES.keys()) == set(expected_devices)Alternatively, if the exact order of devices is not crucial, you can simplify the assertion:
def test_all_models_loaded() -> None: """Test that all models are loaded.""" _load() - assert list(DEVICES) == [ - # ... device IDs ... - ] + assert len(DEVICES) == expected_number_of_devices
| DEVICES[short_name(__name__)] = StaticDeviceInfo( | ||
| DataType.JSON, | ||
| Capabilities( | ||
| device_type=DeviceType.VACUUM, | ||
| availability=CapabilityEvent( | ||
| AvailabilityEvent, [GetBattery(is_available_check=True)] | ||
| ), | ||
| battery=CapabilityEvent(BatteryEvent, [GetBattery()]), | ||
| charge=CapabilityExecute(Charge), | ||
| clean=CapabilityClean( | ||
| action=CapabilityCleanAction(command=Clean, area=CleanArea), | ||
| continuous=CapabilitySetEnable( | ||
| ContinuousCleaningEvent, | ||
| [GetContinuousCleaning()], | ||
| SetContinuousCleaning, | ||
| ), | ||
| count=CapabilitySet(CleanCountEvent, [GetCleanCount()], SetCleanCount), | ||
| log=CapabilityEvent(CleanLogEvent, [GetCleanLogs()]), | ||
| preference=CapabilitySetEnable( | ||
| CleanPreferenceEvent, [GetCleanPreference()], SetCleanPreference | ||
| ), | ||
| ), | ||
| custom=CapabilityCustomCommand( | ||
| event=CustomCommandEvent, get=[], set=CustomCommand | ||
| ), | ||
| error=CapabilityEvent(ErrorEvent, [GetError()]), | ||
| fan_speed=CapabilitySetTypes( | ||
| event=FanSpeedEvent, | ||
| get=[GetFanSpeed()], | ||
| set=SetFanSpeed, | ||
| types=( | ||
| FanSpeedLevel.QUIET, | ||
| FanSpeedLevel.NORMAL, | ||
| FanSpeedLevel.MAX, | ||
| FanSpeedLevel.MAX_PLUS, | ||
| ), | ||
| ), | ||
| life_span=CapabilityLifeSpan( | ||
| types=( | ||
| LifeSpan.BRUSH, | ||
| LifeSpan.FILTER, | ||
| LifeSpan.SIDE_BRUSH, | ||
| LifeSpan.UNIT_CARE, | ||
| ), | ||
| event=LifeSpanEvent, | ||
| get=[ | ||
| GetLifeSpan( | ||
| [ | ||
| LifeSpan.BRUSH, | ||
| LifeSpan.FILTER, | ||
| LifeSpan.SIDE_BRUSH, | ||
| LifeSpan.UNIT_CARE, | ||
| ] | ||
| ) | ||
| ], | ||
| reset=ResetLifeSpan, | ||
| ), | ||
| map=CapabilityMap( | ||
| cached_info=CapabilityEvent(CachedMapInfoEvent, [GetCachedMapInfo()]), | ||
| changed=CapabilityEvent(MapChangedEvent, []), | ||
| major=CapabilityEvent(MajorMapEvent, [GetMajorMap()]), | ||
| multi_state=CapabilitySetEnable( | ||
| MultimapStateEvent, [GetMultimapState()], SetMultimapState | ||
| ), | ||
| position=CapabilityEvent(PositionsEvent, [GetPos()]), | ||
| relocation=CapabilityExecute(SetRelocationState), | ||
| rooms=CapabilityEvent(RoomsEvent, [GetCachedMapInfo()]), | ||
| trace=CapabilityEvent(MapTraceEvent, [GetMapTrace()]), | ||
| ), | ||
| network=CapabilityEvent(NetworkInfoEvent, [GetNetInfo()]), | ||
| play_sound=CapabilityExecute(PlaySound), | ||
| settings=CapabilitySettings( | ||
| advanced_mode=CapabilitySetEnable( | ||
| AdvancedModeEvent, [GetAdvancedMode()], SetAdvancedMode | ||
| ), | ||
| carpet_auto_fan_boost=CapabilitySetEnable( | ||
| CarpetAutoFanBoostEvent, | ||
| [GetCarpetAutoFanBoost()], | ||
| SetCarpetAutoFanBoost, | ||
| ), | ||
| true_detect=CapabilitySetEnable( | ||
| TrueDetectEvent, [GetTrueDetect()], SetTrueDetect | ||
| ), | ||
| volume=CapabilitySet(VolumeEvent, [GetVolume()], SetVolume), | ||
| ), | ||
| state=CapabilityEvent(StateEvent, [GetChargeState(), GetCleanInfo()]), | ||
| stats=CapabilityStats( | ||
| clean=CapabilityEvent(StatsEvent, [GetStats()]), | ||
| report=CapabilityEvent(ReportStatsEvent, []), | ||
| total=CapabilityEvent(TotalStatsEvent, [GetTotalStats()]), | ||
| ), | ||
| water=CapabilitySetTypes( | ||
| event=WaterInfoEvent, | ||
| get=[GetWaterInfo()], | ||
| set=SetWaterInfo, | ||
| types=( | ||
| WaterAmount.LOW, | ||
| WaterAmount.MEDIUM, | ||
| WaterAmount.HIGH, | ||
| WaterAmount.ULTRAHIGH, | ||
| ), | ||
| ), | ||
| ), | ||
| ) |
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.
🛠️ Refactor suggestion
Consider reusing existing capabilities to avoid code duplication
Since the DEEBOT N8+ Black variant ("b2jqs4") is functionally identical to the white variant, you can register the new class ID to point to the existing StaticDeviceInfo instance of the white variant. This approach reduces code duplication and simplifies future maintenance.
You can modify the device registration in the existing file for the white variant (e.g., b2jqs3.py) to include the new class ID:
# In b2jqs3.py
DEVICES[short_name(__name__)] = StaticDeviceInfo(
# existing capabilities...
)
+DEVICES["b2jqs4"] = DEVICES[short_name(__name__)]Alternatively, if the devices are identical except for the class ID, you can create a shared module for common capabilities and import it in both files.
Committable suggestion skipped: line range outside the PR's diff.
|
Looks like the code checks failed because something wasn't imported when it ran. |
|
Hi, |
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 @brendanm720 👍
Good Evening!
Apparently the white and black vaccums each have a different class ID. I only have the White one at my disposal, and someone commented on my original pull request that theirs wasn't working with the log.
Please merge this file to add support for the Deebot N8+ Black Variant. It is the same as the other one I submitted as they are identical vacuums other than the color of the plastic.
Thank you.
Summary by CodeRabbit
New Features
Tests