Finalize BotVac D7 Support And Further Reduce Cloud Calls (#15161)

* Finalize BotVac D7 Support And Further Reduce Cloud Calls

* Lint

* Lint Again

* Implement requested changes

* Hound

* Lint
This commit is contained in:
Daniel Shokouhi 2018-06-27 13:55:27 -07:00 committed by Pascal Vizeli
parent 9066ac44fe
commit 4fbe3bb070
4 changed files with 37 additions and 10 deletions

View file

@ -10,12 +10,13 @@ from datetime import timedelta
from homeassistant.components.camera import Camera
from homeassistant.components.neato import (
NEATO_MAP_DATA, NEATO_ROBOTS, NEATO_LOGIN)
from homeassistant.util import Throttle
_LOGGER = logging.getLogger(__name__)
DEPENDENCIES = ['neato']
SCAN_INTERVAL = timedelta(minutes=10)
def setup_platform(hass, config, add_devices, discovery_info=None):
"""Set up the Neato Camera."""
@ -45,7 +46,6 @@ class NeatoCleaningMap(Camera):
self.update()
return self._image
@Throttle(timedelta(seconds=60))
def update(self):
"""Check the contents of the map list."""
self.neato.update_robots()

View file

@ -54,7 +54,12 @@ ACTION = {
7: 'Updating...',
8: 'Copying logs...',
9: 'Calculating position...',
10: 'IEC test'
10: 'IEC test',
11: 'Map cleaning',
12: 'Exploring map (creating a persistent map)',
13: 'Acquiring Persistent Map IDs',
14: 'Creating & Uploading Map',
15: 'Suspended Exploration'
}
ERRORS = {
@ -70,12 +75,30 @@ ERRORS = {
'ui_error_navigation_pathproblems_returninghome': 'Cannot return to base',
'ui_error_navigation_falling': 'Clear my path',
'ui_error_picked_up': 'Picked up',
'ui_error_stuck': 'Stuck!'
'ui_error_stuck': 'Stuck!',
'dustbin_full': 'Dust bin full',
'dustbin_missing': 'Dust bin missing',
'maint_brush_stuck': 'Brush stuck',
'maint_brush_overload': 'Brush overloaded',
'maint_bumper_stuck': 'Bumper stuck',
'maint_vacuum_stuck': 'Vacuum is stuck',
'maint_left_drop_stuck': 'Vacuum is stuck',
'maint_left_wheel_stuck': 'Vacuum is stuck',
'maint_right_drop_stuck': 'Vacuum is stuck',
'maint_right_wheel_stuck': 'Vacuum is stuck',
'not_on_charge_base': 'Not on the charge base',
'nav_robot_falling': 'Clear my path',
'nav_no_path': 'Clear my path',
'nav_path_problem': 'Clear my path'
}
ALERTS = {
'ui_alert_dust_bin_full': 'Please empty dust bin',
'ui_alert_recovering_location': 'Returning to start'
'ui_alert_recovering_location': 'Returning to start',
'dustbin_full': 'Please empty dust bin',
'maint_brush_change': 'Change the brush',
'maint_filter_change': 'Change the filter',
'clean_completed_to_start': 'Cleaning completed'
}
@ -121,7 +144,7 @@ class NeatoHub(object):
_LOGGER.error("Unable to connect to Neato API")
return False
@Throttle(timedelta(seconds=60))
@Throttle(timedelta(seconds=300))
def update_robots(self):
"""Update the robot states."""
_LOGGER.debug("Running HUB.update_robots %s",

View file

@ -10,12 +10,13 @@ import requests
from homeassistant.const import STATE_OFF, STATE_ON
from homeassistant.helpers.entity import ToggleEntity
from homeassistant.components.neato import NEATO_ROBOTS, NEATO_LOGIN
from homeassistant.util import Throttle
_LOGGER = logging.getLogger(__name__)
DEPENDENCIES = ['neato']
SCAN_INTERVAL = timedelta(minutes=10)
SWITCH_TYPE_SCHEDULE = 'schedule'
SWITCH_TYPES = {
@ -52,7 +53,6 @@ class NeatoConnectedSwitch(ToggleEntity):
self._schedule_state = None
self._clean_state = None
@Throttle(timedelta(seconds=60))
def update(self):
"""Update the states of Neato switches."""
_LOGGER.debug("Running switch update")

View file

@ -15,12 +15,13 @@ from homeassistant.components.vacuum import (
SUPPORT_MAP, ATTR_STATUS, ATTR_BATTERY_LEVEL, ATTR_BATTERY_ICON)
from homeassistant.components.neato import (
NEATO_ROBOTS, NEATO_LOGIN, NEATO_MAP_DATA, ACTION, ERRORS, MODE, ALERTS)
from homeassistant.util import Throttle
_LOGGER = logging.getLogger(__name__)
DEPENDENCIES = ['neato']
SCAN_INTERVAL = timedelta(minutes=5)
SUPPORT_NEATO = SUPPORT_BATTERY | SUPPORT_PAUSE | SUPPORT_RETURN_HOME | \
SUPPORT_STOP | SUPPORT_TURN_OFF | SUPPORT_TURN_ON | \
SUPPORT_STATUS | SUPPORT_MAP
@ -63,7 +64,6 @@ class NeatoConnectedVacuum(VacuumDevice):
self.clean_suspension_charge_count = None
self.clean_suspension_time = None
@Throttle(timedelta(seconds=60))
def update(self):
"""Update the states of Neato Vacuums."""
_LOGGER.debug("Running Neato Vacuums update")
@ -101,6 +101,10 @@ class NeatoConnectedVacuum(VacuumDevice):
self.robot.state['action'] == 3 and
self.robot.state['state'] == 2):
self._clean_state = STATE_ON
elif (self.robot.state['action'] == 11 or
self.robot.state['action'] == 12 and
self.robot.state['state'] == 2):
self._clean_state = STATE_ON
else:
self._clean_state = STATE_OFF