Disconnect yale access locks at the stop event (#93192)

pull/93199/head^2
J. Nick Koston 2023-05-17 06:25:28 -05:00 committed by GitHub
parent 7cdd6b4cbc
commit af1bac8745
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
5 changed files with 19 additions and 7 deletions

View File

@ -28,5 +28,5 @@
"documentation": "https://www.home-assistant.io/integrations/august",
"iot_class": "cloud_push",
"loggers": ["pubnub", "yalexs"],
"requirements": ["yalexs==1.3.3", "yalexs-ble==2.1.16"]
"requirements": ["yalexs==1.3.3", "yalexs-ble==2.1.17"]
}

View File

@ -15,8 +15,8 @@ from yalexs_ble import (
from homeassistant.components import bluetooth
from homeassistant.config_entries import ConfigEntry
from homeassistant.const import CONF_ADDRESS, Platform
from homeassistant.core import HomeAssistant, callback
from homeassistant.const import CONF_ADDRESS, EVENT_HOMEASSISTANT_STOP, Platform
from homeassistant.core import CALLBACK_TYPE, Event, HomeAssistant, callback
from homeassistant.exceptions import ConfigEntryAuthFailed, ConfigEntryNotReady
from .const import CONF_KEY, CONF_LOCAL_NAME, CONF_SLOT, DEVICE_TIMEOUT, DOMAIN
@ -45,7 +45,16 @@ async def async_setup_entry(hass: HomeAssistant, entry: ConfigEntry) -> bool:
"""Update from a ble callback."""
push_lock.update_advertisement(service_info.device, service_info.advertisement)
entry.async_on_unload(await push_lock.start())
shutdown_callback: CALLBACK_TYPE | None = await push_lock.start()
@callback
def _async_shutdown(event: Event | None = None) -> None:
nonlocal shutdown_callback
if shutdown_callback:
shutdown_callback()
shutdown_callback = None
entry.async_on_unload(_async_shutdown)
# We may already have the advertisement, so check for it.
if service_info := async_find_existing_service_info(hass, local_name, address):
@ -97,6 +106,9 @@ async def async_setup_entry(hass: HomeAssistant, entry: ConfigEntry) -> bool:
entry.async_on_unload(push_lock.register_callback(_async_state_changed))
await hass.config_entries.async_forward_entry_setups(entry, PLATFORMS)
entry.async_on_unload(entry.add_update_listener(_async_update_listener))
entry.async_on_unload(
hass.bus.async_listen_once(EVENT_HOMEASSISTANT_STOP, _async_shutdown)
)
return True

View File

@ -12,5 +12,5 @@
"dependencies": ["bluetooth_adapters"],
"documentation": "https://www.home-assistant.io/integrations/yalexs_ble",
"iot_class": "local_push",
"requirements": ["yalexs-ble==2.1.16"]
"requirements": ["yalexs-ble==2.1.17"]
}

View File

@ -2691,7 +2691,7 @@ yalesmartalarmclient==0.3.9
# homeassistant.components.august
# homeassistant.components.yalexs_ble
yalexs-ble==2.1.16
yalexs-ble==2.1.17
# homeassistant.components.august
yalexs==1.3.3

View File

@ -1958,7 +1958,7 @@ yalesmartalarmclient==0.3.9
# homeassistant.components.august
# homeassistant.components.yalexs_ble
yalexs-ble==2.1.16
yalexs-ble==2.1.17
# homeassistant.components.august
yalexs==1.3.3