Add errors for no IP and no connection
This commit is contained in:
parent
edd93b1469
commit
711997cb13
|
|
@ -1,37 +1,38 @@
|
||||||
ERROR_MESSAGES = {
|
ERROR_MESSAGES = {
|
||||||
"IP_ADDRESS": "IP Address not set",
|
"IP_ADDRESS": "IP Address not set",
|
||||||
|
"CONNECTION_FAILED": "Connection to the vacuum failed",
|
||||||
"no_error": "None",
|
"no_error": "None",
|
||||||
1:"Error: Front bumper stuck",
|
1:"Front bumper stuck",
|
||||||
2:"Error: Wheel stuck",
|
2:"Wheel stuck",
|
||||||
3:"Error: Side brush",
|
3:"Side brush",
|
||||||
4:"Error: Rolling brush bar stuck",
|
4:"Rolling brush bar stuck",
|
||||||
5:"Error: Device trapped",
|
5:"Device trapped",
|
||||||
6:"Error: Device trapped",
|
6:"Device trapped",
|
||||||
7:"Error: Wheel suspended",
|
7:"Wheel suspended",
|
||||||
8:"Error: Low battery",
|
8:"Low battery",
|
||||||
9:"Error: Magnetic boundary",
|
9:"Magnetic boundary",
|
||||||
12:"Error: Right wall sensor",
|
12:"Right wall sensor",
|
||||||
13:"Error: Device tilted",
|
13:"Device tilted",
|
||||||
14:"Error: Insert dust collector",
|
14:"Insert dust collector",
|
||||||
17:"Error: Restricted area detected",
|
17:"Restricted area detected",
|
||||||
18:"Error: Laser cover stuck",
|
18:"Laser cover stuck",
|
||||||
19:"Error: Laser sesor stuck",
|
19:"Laser sesor stuck",
|
||||||
20:"Error: Laser sensor blocked",
|
20:"Laser sensor blocked",
|
||||||
21:"Error: Base blocked",
|
21:"Base blocked",
|
||||||
"S1":"Error: Battery",
|
"S1":"Battery",
|
||||||
"S2":"Error: Wheel Module",
|
"S2":"Wheel Module",
|
||||||
"S3":"Error: Side Brush",
|
"S3":"Side Brush",
|
||||||
"S4":"Error: Suction Fan",
|
"S4":"Suction Fan",
|
||||||
"S5":"Error: Rolling Brush",
|
"S5":"Rolling Brush",
|
||||||
"S8":"Error: Path Tracking Sensor",
|
"S8":"Path Tracking Sensor",
|
||||||
"Wheel_stuck":"Error: Wheel stuck",
|
"Wheel_stuck":"Wheel stuck",
|
||||||
"R_brush_stuck":"Error: Rolling brush stuck",
|
"R_brush_stuck":"Rolling brush stuck",
|
||||||
"Crash_bar_stuck":"Error: Front bumper stuck",
|
"Crash_bar_stuck":"Front bumper stuck",
|
||||||
"sensor_dirty":"Error: Sensor dirty",
|
"sensor_dirty":"Sensor dirty",
|
||||||
"N_enough_pow":"Error: Low battery",
|
"N_enough_pow":"Low battery",
|
||||||
"Stuck_5_min":"Error: Device trapped",
|
"Stuck_5_min":"Device trapped",
|
||||||
"Fan_stuck":"Error: Fan stuck",
|
"Fan_stuck":"Fan stuck",
|
||||||
"S_brush_stuck":"Error: Side brush stuck",
|
"S_brush_stuck":"Side brush stuck",
|
||||||
}
|
}
|
||||||
|
|
||||||
def getErrorMessage(code):
|
def getErrorMessage(code):
|
||||||
|
|
|
||||||
|
|
@ -677,6 +677,7 @@ class TuyaDevice:
|
||||||
try:
|
try:
|
||||||
sock.connect((self.host, self.port))
|
sock.connect((self.host, self.port))
|
||||||
except socket.timeout as e:
|
except socket.timeout as e:
|
||||||
|
self._dps["106"] = "CONNECTION_FAILED"
|
||||||
raise ConnectionTimeoutException("Connection timed out") from e
|
raise ConnectionTimeoutException("Connection timed out") from e
|
||||||
self.reader, self.writer = await asyncio.open_connection(sock=sock)
|
self.reader, self.writer = await asyncio.open_connection(sock=sock)
|
||||||
self._connected = True
|
self._connected = True
|
||||||
|
|
@ -740,6 +741,7 @@ class TuyaDevice:
|
||||||
response_data = await self.reader.readuntil(MAGIC_SUFFIX_BYTES)
|
response_data = await self.reader.readuntil(MAGIC_SUFFIX_BYTES)
|
||||||
except socket.error as e:
|
except socket.error as e:
|
||||||
_LOGGER.error("Connection to {} failed: {}".format(self, e))
|
_LOGGER.error("Connection to {} failed: {}".format(self, e))
|
||||||
|
self._dps["106"] = "CONNECTION_FAILED"
|
||||||
asyncio.ensure_future(self.async_disconnect())
|
asyncio.ensure_future(self.async_disconnect())
|
||||||
return
|
return
|
||||||
except asyncio.IncompleteReadError as e:
|
except asyncio.IncompleteReadError as e:
|
||||||
|
|
|
||||||
|
|
@ -201,7 +201,8 @@ class RoboVacEntity(StateVacuumEntity):
|
||||||
def extra_state_attributes(self) -> dict[str, Any]:
|
def extra_state_attributes(self) -> dict[str, Any]:
|
||||||
"""Return the device-specific state attributes of this vacuum."""
|
"""Return the device-specific state attributes of this vacuum."""
|
||||||
data: dict[str, Any] = {}
|
data: dict[str, Any] = {}
|
||||||
data[ATTR_ERROR] = getErrorMessage(self.error_code)
|
if type(self.error_code) is not None and self.error_code not in [0, "no_error"]:
|
||||||
|
data[ATTR_ERROR] = getErrorMessage(self.error_code)
|
||||||
|
|
||||||
if self.supported_features & VacuumEntityFeature.STATUS:
|
if self.supported_features & VacuumEntityFeature.STATUS:
|
||||||
data[ATTR_STATUS] = self.status
|
data[ATTR_STATUS] = self.status
|
||||||
|
|
@ -263,6 +264,7 @@ class RoboVacEntity(StateVacuumEntity):
|
||||||
"""Synchronise state from the vacuum."""
|
"""Synchronise state from the vacuum."""
|
||||||
self.async_write_ha_state()
|
self.async_write_ha_state()
|
||||||
if self.ip_address == "":
|
if self.ip_address == "":
|
||||||
|
self.error_code = "IP_ADDRESS"
|
||||||
return
|
return
|
||||||
await self.vacuum.async_get()
|
await self.vacuum.async_get()
|
||||||
self.tuyastatus = self.vacuum._dps
|
self.tuyastatus = self.vacuum._dps
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue