Пример #1
0
 def update(self):
     """Update the properties of sensor."""
     _LOGGER.debug('Update of sensor')
     self.neato.update_robots()
     if not self._state:
         return
     self._state = self.robot.state
     _LOGGER.debug('self._state=%s', self._state)
     if self.type == SENSOR_TYPE_STATUS:
         if self._state['state'] == 1:
             if self._state['details']['isCharging']:
                 self._status_state = 'Charging'
             elif (self._state['details']['isDocked'] and
                   not self._state['details']['isCharging']):
                 self._status_state = 'Docked'
             else:
                 self._status_state = 'Stopped'
         elif self._state['state'] == 2:
             if ALERTS.get(self._state['error']) is None:
                 self._status_state = (
                     MODE.get(self._state['cleaning']['mode'])
                     + ' ' + ACTION.get(self._state['action']))
             else:
                 self._status_state = ALERTS.get(self._state['error'])
         elif self._state['state'] == 3:
             self._status_state = 'Paused'
         elif self._state['state'] == 4:
             self._status_state = ERRORS.get(self._state['error'])
     if self.type == SENSOR_TYPE_BATTERY:
         self._battery_state = self._state['details']['charge']
Пример #2
0
 def update(self):
     """Update the properties of sensor."""
     _LOGGER.debug('Update of sensor')
     self.neato.update_robots()
     if not self._state:
         return
     self._state = self.robot.state
     _LOGGER.debug('self._state=%s', self._state)
     if self.type == SENSOR_TYPE_STATUS:
         if self._state['state'] == 1:
             if self._state['details']['isCharging']:
                 self._status_state = 'Charging'
             elif (self._state['details']['isDocked']
                   and not self._state['details']['isCharging']):
                 self._status_state = 'Docked'
             else:
                 self._status_state = 'Stopped'
         elif self._state['state'] == 2:
             if ALERTS.get(self._state['error']) is None:
                 self._status_state = (
                     MODE.get(self._state['cleaning']['mode']) + ' ' +
                     ACTION.get(self._state['action']))
             else:
                 self._status_state = ALERTS.get(self._state['error'])
         elif self._state['state'] == 3:
             self._status_state = 'Paused'
         elif self._state['state'] == 4:
             self._status_state = ERRORS.get(self._state['error'])
     if self.type == SENSOR_TYPE_BATTERY:
         self._battery_state = self._state['details']['charge']
Пример #3
0
 def update(self):
     """Update the properties of sensor."""
     _LOGGER.debug('Update of sensor')
     self.neato.update_robots()
     self._mapdata = self.hass.data[NEATO_MAP_DATA]
     try:
         self._state = self.robot.state
     except (requests.exceptions.ConnectionError,
             requests.exceptions.HTTPError) as ex:
         self._state = None
         self._status_state = 'Offline'
         _LOGGER.warning('Neato connection error: %s', ex)
         return
     if not self._state:
         return
     _LOGGER.debug('self._state=%s', self._state)
     if self.type == SENSOR_TYPE_STATUS:
         if self._state['state'] == 1:
             if self._state['details']['isCharging']:
                 self._status_state = 'Charging'
             elif (self._state['details']['isDocked'] and
                   not self._state['details']['isCharging']):
                 self._status_state = 'Docked'
             else:
                 self._status_state = 'Stopped'
         elif self._state['state'] == 2:
             if ALERTS.get(self._state['error']) is None:
                 self._status_state = (
                     MODE.get(self._state['cleaning']['mode'])
                     + ' ' + ACTION.get(self._state['action']))
             else:
                 self._status_state = ALERTS.get(self._state['error'])
         elif self._state['state'] == 3:
             self._status_state = 'Paused'
         elif self._state['state'] == 4:
             self._status_state = ERRORS.get(self._state['error'])
     if self.type == SENSOR_TYPE_BATTERY:
         self._battery_state = self._state['details']['charge']
     if self._mapdata is None:
         return
     self.clean_time_start = (
         (self._mapdata[self.robot.serial]['maps'][0]['start_at']
          .strip('Z'))
         .replace('T', ' '))
     self.clean_time_stop = (
         (self._mapdata[self.robot.serial]['maps'][0]['end_at'].strip('Z'))
         .replace('T', ' '))
     self.clean_area = (
         self._mapdata[self.robot.serial]['maps'][0]['cleaned_area'])
     self.clean_suspension_charge_count = (
         self._mapdata[self.robot.serial]['maps'][0]
         ['suspended_cleaning_charging_count'])
     self.clean_suspension_time = (
         self._mapdata[self.robot.serial]['maps'][0]
         ['time_in_suspended_cleaning'])
     self.clean_battery_start = (
         self._mapdata[self.robot.serial]['maps'][0]['run_charge_at_start'])
     self.clean_battery_end = (
         self._mapdata[self.robot.serial]['maps'][0]['run_charge_at_end'])
