Improved logging
This commit is contained in:
@@ -177,7 +177,7 @@ class TuyaDevice(pytuya.TuyaListener, pytuya.ContextualLogger):
|
||||
|
||||
def async_connect(self):
|
||||
"""Connect to device if not already connected."""
|
||||
# self.debug("async_connect: %d %r %r", self._is_closing, self._connect_task, self._interface)
|
||||
# self.info("async_connect: %d %r %r", self._is_closing, self._connect_task, self._interface)
|
||||
if not self._is_closing and self._connect_task is None and not self._interface:
|
||||
self._connect_task = asyncio.create_task(self._make_connection())
|
||||
|
||||
@@ -195,9 +195,9 @@ class TuyaDevice(pytuya.TuyaListener, pytuya.ContextualLogger):
|
||||
self,
|
||||
)
|
||||
self._interface.add_dps_to_request(self.dps_to_request)
|
||||
except Exception: # pylint: disable=broad-except
|
||||
except Exception as ex: # pylint: disable=broad-except
|
||||
self.warning(
|
||||
f"Connect to {self._dev_config_entry[CONF_HOST]} failed attempting to connect"
|
||||
f"Failed to connect to {self._dev_config_entry[CONF_HOST]}: %s", ex
|
||||
)
|
||||
if self._interface is not None:
|
||||
await self._interface.close()
|
||||
|
@@ -256,14 +256,14 @@ async def validate_input(hass: core.HomeAssistant, data):
|
||||
)
|
||||
try:
|
||||
detected_dps = await interface.detect_available_dps()
|
||||
except Exception: # pylint: disable=broad-except
|
||||
except Exception as ex:
|
||||
try:
|
||||
_LOGGER.debug("Initial state update failed, trying reset command")
|
||||
_LOGGER.debug("Initial state update failed (%s), trying reset command", ex)
|
||||
if len(reset_ids) > 0:
|
||||
await interface.reset(reset_ids)
|
||||
detected_dps = await interface.detect_available_dps()
|
||||
except Exception: # pylint: disable=broad-except
|
||||
_LOGGER.debug("No DPS able to be detected")
|
||||
except Exception as ex:
|
||||
_LOGGER.debug("No DPS able to be detected: %s", ex)
|
||||
detected_dps = {}
|
||||
|
||||
# if manual DPs are set, merge these.
|
||||
@@ -493,7 +493,7 @@ class LocalTuyaOptionsFlowHandler(config_entries.OptionsFlow):
|
||||
errors["base"] = "address_in_use"
|
||||
else:
|
||||
errors["base"] = "discovery_failed"
|
||||
except Exception: # pylint: disable= broad-except
|
||||
except Exception as ex:
|
||||
_LOGGER.exception("discovery failed")
|
||||
errors["base"] = "discovery_failed"
|
||||
|
||||
@@ -586,8 +586,8 @@ class LocalTuyaOptionsFlowHandler(config_entries.OptionsFlow):
|
||||
errors["base"] = "invalid_auth"
|
||||
except EmptyDpsList:
|
||||
errors["base"] = "empty_dps"
|
||||
except Exception: # pylint: disable=broad-except
|
||||
_LOGGER.exception("Unexpected exception")
|
||||
except Exception as ex:
|
||||
_LOGGER.exception("Unexpected exception: %s", ex)
|
||||
errors["base"] = "unknown"
|
||||
|
||||
defaults = {}
|
||||
|
Reference in New Issue
Block a user