DeebotUniverse / client.py

Deebot client library in python
https://deebot.readthedocs.io
GNU General Public License v3.0
27 stars 41 forks source link

Add 4 more Lifespan entities #494

Closed Ulfmerbold2000 closed 3 months ago

Ulfmerbold2000 commented 3 months ago

Added following Lifespan entities: Dustbag Strainer handFilter autoWater_cleaningFluid

Found them in my logs, should be helpful to add them

Summary by CodeRabbit

codecov[bot] commented 3 months ago

Codecov Report

All modified and coverable lines are covered by tests :white_check_mark:

Project coverage is 85.60%. Comparing base (6cfc009) to head (3b08367).

Additional details and impacted files ```diff @@ Coverage Diff @@ ## dev #494 +/- ## ========================================== + Coverage 85.59% 85.60% +0.01% ========================================== Files 86 86 Lines 3234 3238 +4 Branches 528 528 ========================================== + Hits 2768 2772 +4 Misses 414 414 Partials 52 52 ```

:umbrella: View full report in Codecov by Sentry.
:loudspeaker: Have feedback on the report? Share it here.

edenhaus commented 3 months ago

Do you want to add it directly to the config file of your vacuum model?

Ulfmerbold2000 commented 3 months ago

i've been thinking about the directly adding to the capabilities of my bot, but as there is another needed change in the ecovacs integration before i think the long way is better

Without the change in ecovacs there wont be the sensors upcoming

I did this for the dustbag in my HA for testing purposes and it works as intended The other three sensors are there but seems statically in my bot, maybe they will be useful for the other types of bots

edenhaus commented 3 months ago

We should only add lifespan, which are used by at least one model. So please add using it on your model

Ulfmerbold2000 commented 3 months ago

The Lifespans are announced by my system!

2024-05-12 11:21:35.885 WARNING (MainThread) [deebot_client.message] Could not parse getLifeSpan: {'data': [{'left': 86400, 'total': 86400, 'type': 'autoWater_cleaningFluid'}, {'left': 17461, 'total': 18000, 'type': 'brush'}, {'left': 2039, 'total': 3000, 'type': 'dustBag'}, {'left': 30000, 'total': 30000, 'type': 'handFilter'}, {'left': 6239, 'total': 7200, 'type': 'heap'}, {'left': 8943, 'total': 9000, 'type': 'roundMop'}, {'left': 7648, 'total': 9000, 'type': 'sideBrush'}, {'left': 1800, 'total': 1800, 'type': 'strainer'}, {'left': 1616, 'total': 1800, 'type': 'unitCare'}]}
2024-05-12 11:21:35.886 WARNING (MainThread) [deebot_client.message] Could not parse getLifeSpan: {'header': {'pri': 1, 'tzm': 120, 'ts': '1715505695193', 'ver': '0.0.1', 'fwVer': '1.76.0', 'hwVer': '0.1.1', 'wkVer': '0.1.54'}, 'body': {'data': [{'left': 86400, 'total': 86400, 'type': 'autoWater_cleaningFluid'}, {'left': 17461, 'total': 18000, 'type': 'brush'}, {'left': 2039, 'total': 3000, 'type': 'dustBag'}, {'left': 30000, 'total': 30000, 'type': 'handFilter'}, {'left': 6239, 'total': 7200, 'type': 'heap'}, {'left': 8943, 'total': 9000, 'type': 'roundMop'}, {'left': 7648, 'total': 9000, 'type': 'sideBrush'}, {'left': 1800, 'total': 1800, 'type': 'strainer'}, {'left': 1616, 'total': 1800, 'type': 'unitCare'}]}}

All four are announced, but only the Dustbag counts down...this was my reason for saying "not used". My point is to minimize errors in logs first, before gaining any further goals. Being able to reset Dustbag after replacing it in station is nice, but having an cleaner log with less errors gives me more gain from my point of view.

Less errors means more handling as it should be and less options to run into mem leaks and other funny things

coderabbitai[bot] commented 3 months ago

Walkthrough

The recent update enhances the LifeSpan enum class in deebot_client/events/__init__.py with new constants like DUST_BAG, CLEANING_FLUID, STRAINER, and HAND_FILTER, improving component lifespan tracking for the Deebot device. Test cases in tests/commands/json/test_life_span.py are updated to incorporate these new enum values for comprehensive testing.

Changes

File Path Change Summary
deebot_client/events/__init__.py Added new LifeSpan enum constants
tests/commands/json/test_life_span.py Updated test cases with new enum values

In the world of code, new constants bloom,
For dust bags and filters, there's now more room.
Cleaning fluid and strainers join the fray,
Ensuring our Deebot works day by day.
With each new enum, our maintenance grows,
Keeping our floors clean, as everyone knows. 🌟🐰


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?

