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

Alexa: Support vacuums without turn_on/turn_off feature #32570

Merged
merged 2 commits into from
Mar 9, 2020

Conversation

Tho85
Copy link
Contributor

@Tho85 Tho85 commented Mar 7, 2020

Proposed change

Fix Alexa integration with vacuums that do not have support for TURN_ON or TURN_OFF.

#23171 introduced a StateVacuumDevice for MQTT vacuums. It is meant to deprecate the existing VacuumDevice at some point in time. As per the documentation, the latter supports TURN_ON and TURN_OFF services, while the former does only support START and RETURN_TO_BASE services.

Up until now, the Alexa integration would only work with (legacy) vacuums. This PR adds support for the newer state vacuums, i.e. it calls the START service when powering on, and the RETURN_TO_BASE service when powering off.

Additionally, this PR fixes the power state reported to Alexa for both types.

Tested successfully with a Roborock S502 running Valetudo 0.4.0 (with MQTT auto-configuration).

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)
  • Breaking change (fix/feature causing existing functionality to break)
  • Code quality improvements to existing code or addition of tests

Additional information

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
  • The code has been formatted using Black (black --fast homeassistant tests)
  • Tests have been added to verify that the new code works.

@homeassistant
Copy link
Contributor

Hi @Tho85,

It seems you haven't yet signed a CLA. Please do so here.

Once you do that we will be able to review and accept this pull request.

Thanks!

@probot-home-assistant
Copy link

Hey there @home-assistant/cloud, @ochlocracy, mind taking a look at this pull request as its been labeled with a integration (alexa) you are listed as a codeowner for? Thanks!

Copy link
Member

@ochlocracy ochlocracy left a comment

Choose a reason for hiding this comment

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

Unfortunately the Alexa Smart Home API doesn't yet have the necessary configuration settings to fully support vacuums like they could be. Doesn't even have a category... But based on recent blog posts, and Alexa app updates I've seen over the past few months I suspect that will be coming in the future.

Everything looks good. We just need a clear decision on how to address the SUPPORT_RETURN_HOME and deciding when it's appropriate to change the service to SERVICE_RETURN_TO_BASE. 👍

homeassistant/components/alexa/handlers.py Outdated Show resolved Hide resolved
@Tho85
Copy link
Contributor Author

Tho85 commented Mar 8, 2020

You're right, somehow I missed SUPPORT_RETURN_HOME completely. I skimmed the vacuum integrations, here's an overview of what features they support and how they behave:

Integration Turn on Turn off Start Stop Return home
Dyson Starts or resumes cleaning Pauses cleaning - Pauses cleaning Returns home
Ecovacs Starts cleaning Returns home - Stops cleaning Returns home
iRobot Roomba Starts cleaning Stops and returns home - Stops cleaning Returns home
MQTT Legacy depends depends - - depends
MQTT State - - depends depends depends
Neato Botvac - - Starts or resumes cleaning Stops cleaning Pauses and returns home
Template - - depends depends depends
Xiaomi Mi - - Starts or resumes cleaning Stops cleaning Returns home

Based on this I'd change the behavior as follows:

  • Alexa "power on": If supported, use TURN_ON, else use START. This way, each integration might overwrite what to do when powering on
  • Alexa "power off": If supported, use TURN OFF, else use RETURN_HOME. It seems like all supported vacuums also have a dock, so I think this is OK.

What do you think?

@Tho85
Copy link
Contributor Author

Tho85 commented Mar 8, 2020

@ochlocracy I changed the code accordingly, please have another look.

Copy link
Member

@ochlocracy ochlocracy left a comment

Choose a reason for hiding this comment

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

Looks good! Thorough tests too. 👍

Looks like the build error is from a test unrelated to this.

@ochlocracy ochlocracy merged commit 22b5690 into home-assistant:dev Mar 9, 2020
@Tho85 Tho85 deleted the alexa-state-vacuum branch March 9, 2020 16:36
@lock lock bot locked and limited conversation to collaborators Mar 10, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants