Add support fo map data from Neato (#6939)
* Responsiveness * Delay was not needed as commands does not return until done. * Add support for cleaning maps and cleaning data * Hound * Docstring * Update requirements * Review changes * External lib now returns the raw data. * debug * Sensor did not refresh * Error handling * Issue warning on connection error * Update requirements * Review changes
This commit is contained in:
1 parent
01c7616147
commit
38ad5714cd
5 files changed
+164
-22
No files matched your search
@@ -12,6 +12,8 @@ from homeassistant.components.neato import NEATO_ROBOTS, NEATO_LOGIN
|
||||
|
||||
_LOGGER = logging.getLogger(__name__)
|
||||
|
||||
DEPENDENCIES = ['neato']
|
||||
|
||||
SWITCH_TYPE_CLEAN = 'clean'
|
||||
SWITCH_TYPE_SCHEDULE = 'scedule'
|
||||
|
||||
@@ -23,9 +25,6 @@ SWITCH_TYPES = {
|
||||
|
||||
def setup_platform(hass, config, add_devices, discovery_info=None):
|
||||
"""Setup the Neato switches."""
|
||||
if not hass.data[NEATO_ROBOTS]:
|
||||
return False
|
||||
|
||||
dev = []
|
||||
for robot in hass.data[NEATO_ROBOTS]:
|
||||
for type_name in SWITCH_TYPES:
|
||||
@@ -43,7 +42,12 @@ class NeatoConnectedSwitch(ToggleEntity):
|
||||
self.robot = robot
|
||||
self.neato = hass.data[NEATO_LOGIN]
|
||||
self._robot_name = self.robot.name + ' ' + SWITCH_TYPES[self.type][0]
|
||||
self._state = self.robot.state
|
||||
try:
|
||||
self._state = self.robot.state
|
||||
except (requests.exceptions.ConnectionError,
|
||||
requests.exceptions.HTTPError) as ex:
|
||||
_LOGGER.warning('Neato connection error: %s', ex)
|
||||
self._state = None
|
||||
self._schedule_state = None
|
||||
self._clean_state = None
|
||||
|
||||
@@ -51,14 +55,13 @@ class NeatoConnectedSwitch(ToggleEntity):
|
||||
"""Update the states of Neato switches."""
|
||||
_LOGGER.debug('Running switch update')
|
||||
self.neato.update_robots()
|
||||
if not self._state:
|
||||
return
|
||||
try:
|
||||
self._state = self.robot.state
|
||||
except requests.exceptions.HTTPError:
|
||||
except (requests.exceptions.ConnectionError,
|
||||
requests.exceptions.HTTPError) as ex:
|
||||
_LOGGER.warning('Neato connection error: %s', ex)
|
||||
self._state = None
|
||||
return
|
||||
self._state = self.robot.state
|
||||
_LOGGER.debug('self._state=%s', self._state)
|
||||
if self.type == SWITCH_TYPE_CLEAN:
|
||||
if (self.robot.state['action'] == 1 or
|
||||
|
||||
Reference in new issue
Block a user