1 """A wrapper 'hub' for the Litter-Robot API."""
3 from __future__
import annotations
5 from collections.abc
import Generator, Mapping
6 from datetime
import timedelta
10 from pylitterbot
import Account, FeederRobot, LitterRobot
11 from pylitterbot.exceptions
import LitterRobotException, LitterRobotLoginException
19 from .const
import DOMAIN
21 _LOGGER = logging.getLogger(__name__)
23 UPDATE_INTERVAL_SECONDS = 60 * 5
27 """A Litter-Robot hub wrapper class."""
29 def __init__(self, hass: HomeAssistant, data: Mapping[str, Any]) ->
None:
30 """Initialize the Litter-Robot hub."""
34 async
def _async_update_data() -> bool:
35 """Update all device states from the Litter-Robot API."""
36 await self.
accountaccount.refresh_robots()
43 update_method=_async_update_data,
44 update_interval=
timedelta(seconds=UPDATE_INTERVAL_SECONDS),
48 self, load_robots: bool =
False, subscribe_for_updates: bool =
False
50 """Login to Litter-Robot."""
52 await self.
accountaccount.connect(
53 username=self.
_data_data[CONF_USERNAME],
54 password=self.
_data_data[CONF_PASSWORD],
55 load_robots=load_robots,
56 subscribe_for_updates=subscribe_for_updates,
58 except LitterRobotLoginException
as ex:
60 except LitterRobotException
as ex:
64 """Get Litter-Robots from the account."""
66 robot
for robot
in self.
accountaccount.robots
if isinstance(robot, LitterRobot)
70 """Get Feeder-Robots from the account."""
72 robot
for robot
in self.
accountaccount.robots
if isinstance(robot, FeederRobot)
None __init__(self, HomeAssistant hass, Mapping[str, Any] data)
Generator[LitterRobot] litter_robots(self)
None login(self, bool load_robots=False, bool subscribe_for_updates=False)
Generator[FeederRobot] feeder_robots(self)
aiohttp.ClientSession async_get_clientsession(HomeAssistant hass, bool verify_ssl=True, socket.AddressFamily family=socket.AF_UNSPEC, ssl_util.SSLCipherList ssl_cipher=ssl_util.SSLCipherList.PYTHON_DEFAULT)