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 all commits
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
8 changes: 5 additions & 3 deletions custom_components/localtuya/common.py
Original file line number Diff line number Diff line change
Expand Up @@ -150,6 +150,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 @@ -197,10 +198,11 @@ 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
)
message = f"Failed to connect to {self._dev_config_entry[CONF_HOST]}: %s" % ex
self.warning(message) if not self._disconnect_warning_logged else self.info(message)
self._disconnect_warning_logged = True
if self._interface is not None:
await self._interface.close()
self._interface = None
Expand Down