Skip to content
Snippets Groups Projects
Commit a107a592 authored by John Arild Berentsen's avatar John Arild Berentsen Committed by GitHub
Browse files

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
parent 134b21df
No related branches found
No related tags found
No related merge requests found
......@@ -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:
......
......@@ -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:
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment