mirror of
https://github.com/home-assistant/core.git
synced 2025-07-23 13:17:32 +00:00
Improve Neato error logging by including device name (#37865)
This commit is contained in:
parent
d37a5cdde5
commit
f24fe9c246
@ -60,18 +60,20 @@ class NeatoCleaningMap(Camera):
|
|||||||
def update(self):
|
def update(self):
|
||||||
"""Check the contents of the map list."""
|
"""Check the contents of the map list."""
|
||||||
if self.neato is None:
|
if self.neato is None:
|
||||||
_LOGGER.error("Error while updating camera")
|
_LOGGER.error("Error while updating '%s'", self.entity_id)
|
||||||
self._image = None
|
self._image = None
|
||||||
self._image_url = None
|
self._image_url = None
|
||||||
self._available = False
|
self._available = False
|
||||||
return
|
return
|
||||||
|
|
||||||
_LOGGER.debug("Running camera update")
|
_LOGGER.debug("Running camera update for '%s'", self.entity_id)
|
||||||
try:
|
try:
|
||||||
self.neato.update_robots()
|
self.neato.update_robots()
|
||||||
except NeatoRobotException as ex:
|
except NeatoRobotException as ex:
|
||||||
if self._available: # Print only once when available
|
if self._available: # Print only once when available
|
||||||
_LOGGER.error("Neato camera connection error: %s", ex)
|
_LOGGER.error(
|
||||||
|
"Neato camera connection error for '%s': %s", self.entity_id, ex
|
||||||
|
)
|
||||||
self._image = None
|
self._image = None
|
||||||
self._image_url = None
|
self._image_url = None
|
||||||
self._available = False
|
self._available = False
|
||||||
@ -81,14 +83,18 @@ class NeatoCleaningMap(Camera):
|
|||||||
map_data = self._mapdata[self._robot_serial]["maps"][0]
|
map_data = self._mapdata[self._robot_serial]["maps"][0]
|
||||||
image_url = map_data["url"]
|
image_url = map_data["url"]
|
||||||
if image_url == self._image_url:
|
if image_url == self._image_url:
|
||||||
_LOGGER.debug("The map image_url is the same as old")
|
_LOGGER.debug(
|
||||||
|
"The map image_url for '%s' is the same as old", self.entity_id
|
||||||
|
)
|
||||||
return
|
return
|
||||||
|
|
||||||
try:
|
try:
|
||||||
image = self.neato.download_map(image_url)
|
image = self.neato.download_map(image_url)
|
||||||
except NeatoRobotException as ex:
|
except NeatoRobotException as ex:
|
||||||
if self._available: # Print only once when available
|
if self._available: # Print only once when available
|
||||||
_LOGGER.error("Neato camera connection error: %s", ex)
|
_LOGGER.error(
|
||||||
|
"Neato camera connection error for '%s': %s", self.entity_id, ex
|
||||||
|
)
|
||||||
self._image = None
|
self._image = None
|
||||||
self._image_url = None
|
self._image_url = None
|
||||||
self._available = False
|
self._available = False
|
||||||
|
@ -48,7 +48,9 @@ class NeatoSensor(Entity):
|
|||||||
self._state = self.robot.state
|
self._state = self.robot.state
|
||||||
except NeatoRobotException as ex:
|
except NeatoRobotException as ex:
|
||||||
if self._available:
|
if self._available:
|
||||||
_LOGGER.error("Neato sensor connection error: %s", ex)
|
_LOGGER.error(
|
||||||
|
"Neato sensor connection error for '%s': %s", self.entity_id, ex
|
||||||
|
)
|
||||||
self._state = None
|
self._state = None
|
||||||
self._available = False
|
self._available = False
|
||||||
return
|
return
|
||||||
|
@ -49,12 +49,14 @@ class NeatoConnectedSwitch(ToggleEntity):
|
|||||||
|
|
||||||
def update(self):
|
def update(self):
|
||||||
"""Update the states of Neato switches."""
|
"""Update the states of Neato switches."""
|
||||||
_LOGGER.debug("Running switch update")
|
_LOGGER.debug("Running Neato switch update for '%s'", self.entity_id)
|
||||||
try:
|
try:
|
||||||
self._state = self.robot.state
|
self._state = self.robot.state
|
||||||
except NeatoRobotException as ex:
|
except NeatoRobotException as ex:
|
||||||
if self._available: # Print only once when available
|
if self._available: # Print only once when available
|
||||||
_LOGGER.error("Neato switch connection error: %s", ex)
|
_LOGGER.error(
|
||||||
|
"Neato switch connection error for '%s': %s", self.entity_id, ex
|
||||||
|
)
|
||||||
self._state = None
|
self._state = None
|
||||||
self._available = False
|
self._available = False
|
||||||
return
|
return
|
||||||
@ -67,7 +69,9 @@ class NeatoConnectedSwitch(ToggleEntity):
|
|||||||
self._schedule_state = STATE_ON
|
self._schedule_state = STATE_ON
|
||||||
else:
|
else:
|
||||||
self._schedule_state = STATE_OFF
|
self._schedule_state = STATE_OFF
|
||||||
_LOGGER.debug("Schedule state: %s", self._schedule_state)
|
_LOGGER.debug(
|
||||||
|
"Schedule state for '%s': %s", self.entity_id, self._schedule_state
|
||||||
|
)
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def name(self):
|
def name(self):
|
||||||
@ -103,7 +107,9 @@ class NeatoConnectedSwitch(ToggleEntity):
|
|||||||
try:
|
try:
|
||||||
self.robot.enable_schedule()
|
self.robot.enable_schedule()
|
||||||
except NeatoRobotException as ex:
|
except NeatoRobotException as ex:
|
||||||
_LOGGER.error("Neato switch connection error: %s", ex)
|
_LOGGER.error(
|
||||||
|
"Neato switch connection error '%s': %s", self.entity_id, ex
|
||||||
|
)
|
||||||
|
|
||||||
def turn_off(self, **kwargs):
|
def turn_off(self, **kwargs):
|
||||||
"""Turn the switch off."""
|
"""Turn the switch off."""
|
||||||
@ -111,4 +117,6 @@ class NeatoConnectedSwitch(ToggleEntity):
|
|||||||
try:
|
try:
|
||||||
self.robot.disable_schedule()
|
self.robot.disable_schedule()
|
||||||
except NeatoRobotException as ex:
|
except NeatoRobotException as ex:
|
||||||
_LOGGER.error("Neato switch connection error: %s", ex)
|
_LOGGER.error(
|
||||||
|
"Neato switch connection error '%s': %s", self.entity_id, ex
|
||||||
|
)
|
||||||
|
@ -157,18 +157,20 @@ class NeatoConnectedVacuum(StateVacuumEntity):
|
|||||||
|
|
||||||
def update(self):
|
def update(self):
|
||||||
"""Update the states of Neato Vacuums."""
|
"""Update the states of Neato Vacuums."""
|
||||||
_LOGGER.debug("Running Neato Vacuums update")
|
_LOGGER.debug("Running Neato Vacuums update for '%s'", self.entity_id)
|
||||||
try:
|
try:
|
||||||
if self._robot_stats is None:
|
if self._robot_stats is None:
|
||||||
self._robot_stats = self.robot.get_general_info().json().get("data")
|
self._robot_stats = self.robot.get_general_info().json().get("data")
|
||||||
except NeatoRobotException:
|
except NeatoRobotException:
|
||||||
_LOGGER.warning("Couldn't fetch robot information of %s", self._name)
|
_LOGGER.warning("Couldn't fetch robot information of %s", self.entity_id)
|
||||||
|
|
||||||
try:
|
try:
|
||||||
self._state = self.robot.state
|
self._state = self.robot.state
|
||||||
except NeatoRobotException as ex:
|
except NeatoRobotException as ex:
|
||||||
if self._available: # print only once when available
|
if self._available: # print only once when available
|
||||||
_LOGGER.error("Neato vacuum connection error: %s", ex)
|
_LOGGER.error(
|
||||||
|
"Neato vacuum connection error for '%s': %s", self.entity_id, ex
|
||||||
|
)
|
||||||
self._state = None
|
self._state = None
|
||||||
self._available = False
|
self._available = False
|
||||||
return
|
return
|
||||||
@ -241,25 +243,31 @@ class NeatoConnectedVacuum(StateVacuumEntity):
|
|||||||
and self._robot_maps[self._robot_serial]
|
and self._robot_maps[self._robot_serial]
|
||||||
):
|
):
|
||||||
allmaps = self._robot_maps[self._robot_serial]
|
allmaps = self._robot_maps[self._robot_serial]
|
||||||
_LOGGER.debug("Found the following maps for '%s': %s", self._name, allmaps)
|
_LOGGER.debug(
|
||||||
|
"Found the following maps for '%s': %s", self.entity_id, allmaps
|
||||||
|
)
|
||||||
self._robot_boundaries = [] # Reset boundaries before refreshing boundaries
|
self._robot_boundaries = [] # Reset boundaries before refreshing boundaries
|
||||||
for maps in allmaps:
|
for maps in allmaps:
|
||||||
try:
|
try:
|
||||||
robot_boundaries = self.robot.get_map_boundaries(maps["id"]).json()
|
robot_boundaries = self.robot.get_map_boundaries(maps["id"]).json()
|
||||||
except NeatoRobotException as ex:
|
except NeatoRobotException as ex:
|
||||||
_LOGGER.error("Could not fetch map boundaries: %s", ex)
|
_LOGGER.error(
|
||||||
|
"Could not fetch map boundaries for '%s': %s",
|
||||||
|
self.entity_id,
|
||||||
|
ex,
|
||||||
|
)
|
||||||
return
|
return
|
||||||
|
|
||||||
_LOGGER.debug(
|
_LOGGER.debug(
|
||||||
"Boundaries for robot '%s' in map '%s': %s",
|
"Boundaries for robot '%s' in map '%s': %s",
|
||||||
self._name,
|
self.entity_id,
|
||||||
maps["name"],
|
maps["name"],
|
||||||
robot_boundaries,
|
robot_boundaries,
|
||||||
)
|
)
|
||||||
self._robot_boundaries += robot_boundaries["data"]["boundaries"]
|
self._robot_boundaries += robot_boundaries["data"]["boundaries"]
|
||||||
_LOGGER.debug(
|
_LOGGER.debug(
|
||||||
"List of boundaries for '%s': %s",
|
"List of boundaries for '%s': %s",
|
||||||
self._name,
|
self.entity_id,
|
||||||
self._robot_boundaries,
|
self._robot_boundaries,
|
||||||
)
|
)
|
||||||
|
|
||||||
@ -346,14 +354,18 @@ class NeatoConnectedVacuum(StateVacuumEntity):
|
|||||||
elif self._state["state"] == 3:
|
elif self._state["state"] == 3:
|
||||||
self.robot.resume_cleaning()
|
self.robot.resume_cleaning()
|
||||||
except NeatoRobotException as ex:
|
except NeatoRobotException as ex:
|
||||||
_LOGGER.error("Neato vacuum connection error: %s", ex)
|
_LOGGER.error(
|
||||||
|
"Neato vacuum connection error for '%s': %s", self.entity_id, ex
|
||||||
|
)
|
||||||
|
|
||||||
def pause(self):
|
def pause(self):
|
||||||
"""Pause the vacuum."""
|
"""Pause the vacuum."""
|
||||||
try:
|
try:
|
||||||
self.robot.pause_cleaning()
|
self.robot.pause_cleaning()
|
||||||
except NeatoRobotException as ex:
|
except NeatoRobotException as ex:
|
||||||
_LOGGER.error("Neato vacuum connection error: %s", ex)
|
_LOGGER.error(
|
||||||
|
"Neato vacuum connection error for '%s': %s", self.entity_id, ex
|
||||||
|
)
|
||||||
|
|
||||||
def return_to_base(self, **kwargs):
|
def return_to_base(self, **kwargs):
|
||||||
"""Set the vacuum cleaner to return to the dock."""
|
"""Set the vacuum cleaner to return to the dock."""
|
||||||
@ -363,28 +375,36 @@ class NeatoConnectedVacuum(StateVacuumEntity):
|
|||||||
self._clean_state = STATE_RETURNING
|
self._clean_state = STATE_RETURNING
|
||||||
self.robot.send_to_base()
|
self.robot.send_to_base()
|
||||||
except NeatoRobotException as ex:
|
except NeatoRobotException as ex:
|
||||||
_LOGGER.error("Neato vacuum connection error: %s", ex)
|
_LOGGER.error(
|
||||||
|
"Neato vacuum connection error for '%s': %s", self.entity_id, ex
|
||||||
|
)
|
||||||
|
|
||||||
def stop(self, **kwargs):
|
def stop(self, **kwargs):
|
||||||
"""Stop the vacuum cleaner."""
|
"""Stop the vacuum cleaner."""
|
||||||
try:
|
try:
|
||||||
self.robot.stop_cleaning()
|
self.robot.stop_cleaning()
|
||||||
except NeatoRobotException as ex:
|
except NeatoRobotException as ex:
|
||||||
_LOGGER.error("Neato vacuum connection error: %s", ex)
|
_LOGGER.error(
|
||||||
|
"Neato vacuum connection error for '%s': %s", self.entity_id, ex
|
||||||
|
)
|
||||||
|
|
||||||
def locate(self, **kwargs):
|
def locate(self, **kwargs):
|
||||||
"""Locate the robot by making it emit a sound."""
|
"""Locate the robot by making it emit a sound."""
|
||||||
try:
|
try:
|
||||||
self.robot.locate()
|
self.robot.locate()
|
||||||
except NeatoRobotException as ex:
|
except NeatoRobotException as ex:
|
||||||
_LOGGER.error("Neato vacuum connection error: %s", ex)
|
_LOGGER.error(
|
||||||
|
"Neato vacuum connection error for '%s': %s", self.entity_id, ex
|
||||||
|
)
|
||||||
|
|
||||||
def clean_spot(self, **kwargs):
|
def clean_spot(self, **kwargs):
|
||||||
"""Run a spot cleaning starting from the base."""
|
"""Run a spot cleaning starting from the base."""
|
||||||
try:
|
try:
|
||||||
self.robot.start_spot_cleaning()
|
self.robot.start_spot_cleaning()
|
||||||
except NeatoRobotException as ex:
|
except NeatoRobotException as ex:
|
||||||
_LOGGER.error("Neato vacuum connection error: %s", ex)
|
_LOGGER.error(
|
||||||
|
"Neato vacuum connection error for '%s': %s", self.entity_id, ex
|
||||||
|
)
|
||||||
|
|
||||||
def neato_custom_cleaning(self, mode, navigation, category, zone=None, **kwargs):
|
def neato_custom_cleaning(self, mode, navigation, category, zone=None, **kwargs):
|
||||||
"""Zone cleaning service call."""
|
"""Zone cleaning service call."""
|
||||||
@ -395,7 +415,7 @@ class NeatoConnectedVacuum(StateVacuumEntity):
|
|||||||
boundary_id = boundary["id"]
|
boundary_id = boundary["id"]
|
||||||
if boundary_id is None:
|
if boundary_id is None:
|
||||||
_LOGGER.error(
|
_LOGGER.error(
|
||||||
"Zone '%s' was not found for the robot '%s'", zone, self._name
|
"Zone '%s' was not found for the robot '%s'", zone, self.entity_id
|
||||||
)
|
)
|
||||||
return
|
return
|
||||||
|
|
||||||
@ -403,4 +423,6 @@ class NeatoConnectedVacuum(StateVacuumEntity):
|
|||||||
try:
|
try:
|
||||||
self.robot.start_cleaning(mode, navigation, category, boundary_id)
|
self.robot.start_cleaning(mode, navigation, category, boundary_id)
|
||||||
except NeatoRobotException as ex:
|
except NeatoRobotException as ex:
|
||||||
_LOGGER.error("Neato vacuum connection error: %s", ex)
|
_LOGGER.error(
|
||||||
|
"Neato vacuum connection error for '%s': %s", self.entity_id, ex
|
||||||
|
)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user