Пример #4
0
 def update(self):
     """Update the properties of sensor."""
     _LOGGER.debug('Update of sensor')
     self.neato.update_robots()
     self._mapdata = self.hass.data[NEATO_MAP_DATA]
     try:
         self._state = self.robot.state
     except (requests.exceptions.ConnectionError,
             requests.exceptions.HTTPError) as ex:
         self._state = None
         self._status_state = 'Offline'
         _LOGGER.warning("Neato connection error: %s", ex)
         return
     if not self._state:
         return
     _LOGGER.debug('self._state=%s', self._state)
     if self.type == SENSOR_TYPE_STATUS:
         if self._state['state'] == 1:
             if self._state['details']['isCharging']:
                 self._status_state = 'Charging'
             elif (self._state['details']['isDocked'] and
                   not self._state['details']['isCharging']):
                 self._status_state = 'Docked'
             else:
                 self._status_state = 'Stopped'
         elif self._state['state'] == 2:
             if ALERTS.get(self._state['error']) is None:
                 self._status_state = (
                     MODE.get(self._state['cleaning']['mode'])
                     + ' ' + ACTION.get(self._state['action']))
             else:
                 self._status_state = ALERTS.get(self._state['error'])
         elif self._state['state'] == 3:
             self._status_state = 'Paused'
         elif self._state['state'] == 4:
             self._status_state = ERRORS.get(self._state['error'])
     if self.type == SENSOR_TYPE_BATTERY:
         self._battery_state = self._state['details']['charge']
     if self._mapdata is None:
         return
     self.clean_time_start = (
         (self._mapdata[self.robot.serial]['maps'][0]['start_at']
          .strip('Z'))
         .replace('T', ' '))
     self.clean_time_stop = (
         (self._mapdata[self.robot.serial]['maps'][0]['end_at'].strip('Z'))
         .replace('T', ' '))
     self.clean_area = (
         self._mapdata[self.robot.serial]['maps'][0]['cleaned_area'])
     self.clean_suspension_charge_count = (
         self._mapdata[self.robot.serial]['maps'][0]
         ['suspended_cleaning_charging_count'])
     self.clean_suspension_time = (
         self._mapdata[self.robot.serial]['maps'][0]
         ['time_in_suspended_cleaning'])
     self.clean_battery_start = (
         self._mapdata[self.robot.serial]['maps'][0]['run_charge_at_start'])
     self.clean_battery_end = (
         self._mapdata[self.robot.serial]['maps'][0]['run_charge_at_end'])
