mirror of
https://github.com/home-assistant/core.git
synced 2025-07-23 13:17:32 +00:00
Handle exceptions to prevent disconnect when esphome state subscription raises (#93723)
This commit is contained in:
parent
a547181984
commit
9443ca89bc
@ -266,8 +266,14 @@ class RuntimeEntryData:
|
||||
)
|
||||
stale_state.discard(subscription_key)
|
||||
current_state_by_type[key] = state
|
||||
if subscription_key in self.state_subscriptions:
|
||||
self.state_subscriptions[subscription_key]()
|
||||
if subscription := self.state_subscriptions.get(subscription_key):
|
||||
try:
|
||||
subscription()
|
||||
except Exception as ex: # pylint: disable=broad-except
|
||||
# If we allow this exception to raise it will
|
||||
# make it all the way to data_received in aioesphomeapi
|
||||
# which will cause the connection to be closed.
|
||||
_LOGGER.exception("Error while calling subscription: %s", ex)
|
||||
|
||||
@callback
|
||||
def async_update_device_state(self, hass: HomeAssistant) -> None:
|
||||
|
Loading…
x
Reference in New Issue
Block a user