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

Add vendor support for vorwerk robots and fix zone retrieval #25200

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
21 changes: 16 additions & 5 deletions homeassistant/components/neato/__init__.py
Expand Up @@ -12,6 +12,7 @@

_LOGGER = logging.getLogger(__name__)

CONF_VENDOR = 'vendor'
DOMAIN = 'neato'
NEATO_ROBOTS = 'neato_robots'
NEATO_LOGIN = 'neato_login'
Expand All @@ -22,6 +23,8 @@
DOMAIN: vol.Schema({
vol.Required(CONF_USERNAME): cv.string,
vol.Required(CONF_PASSWORD): cv.string,
vol.Optional(CONF_VENDOR, default='neato'): vol.In(
['neato', 'vorwerk'])
})
}, extra=vol.ALLOW_EXTRA)

Expand Down Expand Up @@ -169,9 +172,13 @@

def setup(hass, config):
"""Set up the Neato component."""
from pybotvac import Account
from pybotvac import Account, Neato, Vorwerk

hass.data[NEATO_LOGIN] = NeatoHub(hass, config[DOMAIN], Account)
if config[DOMAIN][CONF_VENDOR] == 'neato':
hass.data[NEATO_LOGIN] = NeatoHub(hass, config[DOMAIN], Account, Neato)
elif config[DOMAIN][CONF_VENDOR] == 'vorwerk':
hass.data[NEATO_LOGIN] = NeatoHub(hass, config[DOMAIN], Account,
Vorwerk)
hub = hass.data[NEATO_LOGIN]
if not hub.login():
_LOGGER.debug("Failed to login to Neato API")
Expand All @@ -186,15 +193,17 @@ def setup(hass, config):
class NeatoHub:
"""A My Neato hub wrapper class."""

def __init__(self, hass, domain_config, neato):
def __init__(self, hass, domain_config, neato, vendor):
"""Initialize the Neato hub."""
self.config = domain_config
self._neato = neato
self._hass = hass
self._vendor = vendor

self.my_neato = neato(
domain_config[CONF_USERNAME],
domain_config[CONF_PASSWORD])
domain_config[CONF_PASSWORD],
vendor)
self._hass.data[NEATO_ROBOTS] = self.my_neato.robots
self._hass.data[NEATO_PERSISTENT_MAPS] = self.my_neato.persistent_maps
self._hass.data[NEATO_MAP_DATA] = self.my_neato.maps
Expand All @@ -204,7 +213,9 @@ def login(self):
try:
_LOGGER.debug("Trying to connect to Neato API")
self.my_neato = self._neato(
self.config[CONF_USERNAME], self.config[CONF_PASSWORD])
self.config[CONF_USERNAME],
self.config[CONF_PASSWORD],
self._vendor)
return True
except HTTPError:
_LOGGER.error("Unable to connect to Neato API")
Expand Down
2 changes: 1 addition & 1 deletion homeassistant/components/neato/manifest.json
Expand Up @@ -3,7 +3,7 @@
"name": "Neato",
"documentation": "https://www.home-assistant.io/components/neato",
"requirements": [
"pybotvac==0.0.13"
"pybotvac==0.0.15"
],
"dependencies": [],
"codeowners": []
Expand Down
9 changes: 4 additions & 5 deletions homeassistant/components/neato/vacuum.py
Expand Up @@ -187,11 +187,10 @@ def update(self):
if self._robot_has_map:
if self._state['availableServices']['maps'] != "basic-1":
if self._robot_maps[self._robot_serial]:
robot_map_id = (
self._robot_maps[self._robot_serial][0]['id'])

self._robot_boundaries = self.robot.get_map_boundaries(
robot_map_id).json()
allmaps = self._robot_maps[self._robot_serial]
for maps in allmaps:
self._robot_boundaries = self.robot.get_map_boundaries(
maps['id']).json()

@property
def name(self):
Expand Down
2 changes: 1 addition & 1 deletion requirements_all.txt
Expand Up @@ -1051,7 +1051,7 @@ pyblackbird==0.5
# pybluez==0.22

# homeassistant.components.neato
pybotvac==0.0.13
pybotvac==0.0.15

# homeassistant.components.nissan_leaf
pycarwings2==2.8
Expand Down