diff --git a/homeassistant/components/sensor/neato.py b/homeassistant/components/sensor/neato.py index 438e5fb189b074cceb670db2f497cc65079e18af..ca5cff1d24a0ddccdfca5df8e84e4e2446f31b3f 100644 --- a/homeassistant/components/sensor/neato.py +++ b/homeassistant/components/sensor/neato.py @@ -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: diff --git a/homeassistant/components/switch/neato.py b/homeassistant/components/switch/neato.py index 3b723acb748c19f18dab17183d4e707e762d8f34..6cd5c5088dc2ed2f17ee19d52633e7108a07c5ba 100644 --- a/homeassistant/components/switch/neato.py +++ b/homeassistant/components/switch/neato.py @@ -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: