Fix autodiscovery IP key and add error message for unsupported model
This commit is contained in:
parent
7f344d38bf
commit
01024d8e56
|
|
@ -41,19 +41,14 @@ async def async_setup(hass, entry) -> bool:
|
||||||
return
|
return
|
||||||
|
|
||||||
hass_data = entry.data.copy()
|
hass_data = entry.data.copy()
|
||||||
if device["gwId"] in hass_data[CONF_VACS] and device.get(CONF_IP_ADDRESS) is not None:
|
if device["gwId"] in hass_data[CONF_VACS] and device.get("ip") is not None:
|
||||||
if (
|
if hass_data[CONF_VACS][device["gwId"]][CONF_IP_ADDRESS] != device["ip"]:
|
||||||
hass_data[CONF_VACS][device["gwId"]]["ip_address"]
|
hass_data[CONF_VACS][device["gwId"]][CONF_IP_ADDRESS] = device["ip"]
|
||||||
!= device[CONF_IP_ADDRESS]
|
|
||||||
):
|
|
||||||
hass_data[CONF_VACS][device["gwId"]]["ip_address"] = device[
|
|
||||||
CONF_IP_ADDRESS
|
|
||||||
]
|
|
||||||
hass.config_entries.async_update_entry(entry, data=hass_data)
|
hass.config_entries.async_update_entry(entry, data=hass_data)
|
||||||
await hass.config_entries.async_reload(entry.entry_id)
|
await hass.config_entries.async_reload(entry.entry_id)
|
||||||
_LOGGER.debug(
|
_LOGGER.debug(
|
||||||
"Updated ip address of {} to {}".format(
|
"Updated ip address of {} to {}".format(
|
||||||
device["gwId"], device[CONF_IP_ADDRESS]
|
device["gwId"], device["ip"]
|
||||||
)
|
)
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -1,6 +1,7 @@
|
||||||
ERROR_MESSAGES = {
|
ERROR_MESSAGES = {
|
||||||
"IP_ADDRESS": "IP Address not set",
|
"IP_ADDRESS": "IP Address not set",
|
||||||
"CONNECTION_FAILED": "Connection to the vacuum failed",
|
"CONNECTION_FAILED": "Connection to the vacuum failed",
|
||||||
|
"UNSUPPORTED_MODEL": "This model is not supported",
|
||||||
"no_error": "None",
|
"no_error": "None",
|
||||||
1:"Front bumper stuck",
|
1:"Front bumper stuck",
|
||||||
2:"Wheel stuck",
|
2:"Wheel stuck",
|
||||||
|
|
|
||||||
|
|
@ -58,7 +58,12 @@ from homeassistant.const import (
|
||||||
from .const import CONF_VACS, DOMAIN
|
from .const import CONF_VACS, DOMAIN
|
||||||
|
|
||||||
from .errors import getErrorMessage
|
from .errors import getErrorMessage
|
||||||
from .robovac import SUPPORTED_ROBOVAC_MODELS, RoboVac, RoboVacEntityFeature
|
from .robovac import (
|
||||||
|
SUPPORTED_ROBOVAC_MODELS,
|
||||||
|
ModelNotSupportedException,
|
||||||
|
RoboVac,
|
||||||
|
RoboVacEntityFeature,
|
||||||
|
)
|
||||||
|
|
||||||
from homeassistant.const import ATTR_BATTERY_LEVEL
|
from homeassistant.const import ATTR_BATTERY_LEVEL
|
||||||
|
|
||||||
|
|
@ -107,7 +112,6 @@ async def async_setup_entry(
|
||||||
for item in vacuums:
|
for item in vacuums:
|
||||||
item = vacuums[item]
|
item = vacuums[item]
|
||||||
entity = RoboVacEntity(item)
|
entity = RoboVacEntity(item)
|
||||||
await entity.vacuum.async_connect()
|
|
||||||
async_add_entities([entity], update_before_add=True)
|
async_add_entities([entity], update_before_add=True)
|
||||||
|
|
||||||
|
|
||||||
|
|
@ -249,14 +253,17 @@ class RoboVacEntity(StateVacuumEntity):
|
||||||
self._attr_ip_address = item[CONF_IP_ADDRESS]
|
self._attr_ip_address = item[CONF_IP_ADDRESS]
|
||||||
self._attr_access_token = item[CONF_ACCESS_TOKEN]
|
self._attr_access_token = item[CONF_ACCESS_TOKEN]
|
||||||
|
|
||||||
self.vacuum = RoboVac(
|
try:
|
||||||
device_id=self.unique_id,
|
self.vacuum = RoboVac(
|
||||||
host=self.ip_address,
|
device_id=self.unique_id,
|
||||||
local_key=self.access_token,
|
host=self.ip_address,
|
||||||
timeout=2,
|
local_key=self.access_token,
|
||||||
ping_interval=REFRESH_RATE,
|
timeout=2,
|
||||||
model_code=self.model_code[0:5],
|
ping_interval=REFRESH_RATE,
|
||||||
)
|
model_code=self.model_code[0:5],
|
||||||
|
)
|
||||||
|
except ModelNotSupportedException:
|
||||||
|
self.error_code = "UNSUPPORTED_MODEL"
|
||||||
|
|
||||||
self._attr_supported_features = self.vacuum.getHomeAssistantFeatures()
|
self._attr_supported_features = self.vacuum.getHomeAssistantFeatures()
|
||||||
self._attr_robovac_supported = self.vacuum.getRoboVacFeatures()
|
self._attr_robovac_supported = self.vacuum.getRoboVacFeatures()
|
||||||
|
|
@ -280,6 +287,9 @@ class RoboVacEntity(StateVacuumEntity):
|
||||||
|
|
||||||
async def async_update(self):
|
async def async_update(self):
|
||||||
"""Synchronise state from the vacuum."""
|
"""Synchronise state from the vacuum."""
|
||||||
|
if self.error_code == "UNSUPPORTED_MODEL":
|
||||||
|
return
|
||||||
|
|
||||||
if self.ip_address == "":
|
if self.ip_address == "":
|
||||||
self.error_code = "IP_ADDRESS"
|
self.error_code = "IP_ADDRESS"
|
||||||
return
|
return
|
||||||
|
|
|
||||||
|
|
@ -0,0 +1,5 @@
|
||||||
|
cryptography==41.0.3
|
||||||
|
homeassistant==2023.8.4
|
||||||
|
Requests==2.31.0
|
||||||
|
setuptools==68.0.0
|
||||||
|
voluptuous==0.13.1
|
||||||
Loading…
Reference in New Issue