diff --git a/custom_components/zha_toolkit/__init__.py b/custom_components/zha_toolkit/__init__.py index ecaf9e1..fc30244 100644 --- a/custom_components/zha_toolkit/__init__.py +++ b/custom_components/zha_toolkit/__init__.py @@ -7,6 +7,7 @@ from homeassistant.components.zha.core.gateway import ZHAGateway from homeassistant.util import dt as dt_util from zigpy import types as t +from zigpy.exceptions import DeliveryError from . import params as PARDEFS from . import utils as u @@ -815,10 +816,13 @@ async def toolkit_service(service): if handler_exception is not None: LOGGER.error( "Exception '%s' for service call with data '%r'", - params[p.EVT_DONE], + handler_exception, event_data, ) - raise handler_exception + if params[p.FAIL_EXCEPTION] or not isinstance( + handler_exception, DeliveryError + ): + raise handler_exception if not event_data["success"] and params[p.FAIL_EXCEPTION]: raise Exception("Success expected, but failed")