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

* Add vendor support for vorwerk robots and fix zone retrieval

* Lint

* Review comments

* Lint

* Review commeent

* Remove unused variable

* Review comment

* Remove unused variable
This commit is contained in:
Daniel Shokouhi 2019-07-18 10:22:05 -07:00 committed by Paulus Schoutsen
parent 93970b5621
commit 32e89dcbb6
4 changed files with 22 additions and 12 deletions

View File

@ -12,6 +12,7 @@ from homeassistant.util import Throttle
_LOGGER = logging.getLogger(__name__)
CONF_VENDOR = 'vendor'
DOMAIN = 'neato'
NEATO_ROBOTS = 'neato_robots'
NEATO_LOGIN = 'neato_login'
@ -22,6 +23,8 @@ CONFIG_SCHEMA = vol.Schema({
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)
@ -169,9 +172,13 @@ ALERTS = {
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")
@ -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
@ -204,7 +213,9 @@ class NeatoHub:
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")

View File

@ -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": []

View File

@ -187,11 +187,10 @@ class NeatoConnectedVacuum(StateVacuumDevice):
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):

View File

@ -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