Skip to content
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 15 additions & 5 deletions homeassistant/components/neato/__init__.py
Original file line number Diff line number Diff line change
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,7 @@
DOMAIN: vol.Schema({
vol.Required(CONF_USERNAME): cv.string,
vol.Required(CONF_PASSWORD): cv.string,
vol.Optional(CONF_VENDOR, default='neato'): cv.string
Comment thread
dshokouhi marked this conversation as resolved.
Outdated
})
}, extra=vol.ALLOW_EXTRA)

Expand Down Expand Up @@ -169,9 +171,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 +192,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 +212,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
Original file line number Diff line number Diff line change
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
14 changes: 9 additions & 5 deletions homeassistant/components/neato/vacuum.py
Original file line number Diff line number Diff line change
Expand Up @@ -185,13 +185,17 @@ def update(self):
self._mapdata[self._robot_serial]['maps'][0]['run_charge_at_end'])

if self._robot_has_map:
robot_map_id = {}
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:
robot_map_id[allmaps.index(maps)] = maps['id']

for map_id in robot_map_id:
Comment thread
dshokouhi marked this conversation as resolved.
Outdated
neatomap = robot_map_id[map_id]
Comment thread
dshokouhi marked this conversation as resolved.
Outdated
self._robot_boundaries = self.robot.get_map_boundaries(
neatomap).json()

@property
def name(self):
Expand Down
2 changes: 1 addition & 1 deletion requirements_all.txt
Original file line number Diff line number Diff line change
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