mirror of
https://github.com/home-assistant/core.git
synced 2025-07-23 05:07:41 +00:00
Add missing await to HMIPC (#31415)
* Add missing await to HMIPC * use callback instead * Fix call, move callback to hap
This commit is contained in:
parent
bea7aae8cd
commit
03642d9029
@ -348,14 +348,9 @@ async def async_setup_entry(hass: HomeAssistantType, entry: ConfigEntry) -> bool
|
|||||||
if not await hap.async_setup():
|
if not await hap.async_setup():
|
||||||
return False
|
return False
|
||||||
|
|
||||||
async def async_reset_hap_connection():
|
|
||||||
"""Reset hmip hap connection."""
|
|
||||||
await hap.async_reset()
|
|
||||||
_LOGGER.debug("Reset connection to access point id %s", entry.unique_id)
|
|
||||||
|
|
||||||
# Register on HA stop event to gracefully shutdown HomematicIP Cloud connection
|
# Register on HA stop event to gracefully shutdown HomematicIP Cloud connection
|
||||||
hap.reset_connection_listener = hass.bus.async_listen_once(
|
hap.reset_connection_listener = hass.bus.async_listen_once(
|
||||||
EVENT_HOMEASSISTANT_STOP, async_reset_hap_connection()
|
EVENT_HOMEASSISTANT_STOP, hap.shutdown
|
||||||
)
|
)
|
||||||
|
|
||||||
# Register hap as device in registry.
|
# Register hap as device in registry.
|
||||||
|
@ -224,6 +224,17 @@ class HomematicipHAP:
|
|||||||
self.hmip_device_by_entity_id = {}
|
self.hmip_device_by_entity_id = {}
|
||||||
return True
|
return True
|
||||||
|
|
||||||
|
@callback
|
||||||
|
def shutdown(self, event) -> None:
|
||||||
|
"""Wrap the call to async_reset.
|
||||||
|
|
||||||
|
Used as an argument to EventBus.async_listen_once.
|
||||||
|
"""
|
||||||
|
self.hass.async_create_task(self.async_reset())
|
||||||
|
_LOGGER.debug(
|
||||||
|
"Reset connection to access point id %s", self.config_entry.unique_id
|
||||||
|
)
|
||||||
|
|
||||||
async def get_hap(
|
async def get_hap(
|
||||||
self, hass: HomeAssistantType, hapid: str, authtoken: str, name: str
|
self, hass: HomeAssistantType, hapid: str, authtoken: str, name: str
|
||||||
) -> AsyncHome:
|
) -> AsyncHome:
|
||||||
|
Loading…
x
Reference in New Issue
Block a user