-
-
Notifications
You must be signed in to change notification settings - Fork 31.9k
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
Add support to Dyson 360 Eye robot vacuum using new vacuum platform #8852
Conversation
fcfe3b1
to
49615ff
Compare
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.
I assume there's no I/O going on in the entity properties? Three comments. I didn't look at the tests.
class Dyson360EyeDevice(VacuumDevice): | ||
"""Dyson 360 Eye robot vacuum device.""" | ||
|
||
def __init__(self, hass, device): |
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.
Don't pass in hass
. It will be set on the entity when it has been added to home assistant.
Dyson360EyeMode.FULL_CLEAN_FINISHED: "Finished", | ||
Dyson360EyeMode.FULL_CLEAN_NEEDS_CHARGE: "Need charging" | ||
} | ||
if self._device.state.state in dyson_labels: |
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.
return dyson_labels.get(self._device.state.state, self._device.state.state)
_LOGGER.warning("Unable to connect to device %s", | ||
dyson_device) | ||
try: | ||
connected = dyson_device.connect(device["device_ip"]) |
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.
What's the difference between this part of the connection logic and the one at line 92-97? Would it be possible to make a connect function that is called wherever it is needed?
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.
The first block is for manual connection (specifying device id/ip). The second one try to use mDNS protocol to discover fan/purifier devices (not working with robot vacuum yet). https://home-assistant.io/components/dyson/
It was the same method before but it was quite painful to use so I updated the underlying library and create 2 different methods.
Thanks for your review. |
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.
Fix the two import comments and I think this is good to go. 👍
from homeassistant.components.vacuum import dyson | ||
from homeassistant.components.vacuum.dyson import Dyson360EyeDevice | ||
from tests.common import get_test_home_assistant | ||
from libpurecoollink.dyson_360_eye import Dyson360Eye |
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.
This should go above home assistant internal imports separated with a blank line.
https://www.python.org/dev/peps/pep-0008/#imports
SUPPORT_TURN_OFF, SUPPORT_TURN_ON, | ||
VacuumDevice) | ||
from homeassistant.util.icon import icon_for_battery_level | ||
from homeassistant.components.dyson import DYSON_DEVICES |
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.
Put this line above from homeassistant.components.vacuum import ...
, ie 🔡
"""Test setup component with no devices.""" | ||
self.hass.data[dyson.DYSON_DEVICES] = [] | ||
add_devices = mock.MagicMock() | ||
dyson.setup_platform(self.hass, None, add_devices) |
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.
It might not matter for this test but the config argument, the second argument, will always be at least an empty dict {}. When setting up a platform via discovery it will always be an empty dict.
I just updated the import orders (and also use an empty dict instead of none, it's better). Tell me if it's OK for you. But before merging, I would like to have @azogue point of view because I updated the |
@@ -168,9 +168,6 @@ def send_command(hass, command, params=None, entity_id=None): | |||
@asyncio.coroutine | |||
def async_setup(hass, config): | |||
"""Set up the vacuum component.""" | |||
if not config[DOMAIN]: |
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.
This should not be here, so it's good to remove. It would hinder discovery as stated already.
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.
Ok, perfect.
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.
Yeah, I think I copied it from some other component, but I'm not sure why exactly, so better out...
@@ -7,14 +7,14 @@ | |||
import asyncio | |||
import logging | |||
|
|||
from homeassistant.util.icon import icon_for_battery_level |
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.
No, please put this back below. Imports should be alphabetically sorted but following the greater rules of PEP8 for imports.
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.
Ok, this time it should be fine. Next time I'll try to do it in the first commit :)
Hi @CharlesBlonde, congrats for this PR! It is great to see how the community works and how HA grows better and better each release! |
@CharlesBlonde Please link to a docs PR asap. |
Yes, to include all three vacuum cleaners in the next release! (0.50.3 or 0.51.0) ... suggesting subtitle alias for the release: The botvac revolution hehehe ... |
I just submitted the PR for the documentation (home-assistant/home-assistant.io#3148). Ready for release 0.51.0 :) |
…ome-assistant#8852) * Add support to Dyson 360 Eye robot vacuum using new vacuum platform * Fix tests with Python 3.5 * Code review * Code review - v2 * Code review - v3
I try to use Dyson hub to add my 360 eye. But I am not sure which should be the device ID. I only see serial number in my settings page. I put it in the device ID but logs shows can't find the device. Could you please advice on? |
Please use the forum or chat for support questions. |
Description:
Add support to Dyson 360 Eye robot vacuum implementing the new
vacuum
platform added in PR #8623@azogue You did an amazing job with this platform! In less than 2 hours, I had a first fully working Dyson implementation.
Nevertheless, I had to remove a test in the
vacuum
platform:Because I'm calling the setup programaticly, without adding any
vacuum:
I have to do that because I'm using the parent Dyson hub used also by fan/purifier. Do you see any issue by removing this test ?
Pull request in home-assistant.github.io with documentation (if applicable): home-assistant/home-assistant.io#3148
Example entry for
configuration.yaml
(if applicable):It's using the already existing Dyson hub configuration
Checklist:
If user exposed functionality or configuration variables are added/changed:
If the code communicates with devices, web services, or third-party tools:
tox
run successfully. Your PR cannot be merged unless tests passREQUIREMENTS
variable (example).requirements_all.txt
by runningscript/gen_requirements_all.py
..coveragerc
.