Skip to content
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

Roborock Add vacuum_clean_rooms service #134148

Open
wants to merge 4 commits into
base: dev
Choose a base branch
from

Conversation

RaHehl
Copy link
Contributor

@RaHehl RaHehl commented Dec 28, 2024

Breaking change

Proposed change

adds an action/service to clean rooms

Type of change

  • Dependency upgrade
  • Bugfix (non-breaking change which fixes an issue)
  • New integration (thank you!)
  • New feature (which adds functionality to an existing integration)
  • Deprecation (breaking change to happen in the future)
  • Breaking change (fix/feature causing existing functionality to break)
  • Code quality improvements to existing code or addition of tests

Additional information

  • This PR fixes or closes issue: fixes #
  • This PR is related to issue:
  • Link to documentation pull request:

Checklist

  • The code change is tested and works locally.
  • Local tests pass. Your PR cannot be merged unless tests pass
  • There is no commented out code in this PR.
  • I have followed the development checklist
  • I have followed the perfect PR recommendations
  • The code has been formatted using Ruff (ruff format homeassistant tests)
  • Tests have been added to verify that the new code works.

If user exposed functionality or configuration variables are added/changed:

If the code communicates with devices, web services, or third-party tools:

  • The manifest file has all fields filled out correctly.
    Updated and included derived files by running: python3 -m script.hassfest.
  • New or updated dependencies have been added to requirements_all.txt.
    Updated by running python3 -m script.gen_requirements_all.
  • For the updated dependencies - a link to the changelog, or at minimum a diff between library versions is added to the PR description.

To help with the load of incoming pull requests:

@home-assistant
Copy link

Hey there @Lash-L, mind taking a look at this pull request as it has been labeled with an integration (roborock) you are listed as a code owner for? Thanks!

Code owner commands

Code owners of roborock can trigger bot actions by commenting:

  • @home-assistant close Closes the pull request.
  • @home-assistant rename Awesome new title Renames the pull request.
  • @home-assistant reopen Reopen the pull request.
  • @home-assistant unassign roborock Removes the current integration label and assignees on the pull request, add the integration domain after the command.
  • @home-assistant add-label needs-more-information Add a label (needs-more-information, problem in dependency, problem in custom component) to the pull request.
  • @home-assistant remove-label needs-more-information Remove a label (needs-more-information, problem in dependency, problem in custom component) on the pull request.

@RaHehl
Copy link
Contributor Author

RaHehl commented Dec 28, 2024

doc pr follows soon

@RaHehl RaHehl mentioned this pull request Dec 28, 2024
19 tasks
Comment on lines 29 to 46
vacuum_clean_rooms:
target:
entity:
integration: roborock
domain: vacuum
fields:
room_ids:
example: 1,3,4
required: true
selector:
text:
repeat:
example: 1
required: false
selector:
number:
min: 1
max: 3
Copy link
Contributor

Choose a reason for hiding this comment

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

@allenporter There isn't a way that this could be dynamic is there? We have individual room names and that would be a lot better for the user, but if I'm not mistaken it isn't really possible to do dynamic fields in Actions.

Copy link
Contributor Author

@RaHehl RaHehl Dec 28, 2024

Choose a reason for hiding this comment

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

I've already asked myself the question, due to the usability, the potential usability in Homekit/Matter (I think vaccums are supported from upcomming iOS 18.3) and the usability in HA Voice Assistant (which I haven't looked into yet) In a perfect world, this would also correspond to the rooms in HomeAssistant

Copy link
Contributor

Choose a reason for hiding this comment

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

I believe I tried this in the past and I came up short and decided I would wait for Multiselect entities but they are indefinitely on hold now.

Comment on lines +104 to +106
vol.Required("room_ids"): vol.Any(
vol.Coerce(int), [vol.Coerce(int)], vol.Coerce(str)
),
Copy link
Member

Choose a reason for hiding this comment

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

I am a bit unsure if it works but could we maybe use the SelectSelector here and construct it with the proper values and room names?

homeassistant/components/roborock/strings.json Outdated Show resolved Hide resolved
homeassistant/components/roborock/const.py Outdated Show resolved Hide resolved
Copy link
Contributor

@allenporter allenporter left a comment

Choose a reason for hiding this comment

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

Similar to the discussion about coordinates, how are users expected to know how to use rooms? These room number ids won't really be usable right?

This feels like we're bypassing some of the discussion in home-assistant/architecture#913 and home-assistant/architecture#950 missing an opportunity to figure out a user friendly way to surface rooms.

@gjohansson-ST
Copy link
Member

Similar to the discussion about coordinates, how are users expected to know how to use rooms? These room number ids won't really be usable right?

That's why the proposal above to use a SelectSelector above so the users get's a list of friendly room names instead of entering some random int which supposedly is for a specific room.

@RaHehl
Copy link
Contributor Author

RaHehl commented Dec 29, 2024

Similar to the discussion about coordinates, how are users expected to know how to use rooms? These room number ids won't really be usable right?

That's why the proposal above to use a SelectSelector above so the users get's a list of friendly room names instead of entering some random int which supposedly is for a specific room.

Even though the IDs are essentially random, I still think the way to obtain them is reasonably clean.

"description": "Ids of the Rooms to clean, separated by comma. (retrieve the ids with the service get_maps)"

The numbers shouldn’t change very often anyway.

I haven’t found anything in the core code about using SelectSelector in actions. Overall, I agree with the usability argument and think this approach makes sense. Correct me if I’m wrong, but doesn’t this action appear under a section labeled “Developer Tools”? If so, it seems perfectly fine to fetch an ID via one service and then use it in another.

However, if this is meant for a scenario where an everyday user would run the service, it should be more encapsulated—so they can simply say “clean room XY,” and that could be handled behind the scenes, perhaps via a button on a dashboard.

@gjohansson-ST
Copy link
Member

I was thinking a bit more and the schema can not really be dynamic and the selections are robot specific so it would not work with my proposal.
But we could perhaps at least extend the options a bit so instead of providing int's, it could be friendly names. So instead of typing 20 I could type Kitchen and the service would "translate" it for me.

@RaHehl
Copy link
Contributor Author

RaHehl commented Dec 29, 2024

I was thinking along those lines as well. My idea was to check if the value is a string (after splitting by the comma) and then do a translation from the room name to an integer. However, the plan was to wait until the maps are really cached, and then add this feature. That wouldn't be a breaking change either.

@gjohansson-ST
Copy link
Member

I don't see the logic about that. We might as well just make a call to get the maps and then use that information. Any caching for the map can come later (as I don't think these will be used extensively and therefore not burden the system really).

It should also not be a text field (with comma separation) but a multi text or a select with custom input.

@Lash-L
Copy link
Contributor

Lash-L commented Dec 29, 2024

But we could perhaps at least extend the options a bit so instead of providing int's, it could be friendly names. So instead of typing 20 I could type Kitchen and the service would "translate" it for me.

Both will need to be available so I think extend is the key word. As unnamed rooms can still be cleaned via an id.

I don't see the logic about that. We might as well just make a call to get the maps and then use that information. Any caching for the map can come later (as I don't think these will be used extensively and therefore not burden the system really).

The coordinator should hold all this info in self.maps or self.maps info I believe. I have all of the map ids and the corresponding rooms. Should be trivial to get a room name from an id with that, I believe I even do it in the image component. I'm not able to check right now as I'm on mobile, but I believe logic exists

@RaHehl
Copy link
Contributor Author

RaHehl commented Dec 30, 2024

But we could perhaps at least extend the options a bit so instead of providing int's, it could be friendly names. So instead of typing 20 I could type Kitchen and the service would "translate" it for me.

Both will need to be available so I think extend is the key word. As unnamed rooms can still be cleaned via an id.

I don't see the logic about that. We might as well just make a call to get the maps and then use that information. Any caching for the map can come later (as I don't think these will be used extensively and therefore not burden the system really).

The coordinator should hold all this info in self.maps or self.maps info I believe. I have all of the map ids and the corresponding rooms. Should be trivial to get a room name from an id with that, I believe I even do it in the image component. I'm not able to check right now as I'm on mobile, but I believe logic exists

with latest commit it accepts ids names and mixes of both

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants