Store runtime data in entry in Ecovacs (#116445)

This commit is contained in:
Robert Resch 2024-04-30 22:44:56 +02:00 committed by GitHub
parent 2e9b1916c0
commit 1641df18ce
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
15 changed files with 79 additions and 80 deletions

View file

@ -42,7 +42,7 @@ class EcovacsController:
"""Initialize controller."""
self._hass = hass
self._devices: list[Device] = []
self.legacy_devices: list[VacBot] = []
self._legacy_devices: list[VacBot] = []
rest_url = config.get(CONF_OVERRIDE_REST_URL)
self._device_id = get_client_device_id(hass, rest_url is not None)
country = config[CONF_COUNTRY]
@ -101,7 +101,7 @@ class EcovacsController:
self._continent,
monitor=True,
)
self.legacy_devices.append(bot)
self._legacy_devices.append(bot)
except InvalidAuthenticationError as ex:
raise ConfigEntryError("Invalid credentials") from ex
except DeebotError as ex:
@ -113,7 +113,7 @@ class EcovacsController:
"""Disconnect controller."""
for device in self._devices:
await device.teardown()
for legacy_device in self.legacy_devices:
for legacy_device in self._legacy_devices:
await self._hass.async_add_executor_job(legacy_device.disconnect)
await self._mqtt.disconnect()
await self._authenticator.teardown()
@ -124,3 +124,8 @@ class EcovacsController:
for device in self._devices:
if isinstance(device.capabilities, capability):
yield device
@property
def legacy_devices(self) -> list[VacBot]:
"""Return legacy devices."""
return self._legacy_devices