Fix harmony failing to switch activities when a switch is in progress (#47212)
Co-authored-by: Paulus Schoutsen <paulus@home-assistant.io>
This commit is contained in:
parent
cb99969845
commit
d02218ff30
2 changed files with 32 additions and 11 deletions
|
@ -22,17 +22,8 @@ class HarmonyData(HarmonySubscriberMixin):
|
|||
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)
|
||||
)
|
||||
self._client = None
|
||||
self._address = address
|
||||
|
||||
@property
|
||||
def activities(self):
|
||||
|
@ -105,6 +96,18 @@ class HarmonyData(HarmonySubscriberMixin):
|
|||
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)
|
||||
|
@ -113,6 +116,7 @@ class HarmonyData(HarmonySubscriberMixin):
|
|||
except aioexc.TimeOut:
|
||||
_LOGGER.warning("%s: Connection timed-out", self._name)
|
||||
return False
|
||||
|
||||
return True
|
||||
|
||||
async def shutdown(self):
|
||||
|
@ -159,10 +163,12 @@ class HarmonyData(HarmonySubscriberMixin):
|
|||
)
|
||||
return
|
||||
|
||||
await self.async_lock_start_activity()
|
||||
try:
|
||||
await self._client.start_activity(activity_id)
|
||||
except aioexc.TimeOut:
|
||||
_LOGGER.error("%s: Starting activity %s timed-out", self.name, activity)
|
||||
self.async_unlock_start_activity()
|
||||
|
||||
async def async_power_off(self):
|
||||
"""Start the PowerOff activity."""
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue