Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Logging excessive warnings on disconnect #1549

Open
wants to merge 3 commits into
base: master
Choose a base branch
from
Open
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 12 additions & 3 deletions custom_components/localtuya/common.py
Original file line number Diff line number Diff line change
Expand Up @@ -148,6 +148,7 @@ def __init__(self, hass, config_entry, dev_id):
self._entities = []
self._local_key = self._dev_config_entry[CONF_LOCAL_KEY]
self._default_reset_dpids = None
self._disconnect_warning_logged = False
if CONF_RESET_DPIDS in self._dev_config_entry:
reset_ids_str = self._dev_config_entry[CONF_RESET_DPIDS].split(",")

Expand Down Expand Up @@ -195,10 +196,18 @@ async def _make_connection(self):
self,
)
self._interface.add_dps_to_request(self.dps_to_request)
self._disconnect_warning_logged = False
except Exception as ex: # pylint: disable=broad-except
self.warning(
f"Failed to connect to {self._dev_config_entry[CONF_HOST]}: %s", ex
)
if not self._disconnect_warning_logged:
self.warning(
f"Failed to connect to {self._dev_config_entry[CONF_HOST]}: %s", ex
)
self._disconnect_warning_logged = True
else:
self.info(
f"Failed to connect to {self._dev_config_entry[CONF_HOST]}: %s", ex
)

PeteRager marked this conversation as resolved.
Show resolved Hide resolved
if self._interface is not None:
await self._interface.close()
self._interface = None
Expand Down