Share - [X](https://twitter.com/intent/tweet?text=I%20just%20used%20%40coderabbitai%20for%20my%20code%20review%2C%20and%20it%27s%20fantastic%21%20It%27s%20free%20for%20OSS%20and%20offers%20a%20free%20trial%20for%20the%20proprietary%20code.%20Check%20it%20out%3A&url=https%3A//coderabbit.ai) - [Mastodon](https://mastodon.social/share?text=I%20just%20used%20%40coderabbitai%20for%20my%20code%20review%2C%20and%20it%27s%20fantastic%21%20It%27s%20free%20for%20OSS%20and%20offers%20a%20free%20trial%20for%20the%20proprietary%20code.%20Check%20it%20out%3A%20https%3A%2F%2Fcoderabbit.ai) - [Reddit](https://www.reddit.com/submit?title=Great%20tool%20for%20code%20review%20-%20CodeRabbit&text=I%20just%20used%20CodeRabbit%20for%20my%20code%20review%2C%20and%20it%27s%20fantastic%21%20It%27s%20free%20for%20OSS%20and%20offers%20a%20free%20trial%20for%20proprietary%20code.%20Check%20it%20out%3A%20https%3A//coderabbit.ai) - [LinkedIn](https://www.linkedin.com/sharing/share-offsite/?url=https%3A%2F%2Fcoderabbit.ai&mini=true&title=Great%20tool%20for%20code%20review%20-%20CodeRabbit&summary=I%20just%20used%20CodeRabbit%20for%20my%20code%20review%2C%20and%20it%27s%20fantastic%21%20It%27s%20free%20for%20OSS%20and%20offers%20a%20free%20trial%20for%20proprietary%20code)
Tips ### Chat There are 3 ways to chat with [CodeRabbit](https://coderabbit.ai): - Review comments: Directly reply to a review comment made by CodeRabbit. Example: - `I pushed a fix in commit .` - `Generate unit testing code for this file.` - `Open a follow-up GitHub issue for this discussion.` - Files and specific lines of code (under the "Files changed" tab): Tag `@coderabbitai` in a new review comment at the desired location with your query. Examples: - `@coderabbitai generate unit testing code for this file.` - `@coderabbitai modularize this function.` - PR comments: Tag `@coderabbitai` in a new PR comment to ask questions about the PR branch. For the best results, please provide a very specific query, as very limited context is provided in this mode. Examples: - `@coderabbitai generate interesting stats about this repository and render them as a table.` - `@coderabbitai show all the console.log statements in this repository.` - `@coderabbitai read src/utils.ts and generate unit testing code.` - `@coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.` 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 as PR comments) - `@coderabbitai pause` to pause the reviews on a PR. - `@coderabbitai resume` to resume the paused reviews. - `@coderabbitai review` to trigger a review. This is useful when automatic reviews are disabled for the repository. - `@coderabbitai resolve` resolve all the CodeRabbit review comments. - `@coderabbitai help` to get help. Additionally, you can add `@coderabbitai ignore` anywhere in the PR description to prevent this PR from being reviewed. ### CodeRabbit Configration File (`.coderabbit.yaml`) - You can programmatically configure CodeRabbit by adding a `.coderabbit.yaml` file to the root of your repository. - Please see the [configuration documentation](https://docs.coderabbit.ai/guides/configure-coderabbit) for more information. - If your editor has YAML language server enabled, you can add the path at the top of this file to enable auto-completion and validation: `# yaml-language-server: $schema=https://coderabbit.ai/integrations/schema.v2.json` ### Documentation and Community - Visit our [Documentation](https://coderabbit.ai/docs) for detailed information on how to use CodeRabbit. - Join our [Discord Community](https://discord.com/invite/GsXnASn26c) to get help, request features, and share feedback. - Follow us on [X/Twitter](https://twitter.com/coderabbitai) for updates and announcements.
edenhaus commented 3 months ago

The Lifespans are announced by my system!

2024-05-12 11:21:35.885 WARNING (MainThread) [deebot_client.message] Could not parse getLifeSpan: {'data': [{'left': 86400, 'total': 86400, 'type': 'autoWater_cleaningFluid'}, {'left': 17461, 'total': 18000, 'type': 'brush'}, {'left': 2039, 'total': 3000, 'type': 'dustBag'}, {'left': 30000, 'total': 30000, 'type': 'handFilter'}, {'left': 6239, 'total': 7200, 'type': 'heap'}, {'left': 8943, 'total': 9000, 'type': 'roundMop'}, {'left': 7648, 'total': 9000, 'type': 'sideBrush'}, {'left': 1800, 'total': 1800, 'type': 'strainer'}, {'left': 1616, 'total': 1800, 'type': 'unitCare'}]}
2024-05-12 11:21:35.886 WARNING (MainThread) [deebot_client.message] Could not parse getLifeSpan: {'header': {'pri': 1, 'tzm': 120, 'ts': '1715505695193', 'ver': '0.0.1', 'fwVer': '1.76.0', 'hwVer': '0.1.1', 'wkVer': '0.1.54'}, 'body': {'data': [{'left': 86400, 'total': 86400, 'type': 'autoWater_cleaningFluid'}, {'left': 17461, 'total': 18000, 'type': 'brush'}, {'left': 2039, 'total': 3000, 'type': 'dustBag'}, {'left': 30000, 'total': 30000, 'type': 'handFilter'}, {'left': 6239, 'total': 7200, 'type': 'heap'}, {'left': 8943, 'total': 9000, 'type': 'roundMop'}, {'left': 7648, 'total': 9000, 'type': 'sideBrush'}, {'left': 1800, 'total': 1800, 'type': 'strainer'}, {'left': 1616, 'total': 1800, 'type': 'unitCare'}]}}

All four are announced, but only the Dustbag counts down...this was my reason for saying "not used". My point is to minimize errors in logs first, before gaining any further goals. Being able to reset Dustbag after replacing it in station is nice, but having an cleaner log with less errors gives me more gain from my point of view.

Less errors means more handling as it should be and less options to run into mem leaks and other funny things

Can you please add a test for the new added lifespan attributes. You already have two example responses, which can be used in the test. So these values are tested

Ulfmerbold2000 commented 3 months ago

I'm not sure why the run tests and the pre-commit failed, but the test_life_span.py is now expanded and should work as intended.

edenhaus commented 3 months ago

pre-commit.ci autofix

Ulfmerbold2000 commented 3 months ago

Robert i've overlooked your editings. For my personal learnings: Is there an reason to formating the entries this way? Just readability or an interpreter problem you work around?