async def connect(self) -> bool: """Connect to the Harmony Hub.""" _LOGGER.debug("%s: Connecting", self._name) callbacks = { "config_updated": self._config_updated, "connect": self._connected, "disconnect": self._disconnected, "new_activity_starting": self._activity_starting, "new_activity": self._activity_started, } self._client = HarmonyClient( ip_address=self._address, callbacks=ClientCallbackType(**callbacks) ) connected = False try: connected = await self._client.connect() except (asyncio.TimeoutError, aioexc.TimeOut) as err: await self._client.close() raise ConfigEntryNotReady( f"{self._name}: Connection timed-out to {self._address}:8088" ) from err except (ValueError, AttributeError) as err: await self._client.close() raise ConfigEntryNotReady( f"{self._name}: Error {err} while connected HUB at: {self._address}:8088" ) from err if not connected: await self._client.close() raise ConfigEntryNotReady( f"{self._name}: Unable to connect to HUB at: {self._address}:8088" )
def __init__(self, name, host, port, activity, out_path, delay_secs): """Initialize HarmonyRemote class.""" from aioharmony.harmonyapi import ( HarmonyAPI as HarmonyClient, ClientCallbackType ) _LOGGER.debug("%s: Device init started", name) self._name = name self.host = host self.port = port self._state = None self._current_activity = None self._default_activity = activity self._client = HarmonyClient( ip_address=host, callbacks=ClientCallbackType( new_activity=self.new_activity, config_updated=self.new_config, connect=self.got_connected, disconnect=self.got_disconnected ) ) self._config_path = out_path self._delay_secs = delay_secs self._available = False
def __init__(self, name, host, port, activity, out_path, delay_secs): """Initialize HarmonyRemote class.""" self._name = name self.host = host self.port = port self._state = None self._current_activity = None self._default_activity = activity self._client = HarmonyClient(ip_address=host) self._config_path = out_path self._delay_secs = delay_secs self._available = False
def __init__(self, name, unique_id, host, activity, out_path, delay_secs): """Initialize HarmonyRemote class.""" self._name = name self.host = host self._state = None self._current_activity = None self.default_activity = activity self._client = HarmonyClient(ip_address=host) self._config_path = out_path self.delay_secs = delay_secs self._available = False self._unique_id = unique_id self._undo_dispatch_subscription = None
def __init__(self, name, unique_id, host, activity, out_path, delay_secs): """Initialize HarmonyRemote class.""" self._name = name self.host = host self._state = None self._current_activity = ACTIVITY_POWER_OFF self.default_activity = activity self._activity_starting = None self._is_initial_update = True self._client = HarmonyClient(ip_address=host) self._config_path = out_path self.delay_secs = delay_secs self._available = False self._unique_id = unique_id self._last_activity = None
def __init__(self, hass, address: str, name: str, unique_id: str): """Initialize a data object.""" super().__init__(hass) self._name = name self._unique_id = unique_id self._available = False callbacks = { "config_updated": self._config_updated, "connect": self._connected, "disconnect": self._disconnected, "new_activity_starting": self._activity_starting, "new_activity": self._activity_started, } self._client = HarmonyClient(ip_address=address, callbacks=ClientCallbackType(**callbacks))
async def connect(self) -> bool: """Connect to the Harmony Hub.""" _LOGGER.debug("%s: Connecting", self._name) callbacks = { "config_updated": self._config_updated, "connect": self._connected, "disconnect": self._disconnected, "new_activity_starting": self._activity_starting, "new_activity": self._activity_started, } self._client = HarmonyClient(ip_address=self._address, callbacks=ClientCallbackType(**callbacks)) try: if not await self._client.connect(): _LOGGER.warning("%s: Unable to connect to HUB", self._name) await self._client.close() return False except aioexc.TimeOut: _LOGGER.warning("%s: Connection timed-out", self._name) return False return True