-
-
Notifications
You must be signed in to change notification settings - Fork 34.1k
Refactor Neato botvac components as a vacuum #9946
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
def turn_on(self, **kwargs): | ||
"""Turn the vacuum on and start cleaning.""" | ||
self.robot.start_cleaning() | ||
|
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.
blank line contains whitespace
def battery_level(self): | ||
"""Return the battery level of the vacuum cleaner.""" | ||
return self._state['details']['charge'] | ||
|
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.
blank line contains whitespace
def supported_features(self): | ||
"""Flag vacuum cleaner robot features that are supported.""" | ||
return SUPPORT_NEATO | ||
|
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.
blank line contains whitespace
def icon(self): | ||
"""Return the icon to use for device.""" | ||
return ICON | ||
|
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.
blank line contains whitespace
if (self.robot.state['action'] == 1 or | ||
self.robot.state['action'] == 2 or | ||
self.robot.state['action'] == 3 and | ||
self.robot.state['state'] == 2): |
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.
visually indented line with same indent as next logical line
_LOGGER.debug("Adding vacuums %s", dev) | ||
add_devices(dev) | ||
|
||
class NeatoConnectedVacuum(VacuumDevice): |
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.
expected 2 blank lines, found 1
SUPPORT_MAP, ATTR_STATUS, | ||
ATTR_BATTERY_LEVEL, | ||
ATTR_BATTERY_ICON, VacuumDevice) | ||
from homeassistant.components.neato import ( |
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.
'homeassistant.components.neato.NEATO_MAP_DATA' imported but unused
import logging | ||
import requests | ||
from homeassistant.const import STATE_OFF, STATE_ON | ||
from homeassistant.components.vacuum import (SUPPORT_BATTERY, |
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.
'homeassistant.components.vacuum.SUPPORT_FAN_SPEED' imported but unused
requests.exceptions.HTTPError) as ex: | ||
_LOGGER.warning("Neato connection error: %s", ex) | ||
self._state = None | ||
self._mapdata = hass.data[NEATO_MAP_DATA] |
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.
undefined name 'NEATO_MAP_DATA'
ATTR_CLEAN_SUSP_COUNT = 'clean_suspension_count' | ||
ATTR_CLEAN_SUSP_TIME = 'clean_suspension_time' | ||
|
||
def setup_platform(hass, config, add_devices, discovery_info=None): |
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.
expected 2 blank lines, found 1
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 🐦
@property | ||
def is_on(self): | ||
"""Return true if switch is on.""" | ||
if self._clean_state == STATE_ON: |
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 self._clean_state == STATE_ON
if self._state['state'] == 1: | ||
self.robot.start_cleaning() | ||
elif self._state['state'] == 2: | ||
if ALERTS.get(self._state['error']) is None: |
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.
Connect this statement to the previous line with and
.
self._status_state = None | ||
self._clean_state = None | ||
try: | ||
self._state = self.robot.state |
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.
Initial this as None
and call update
instead during entity addition by adding True
as second argument to add_devices
.
if self._state['state'] == 1: | ||
self.robot.start_cleaning() | ||
elif self._state['state'] == 2 and\ | ||
ALERTS.get(self._state['error']) is None: |
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.
continuation line over-indented for visual indent
if self._state['state'] == 1: | ||
self.robot.start_cleaning() | ||
elif self._state['state'] == 2 and\ | ||
ALERTS.get(self._state['error']) is None: |
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.
continuation line over-indented for visual indent
self.clean_battery_end = None | ||
self.clean_suspension_charge_count = None | ||
self.clean_suspension_time = None | ||
self.update() |
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.
Remove this and instead call add_devices
in setup_platform
like this:
add_devices(dev, True)
update
will then be called during adding the devices to home assistant.
A switch is still use to enable/disable the schedule Signed-off-by: Hugo D. (jabesq) <[email protected]>
Signed-off-by: Hugo D. (jabesq) <[email protected]>
Signed-off-by: Hugo D. (jabesq) <[email protected]>
As future improvment, you can remove the switch and make platform service calls for that function or maybe it make sense to add it to base |
This PR should have included a section for the breaking changes section of the release notes. |
Description:
Refactor Neato botvac components as a vacuum
A switch is still use to enable/disable the schedule
Pull request in home-assistant.github.io with documentation (if applicable): home-assistant/home-assistant.io#3674
Checklist:
If user exposed functionality or configuration variables are added/changed:
If the code does not interact with devices:
tox
run successfully. Your PR cannot be merged unless tests pass