Fix for #6691 Neato Connection error handling (#6731)

* Responsiveness

* Delay was not needed as commands does not return until done.

* Offline error catch

* Remove unneeded code
This commit is contained in:
John Arild Berentsen 2017-04-03 14:42:21 +02:00 committed by GitHub
parent 134b21dfea
commit a107a592de
2 changed files with 14 additions and 3 deletions

View file

@ -5,7 +5,7 @@ For more details about this platform, please refer to the documentation at
https://home-assistant.io/components/sensor.neato/
"""
import logging
import requests
from homeassistant.helpers.entity import Entity
from homeassistant.components.neato import (
NEATO_ROBOTS, NEATO_LOGIN, ACTION, ERRORS, MODE, ALERTS)
@ -52,7 +52,13 @@ class NeatoConnectedSensor(Entity):
self.neato.update_robots()
if not self._state:
return
self._state = self.robot.state
try:
self._state = self.robot.state
except requests.exceptions.HTTPError as ex:
self._state = None
self._status_state = 'Offline'
_LOGGER.debug('Neato connection issue: %s', ex)
return
_LOGGER.debug('self._state=%s', self._state)
if self.type == SENSOR_TYPE_STATUS:
if self._state['state'] == 1:

View file

@ -5,7 +5,7 @@ For more details about this platform, please refer to the documentation at
https://home-assistant.io/components/switch.neato/
"""
import logging
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
@ -53,6 +53,11 @@ class NeatoConnectedSwitch(ToggleEntity):
self.neato.update_robots()
if not self._state:
return
try:
self._state = self.robot.state
except requests.exceptions.HTTPError:
self._state = None
return
self._state = self.robot.state
_LOGGER.debug('self._state=%s', self._state)
if self.type == SWITCH_TYPE_CLEAN: