Neato Fixes (#4490)
* Fix, switch state. Move constants to hub * Responsiveness * Whitespace * Delay was not needed as commands does not return until done.pull/4519/head
parent
e5aa40fa5d
commit
c23809488b
|
@ -31,6 +31,53 @@ CONFIG_SCHEMA = vol.Schema({
|
|||
})
|
||||
}, extra=vol.ALLOW_EXTRA)
|
||||
|
||||
STATES = {
|
||||
1: 'Idle',
|
||||
2: 'Busy',
|
||||
3: 'Pause',
|
||||
4: 'Error'
|
||||
}
|
||||
|
||||
MODE = {
|
||||
1: 'Eco',
|
||||
2: 'Turbo'
|
||||
}
|
||||
|
||||
ACTION = {
|
||||
0: 'No action',
|
||||
1: 'House cleaning',
|
||||
2: 'Spot cleaning',
|
||||
3: 'Manual cleaning',
|
||||
4: 'Docking',
|
||||
5: 'User menu active',
|
||||
6: 'Cleaning cancelled',
|
||||
7: 'Updating...',
|
||||
8: 'Copying logs...',
|
||||
9: 'Calculating position...',
|
||||
10: 'IEC test'
|
||||
}
|
||||
|
||||
ERRORS = {
|
||||
'ui_error_brush_stuck': 'Brush stuck',
|
||||
'ui_error_brush_overloaded': 'Brush overloaded',
|
||||
'ui_error_bumper_stuck': 'Bumper stuck',
|
||||
'ui_error_dust_bin_missing': 'Dust bin missing',
|
||||
'ui_error_dust_bin_full': 'Dust bin full',
|
||||
'ui_error_dust_bin_emptied': 'Dust bin emptied',
|
||||
'ui_error_navigation_backdrop_leftbump': 'Clear my path',
|
||||
'ui_error_navigation_noprogress': 'Clear my path',
|
||||
'ui_error_navigation_origin_unclean': 'Clear my path',
|
||||
'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!'
|
||||
}
|
||||
|
||||
ALERTS = {
|
||||
'ui_alert_dust_bin_full': 'Please empty dust bin',
|
||||
'ui_alert_recovering_location': 'Returning to start'
|
||||
}
|
||||
|
||||
|
||||
def setup(hass, config):
|
||||
"""Setup the Verisure component."""
|
||||
|
|
|
@ -7,7 +7,8 @@ https://home-assistant.io/components/sensor.neato/
|
|||
import logging
|
||||
|
||||
from homeassistant.helpers.entity import Entity
|
||||
from homeassistant.components.neato import NEATO_ROBOTS, NEATO_LOGIN
|
||||
from homeassistant.components.neato import (
|
||||
NEATO_ROBOTS, NEATO_LOGIN, ACTION, ERRORS, MODE, ALERTS)
|
||||
|
||||
_LOGGER = logging.getLogger(__name__)
|
||||
SENSOR_TYPE_STATUS = 'status'
|
||||
|
@ -18,52 +19,6 @@ SENSOR_TYPES = {
|
|||
SENSOR_TYPE_BATTERY: ['Battery']
|
||||
}
|
||||
|
||||
STATES = {
|
||||
1: 'Idle',
|
||||
2: 'Busy',
|
||||
3: 'Pause',
|
||||
4: 'Error'
|
||||
}
|
||||
|
||||
MODE = {
|
||||
1: 'Eco',
|
||||
2: 'Turbo'
|
||||
}
|
||||
|
||||
ACTION = {
|
||||
0: 'No action',
|
||||
1: 'House cleaning',
|
||||
2: 'Spot cleaning',
|
||||
3: 'Manual cleaning',
|
||||
4: 'Docking',
|
||||
5: 'User menu active',
|
||||
6: 'Cleaning cancelled',
|
||||
7: 'Updating...',
|
||||
8: 'Copying logs...',
|
||||
9: 'Calculating position...',
|
||||
10: 'IEC test'
|
||||
}
|
||||
|
||||
ERRORS = {
|
||||
'ui_error_brush_stuck': 'Brush stuck',
|
||||
'ui_error_brush_overloaded': 'Brush overloaded',
|
||||
'ui_error_bumper_stuck': 'Bumper stuck',
|
||||
'ui_error_dust_bin_missing': 'Dust bin missing',
|
||||
'ui_error_dust_bin_full': 'Dust bin full',
|
||||
'ui_error_dust_bin_emptied': 'Dust bin emptied',
|
||||
'ui_error_navigation_noprogress': 'Clear my path',
|
||||
'ui_error_navigation_origin_unclean': 'Clear my path',
|
||||
'ui_error_navigation_falling': 'Clear my path',
|
||||
'ui_error_picked_up': 'Picked up',
|
||||
'ui_error_stuck': 'Stuck!'
|
||||
|
||||
}
|
||||
|
||||
ALERTS = {
|
||||
'ui_alert_dust_bin_full': 'Please empty dust bin',
|
||||
'ui_alert_recovering_location': 'Returning to start'
|
||||
}
|
||||
|
||||
|
||||
def setup_platform(hass, config, add_devices, discovery_info=None):
|
||||
"""Setup the Neato sensor platform."""
|
||||
|
|
|
@ -4,7 +4,6 @@ Support for Neato Connected Vaccums switches.
|
|||
For more details about this platform, please refer to the documentation at
|
||||
https://home-assistant.io/components/switch.neato/
|
||||
"""
|
||||
import time
|
||||
import logging
|
||||
|
||||
from homeassistant.const import STATE_OFF, STATE_ON
|
||||
|
@ -57,17 +56,21 @@ class NeatoConnectedSwitch(ToggleEntity):
|
|||
self._state = self.robot.state
|
||||
_LOGGER.debug('self._state=%s', self._state)
|
||||
if self.type == SWITCH_TYPE_CLEAN:
|
||||
if (self.robot.state['action'] == 1 and
|
||||
if (self.robot.state['action'] == 1 or
|
||||
self.robot.state['action'] == 2 or
|
||||
self.robot.state['action'] == 3 and
|
||||
self.robot.state['state'] == 2):
|
||||
self._clean_state = STATE_ON
|
||||
else:
|
||||
self._clean_state = STATE_OFF
|
||||
_LOGGER.debug('schedule_state=%s', self._schedule_state)
|
||||
if self.type == SWITCH_TYPE_SCHEDULE:
|
||||
_LOGGER.debug('self._state=%s', self._state)
|
||||
if self.robot.schedule_enabled:
|
||||
self._schedule_state = STATE_ON
|
||||
else:
|
||||
self._schedule_state = STATE_OFF
|
||||
_LOGGER.debug('schedule_state=%s', self._schedule_state)
|
||||
|
||||
@property
|
||||
def name(self):
|
||||
|
@ -105,7 +108,6 @@ class NeatoConnectedSwitch(ToggleEntity):
|
|||
"""Turn the switch off."""
|
||||
if self.type == SWITCH_TYPE_CLEAN:
|
||||
self.robot.pause_cleaning()
|
||||
time.sleep(1)
|
||||
self.robot.send_to_base()
|
||||
elif self.type == SWITCH_TYPE_SCHEDULE:
|
||||
self.robot.disable_schedule()
|
||||
|
|
Loading…
Reference in New Issue