Move ESPHome disconnects to the close event (#113652)
This commit is contained in:
parent
412fd3dc05
commit
dbbd6fff01
1 changed files with 5 additions and 2 deletions
|
@ -30,7 +30,7 @@ from homeassistant.config_entries import ConfigEntry
|
||||||
from homeassistant.const import (
|
from homeassistant.const import (
|
||||||
ATTR_DEVICE_ID,
|
ATTR_DEVICE_ID,
|
||||||
CONF_MODE,
|
CONF_MODE,
|
||||||
EVENT_HOMEASSISTANT_STOP,
|
EVENT_HOMEASSISTANT_CLOSE,
|
||||||
EVENT_LOGGING_CHANGED,
|
EVENT_LOGGING_CHANGED,
|
||||||
)
|
)
|
||||||
from homeassistant.core import Event, HomeAssistant, ServiceCall, State, callback
|
from homeassistant.core import Event, HomeAssistant, ServiceCall, State, callback
|
||||||
|
@ -542,9 +542,12 @@ class ESPHomeManager:
|
||||||
# the callback twice when shutting down Home Assistant.
|
# the callback twice when shutting down Home Assistant.
|
||||||
# "Unable to remove unknown listener
|
# "Unable to remove unknown listener
|
||||||
# <function EventBus.async_listen_once.<locals>.onetime_listener>"
|
# <function EventBus.async_listen_once.<locals>.onetime_listener>"
|
||||||
|
# We only close the connection at the last possible moment
|
||||||
|
# when the CLOSE event is fired so anything using a Bluetooth
|
||||||
|
# proxy has a chance to shut down properly.
|
||||||
entry_data.cleanup_callbacks.append(
|
entry_data.cleanup_callbacks.append(
|
||||||
hass.bus.async_listen(
|
hass.bus.async_listen(
|
||||||
EVENT_HOMEASSISTANT_STOP, self.on_stop, run_immediately=True
|
EVENT_HOMEASSISTANT_CLOSE, self.on_stop, run_immediately=True
|
||||||
)
|
)
|
||||||
)
|
)
|
||||||
entry_data.cleanup_callbacks.append(
|
entry_data.cleanup_callbacks.append(
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue