mirror of
https://github.com/home-assistant/core.git
synced 2025-07-16 17:57:11 +00:00
Don't block HA startup while set up legacy Ecovacs bot (#122732)
wait for connection in background
This commit is contained in:
parent
5f5dcec0b9
commit
686598b6b3
@ -1,5 +1,6 @@
|
|||||||
"""Support for Ecovacs Deebot vacuums."""
|
"""Support for Ecovacs Deebot vacuums."""
|
||||||
|
|
||||||
|
from sucks import VacBot
|
||||||
import voluptuous as vol
|
import voluptuous as vol
|
||||||
|
|
||||||
from homeassistant.config_entries import SOURCE_IMPORT, ConfigEntry
|
from homeassistant.config_entries import SOURCE_IMPORT, ConfigEntry
|
||||||
@ -61,6 +62,16 @@ async def async_setup_entry(hass: HomeAssistant, entry: EcovacsConfigEntry) -> b
|
|||||||
|
|
||||||
entry.async_on_unload(on_unload)
|
entry.async_on_unload(on_unload)
|
||||||
entry.runtime_data = controller
|
entry.runtime_data = controller
|
||||||
|
|
||||||
|
async def _async_wait_connect(device: VacBot) -> None:
|
||||||
|
await hass.async_add_executor_job(device.connect_and_wait_until_ready)
|
||||||
|
|
||||||
|
for device in controller.legacy_devices:
|
||||||
|
entry.async_create_background_task(
|
||||||
|
hass=hass,
|
||||||
|
target=_async_wait_connect(device),
|
||||||
|
name=f"{entry.title}_wait_connect_{device.vacuum['did']}",
|
||||||
|
)
|
||||||
await hass.config_entries.async_forward_entry_setups(entry, PLATFORMS)
|
await hass.config_entries.async_forward_entry_setups(entry, PLATFORMS)
|
||||||
return True
|
return True
|
||||||
|
|
||||||
|
@ -56,9 +56,9 @@ async def async_setup_entry(
|
|||||||
for device in controller.devices
|
for device in controller.devices
|
||||||
if device.capabilities.device_type is DeviceType.VACUUM
|
if device.capabilities.device_type is DeviceType.VACUUM
|
||||||
]
|
]
|
||||||
for device in controller.legacy_devices:
|
vacuums.extend(
|
||||||
await hass.async_add_executor_job(device.connect_and_wait_until_ready)
|
[EcovacsLegacyVacuum(device) for device in controller.legacy_devices]
|
||||||
vacuums.append(EcovacsLegacyVacuum(device))
|
)
|
||||||
_LOGGER.debug("Adding Ecovacs Vacuums to Home Assistant: %s", vacuums)
|
_LOGGER.debug("Adding Ecovacs Vacuums to Home Assistant: %s", vacuums)
|
||||||
async_add_entities(vacuums)
|
async_add_entities(vacuums)
|
||||||
|
|
||||||
@ -142,6 +142,11 @@ class EcovacsLegacyVacuum(EcovacsLegacyEntity, StateVacuumEntity):
|
|||||||
|
|
||||||
return None
|
return None
|
||||||
|
|
||||||
|
@property
|
||||||
|
def available(self) -> bool:
|
||||||
|
"""Return True if the vacuum is available."""
|
||||||
|
return super().available and self.state is not None
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def battery_level(self) -> int | None:
|
def battery_level(self) -> int | None:
|
||||||
"""Return the battery level of the vacuum cleaner."""
|
"""Return the battery level of the vacuum cleaner."""
|
||||||
|
Loading…
x
Reference in New Issue
Block a user