2020-08-12 07:31:39 -06:00
|
|
|
"""Shark IQ robot vacuums."""
|
2020-07-21 08:29:36 -06:00
|
|
|
import logging
|
2020-08-12 07:31:39 -06:00
|
|
|
from typing import TYPE_CHECKING, Iterable
|
|
|
|
|
|
|
|
from .const import DOMAIN
|
2020-07-21 08:29:36 -06:00
|
|
|
from .sharkiq import SharkVacuumEntity
|
2020-08-12 07:31:39 -06:00
|
|
|
from .update_coordinator import SharkIqUpdateCoordinator
|
2020-07-21 08:29:36 -06:00
|
|
|
|
|
|
|
if TYPE_CHECKING:
|
2020-08-12 07:31:39 -06:00
|
|
|
from sharkiqpy import SharkIqVacuum
|
2020-07-21 08:29:36 -06:00
|
|
|
|
|
|
|
|
2020-08-12 07:31:39 -06:00
|
|
|
LOGGER = logging.getLogger(__name__)
|
2020-07-21 08:29:36 -06:00
|
|
|
|
|
|
|
|
|
|
|
async def async_setup_entry(hass, config_entry, async_add_entities):
|
|
|
|
"""Set up the Shark IQ vacuum cleaner."""
|
2020-08-12 07:31:39 -06:00
|
|
|
coordinator = hass.data[DOMAIN][
|
|
|
|
config_entry.entry_id
|
|
|
|
] # type: SharkIqUpdateCoordinator
|
|
|
|
devices = coordinator.shark_vacs.values() # type: Iterable[SharkIqVacuum]
|
|
|
|
device_names = [d.name for d in devices]
|
|
|
|
LOGGER.debug(
|
|
|
|
"Found %d Shark IQ device(s): %s",
|
|
|
|
len(device_names),
|
|
|
|
", ".join([d.name for d in devices]),
|
|
|
|
)
|
|
|
|
async_add_entities([SharkVacuumEntity(d, coordinator) for d in devices])
|