mirror of
https://github.com/home-assistant/core.git
synced 2025-07-12 15:57:06 +00:00
* Responsiveness * Delay was not needed as commands does not return until done. * Offline error catch * Remove unneeded code
This commit is contained in:
parent
134b21dfea
commit
a107a592de
@ -5,7 +5,7 @@ For more details about this platform, please refer to the documentation at
|
|||||||
https://home-assistant.io/components/sensor.neato/
|
https://home-assistant.io/components/sensor.neato/
|
||||||
"""
|
"""
|
||||||
import logging
|
import logging
|
||||||
|
import requests
|
||||||
from homeassistant.helpers.entity import Entity
|
from homeassistant.helpers.entity import Entity
|
||||||
from homeassistant.components.neato import (
|
from homeassistant.components.neato import (
|
||||||
NEATO_ROBOTS, NEATO_LOGIN, ACTION, ERRORS, MODE, ALERTS)
|
NEATO_ROBOTS, NEATO_LOGIN, ACTION, ERRORS, MODE, ALERTS)
|
||||||
@ -52,7 +52,13 @@ class NeatoConnectedSensor(Entity):
|
|||||||
self.neato.update_robots()
|
self.neato.update_robots()
|
||||||
if not self._state:
|
if not self._state:
|
||||||
return
|
return
|
||||||
|
try:
|
||||||
self._state = self.robot.state
|
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)
|
_LOGGER.debug('self._state=%s', self._state)
|
||||||
if self.type == SENSOR_TYPE_STATUS:
|
if self.type == SENSOR_TYPE_STATUS:
|
||||||
if self._state['state'] == 1:
|
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/
|
https://home-assistant.io/components/switch.neato/
|
||||||
"""
|
"""
|
||||||
import logging
|
import logging
|
||||||
|
import requests
|
||||||
from homeassistant.const import STATE_OFF, STATE_ON
|
from homeassistant.const import STATE_OFF, STATE_ON
|
||||||
from homeassistant.helpers.entity import ToggleEntity
|
from homeassistant.helpers.entity import ToggleEntity
|
||||||
from homeassistant.components.neato import NEATO_ROBOTS, NEATO_LOGIN
|
from homeassistant.components.neato import NEATO_ROBOTS, NEATO_LOGIN
|
||||||
@ -53,6 +53,11 @@ class NeatoConnectedSwitch(ToggleEntity):
|
|||||||
self.neato.update_robots()
|
self.neato.update_robots()
|
||||||
if not self._state:
|
if not self._state:
|
||||||
return
|
return
|
||||||
|
try:
|
||||||
|
self._state = self.robot.state
|
||||||
|
except requests.exceptions.HTTPError:
|
||||||
|
self._state = None
|
||||||
|
return
|
||||||
self._state = self.robot.state
|
self._state = self.robot.state
|
||||||
_LOGGER.debug('self._state=%s', self._state)
|
_LOGGER.debug('self._state=%s', self._state)
|
||||||
if self.type == SWITCH_TYPE_CLEAN:
|
if self.type == SWITCH_TYPE_CLEAN:
|
||||||
|
Loading…
x
Reference in New Issue
Block a user