mirror of
https://github.com/home-assistant/core.git
synced 2025-07-19 11:17:21 +00:00
Add exception handling to ADS shutdown (#19682)
* Added exception handling to ADS shutdown * corrected whitespaces * deleted blank line
This commit is contained in:
parent
6b18b92bdd
commit
b79057348d
@ -125,16 +125,23 @@ class AdsHub:
|
|||||||
|
|
||||||
def shutdown(self, *args, **kwargs):
|
def shutdown(self, *args, **kwargs):
|
||||||
"""Shutdown ADS connection."""
|
"""Shutdown ADS connection."""
|
||||||
|
import pyads
|
||||||
_LOGGER.debug("Shutting down ADS")
|
_LOGGER.debug("Shutting down ADS")
|
||||||
for notification_item in self._notification_items.values():
|
for notification_item in self._notification_items.values():
|
||||||
self._client.del_device_notification(
|
|
||||||
notification_item.hnotify,
|
|
||||||
notification_item.huser
|
|
||||||
)
|
|
||||||
_LOGGER.debug(
|
_LOGGER.debug(
|
||||||
"Deleting device notification %d, %d",
|
"Deleting device notification %d, %d",
|
||||||
notification_item.hnotify, notification_item.huser)
|
notification_item.hnotify, notification_item.huser)
|
||||||
self._client.close()
|
try:
|
||||||
|
self._client.del_device_notification(
|
||||||
|
notification_item.hnotify,
|
||||||
|
notification_item.huser
|
||||||
|
)
|
||||||
|
except pyads.ADSError as err:
|
||||||
|
_LOGGER.error(err)
|
||||||
|
try:
|
||||||
|
self._client.close()
|
||||||
|
except pyads.ADSError as err:
|
||||||
|
_LOGGER.error(err)
|
||||||
|
|
||||||
def register_device(self, device):
|
def register_device(self, device):
|
||||||
"""Register a new device."""
|
"""Register a new device."""
|
||||||
|
Loading…
x
Reference in New Issue
Block a user