async changes put back in to push for 1.7.0
This commit is contained in:
@@ -21,18 +21,20 @@ ATTR_ERROR = "error"
|
||||
ATTR_COMPONENT_PREFIX = "component_"
|
||||
|
||||
|
||||
def setup_platform(
|
||||
async def async_setup_platform(
|
||||
hass: HomeAssistant,
|
||||
config: ConfigType,
|
||||
add_entities: AddEntitiesCallback,
|
||||
async_add_entities: AddEntitiesCallback,
|
||||
discovery_info: DiscoveryInfoType | None = None,
|
||||
) -> None:
|
||||
"""Set up the Ecovacs vacuums."""
|
||||
vacuums = []
|
||||
for device in hass.data[ECOVACS_DEVICES]:
|
||||
devices: list[sucks.VacBot] = hass.data[ECOVACS_DEVICES]
|
||||
for device in devices:
|
||||
await hass.async_add_executor_job(device.connect_and_wait_until_ready)
|
||||
vacuums.append(EcovacsVacuum(device))
|
||||
_LOGGER.debug("Adding Ecovacs Vacuums to Home Assistant: %s", vacuums)
|
||||
add_entities(vacuums, True)
|
||||
async_add_entities(vacuums)
|
||||
|
||||
|
||||
class EcovacsVacuum(StateVacuumEntity):
|
||||
@@ -56,7 +58,7 @@ class EcovacsVacuum(StateVacuumEntity):
|
||||
def __init__(self, device: sucks.VacBot) -> None:
|
||||
"""Initialize the Ecovacs Vacuum."""
|
||||
self.device = device
|
||||
self.device.connect_and_wait_until_ready()
|
||||
|
||||
if self.device.vacuum.get("nick") is not None:
|
||||
self._attr_name = str(self.device.vacuum["nick"])
|
||||
else:
|
||||
@@ -64,7 +66,6 @@ class EcovacsVacuum(StateVacuumEntity):
|
||||
self._attr_name = str(format(self.device.vacuum["did"]))
|
||||
|
||||
self._error = None
|
||||
_LOGGER.debug("Vacuum initialized: %s", self.name)
|
||||
|
||||
async def async_added_to_hass(self) -> None:
|
||||
"""Set up the event listeners now that hass is ready."""
|
||||
|
||||
Reference in New Issue
Block a user