Пример #5
0
    def update(self):
        """Update the states of Neato Vacuums."""
        _LOGGER.debug("Running Neato Vacuums update")
        self.neato.update_robots()
        try:
            self._state = self.robot.state
            self._available = True
        except (requests.exceptions.ConnectionError,
                requests.exceptions.HTTPError) as ex:
            _LOGGER.warning("Neato connection error: %s", ex)
            self._state = None
            self._available = False
            return
        _LOGGER.debug('self._state=%s', self._state)
        if self._state['state'] == 1:
            if self._state['details']['isCharging']:
                self._clean_state = STATE_DOCKED
                self._status_state = 'Charging'
            elif (self._state['details']['isDocked']
                  and not self._state['details']['isCharging']):
                self._clean_state = STATE_DOCKED
                self._status_state = 'Docked'
            else:
                self._clean_state = STATE_IDLE
                self._status_state = 'Stopped'
        elif self._state['state'] == 2:
            if ALERTS.get(self._state['error']) is None:
                self._clean_state = STATE_CLEANING
                self._status_state = (
                    MODE.get(self._state['cleaning']['mode']) + ' ' +
                    ACTION.get(self._state['action']))
            else:
                self._status_state = ALERTS.get(self._state['error'])
        elif self._state['state'] == 3:
            self._clean_state = STATE_PAUSED
            self._status_state = 'Paused'
        elif self._state['state'] == 4:
            self._clean_state = STATE_ERROR
            self._status_state = ERRORS.get(self._state['error'])

        if not self._mapdata.get(self._robot_serial, {}).get('maps', []):
            return
        self.clean_time_start = ((self._mapdata[self._robot_serial]['maps'][0]
                                  ['start_at'].strip('Z')).replace('T', ' '))
        self.clean_time_stop = ((self._mapdata[self._robot_serial]['maps'][0]
                                 ['end_at'].strip('Z')).replace('T', ' '))
        self.clean_area = (
            self._mapdata[self._robot_serial]['maps'][0]['cleaned_area'])
        self.clean_suspension_charge_count = (
            self._mapdata[self._robot_serial]['maps'][0]
            ['suspended_cleaning_charging_count'])
        self.clean_suspension_time = (self._mapdata[self._robot_serial]['maps']
                                      [0]['time_in_suspended_cleaning'])
        self.clean_battery_start = (self._mapdata[self._robot_serial]['maps']
                                    [0]['run_charge_at_start'])
        self.clean_battery_end = (
            self._mapdata[self._robot_serial]['maps'][0]['run_charge_at_end'])

        self._battery_level = self._state['details']['charge']
 def start_pause(self, **kwargs):
     """Start, pause or resume the cleaning task."""
     if self._state['state'] == 1:
         self.robot.start_cleaning()
     elif self._state['state'] == 2 and\
             ALERTS.get(self._state['error']) is None:
         self.robot.pause_cleaning()
     if self._state['state'] == 3:
         self.robot.resume_cleaning()
Пример #7
0
 def start_pause(self, **kwargs):
     """Start, pause or resume the cleaning task."""
     if self._state['state'] == 1:
         self.robot.start_cleaning()
     elif self._state['state'] == 2 and\
             ALERTS.get(self._state['error']) is None:
         self.robot.pause_cleaning()
     if self._state['state'] == 3:
         self.robot.resume_cleaning()
Пример #8
0
    def update(self):
        """Update the states of Neato Vacuums."""
        _LOGGER.debug("Running Neato Vacuums update")
        self.neato.update_robots()
        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._clean_state = STATE_ERROR
            self._status_state = 'Robot Offline'
            return
        _LOGGER.debug('self._state=%s', self._state)
        if self._state['state'] == 1:
            if self._state['details']['isCharging']:
                self._clean_state = STATE_DOCKED
                self._status_state = 'Charging'
            elif (self._state['details']['isDocked'] and
                  not self._state['details']['isCharging']):
                self._clean_state = STATE_DOCKED
                self._status_state = 'Docked'
            else:
                self._clean_state = STATE_IDLE
                self._status_state = 'Stopped'
        elif self._state['state'] == 2:
            if ALERTS.get(self._state['error']) is None:
                self._clean_state = STATE_CLEANING
                self._status_state = (
                    MODE.get(self._state['cleaning']['mode'])
                    + ' ' + ACTION.get(self._state['action']))
            else:
                self._status_state = ALERTS.get(self._state['error'])
        elif self._state['state'] == 3:
            self._clean_state = STATE_PAUSED
            self._status_state = 'Paused'
        elif self._state['state'] == 4:
            self._clean_state = STATE_ERROR
            self._status_state = ERRORS.get(self._state['error'])

        if not self._mapdata.get(self.robot.serial, {}).get('maps', []):
            return
        self.clean_time_start = (
            (self._mapdata[self.robot.serial]['maps'][0]['start_at']
             .strip('Z'))
            .replace('T', ' '))
        self.clean_time_stop = (
            (self._mapdata[self.robot.serial]['maps'][0]['end_at'].strip('Z'))
            .replace('T', ' '))
        self.clean_area = (
            self._mapdata[self.robot.serial]['maps'][0]['cleaned_area'])
        self.clean_suspension_charge_count = (
            self._mapdata[self.robot.serial]['maps'][0]
            ['suspended_cleaning_charging_count'])
        self.clean_suspension_time = (
            self._mapdata[self.robot.serial]['maps'][0]
            ['time_in_suspended_cleaning'])
        self.clean_battery_start = (
            self._mapdata[self.robot.serial]['maps'][0]['run_charge_at_start'])
        self.clean_battery_end = (
            self._mapdata[self.robot.serial]['maps'][0]['run_charge_at_end'])
Пример #9
0
    def update(self):
        """Update the states of Neato Vacuums."""
        _LOGGER.debug("Running Neato Vacuums update")
        self.neato.update_robots()
        try:
            self._state = self.robot.state
            self._available = True
        except (requests.exceptions.ConnectionError,
                requests.exceptions.HTTPError) as ex:
            _LOGGER.warning("Neato connection error: %s", ex)
            self._state = None
            self._available = False
            return
        _LOGGER.debug('self._state=%s', self._state)
        if 'alert' in self._state:
            robot_alert = ALERTS.get(self._state['alert'])
        else:
            robot_alert = None
        if self._state['state'] == 1:
            if self._state['details']['isCharging']:
                self._clean_state = STATE_DOCKED
                self._status_state = 'Charging'
            elif (self._state['details']['isDocked'] and
                  not self._state['details']['isCharging']):
                self._clean_state = STATE_DOCKED
                self._status_state = 'Docked'
            else:
                self._clean_state = STATE_IDLE
                self._status_state = 'Stopped'

            if robot_alert is not None:
                self._status_state = robot_alert
        elif self._state['state'] == 2:
            if robot_alert is None:
                self._clean_state = STATE_CLEANING
                self._status_state = (
                    MODE.get(self._state['cleaning']['mode'])
                    + ' ' + ACTION.get(self._state['action']))
            else:
                self._status_state = robot_alert
        elif self._state['state'] == 3:
            self._clean_state = STATE_PAUSED
            self._status_state = 'Paused'
        elif self._state['state'] == 4:
            self._clean_state = STATE_ERROR
            self._status_state = ERRORS.get(self._state['error'])

        if not self._mapdata.get(self._robot_serial, {}).get('maps', []):
            return
        self.clean_time_start = (
            (self._mapdata[self._robot_serial]['maps'][0]['start_at']
             .strip('Z'))
            .replace('T', ' '))
        self.clean_time_stop = (
            (self._mapdata[self._robot_serial]['maps'][0]['end_at'].strip('Z'))
            .replace('T', ' '))
        self.clean_area = (
            self._mapdata[self._robot_serial]['maps'][0]['cleaned_area'])
        self.clean_suspension_charge_count = (
            self._mapdata[self._robot_serial]['maps'][0]
            ['suspended_cleaning_charging_count'])
        self.clean_suspension_time = (
            self._mapdata[self._robot_serial]['maps'][0]
            ['time_in_suspended_cleaning'])
        self.clean_battery_start = (
            self._mapdata[self._robot_serial]['maps'][0]['run_charge_at_start']
        )
        self.clean_battery_end = (
            self._mapdata[self._robot_serial]['maps'][0]['run_charge_at_end'])

        self._battery_level = self._state['details']['charge']

        if self._robot_has_map:
            if self._state['availableServices']['maps'] != "basic-1":
                robot_map_id = self._robot_maps[self._robot_serial][0]['id']

                self._robot_boundaries = self.robot.get_map_boundaries(
                    robot_map_id).json()