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

Conversation

PeteRager
Copy link

When a tuya device is turned off the integration attempts to reconnect periodically and logs warnings when each reconnect attempt fails. This behavior may fill up the log with excessive warnings if the device is off for a long period of time. With this change a warning is logged when the first reconnect fails and on subsequent attempts an info level message is logged.

This update allows the integration to meet this specific silver quality requirement:

https://developers.home-assistant.io/docs/integration_quality_scale_index/#silver-
"Handles device/service unavailable. Log a warning once when unavailable, log once when reconnected."

My specific use case. I have a Sunbeam mattress pad. When I leave the house for an extended period of time I unplug the mattress pad. When I do this my log fills up with warnings.

New behavior:

2023-10-30 12:27:46.561 INFO (MainThread) [homeassistant.components.select] Setting up select.localtuya
2023-10-30 12:27:46.587 INFO (MainThread) [custom_components.localtuya.common] [eb1...o2d] Trying to connect to 192.168.20.102...
2023-10-30 12:27:46.617 INFO (MainThread) [custom_components.localtuya.common] [eb1...o2d] Successfully connected to 192.168.20.102
2023-10-30 12:30:49.867 WARNING (MainThread) [custom_components.localtuya.common] [eb1...o2d] Disconnected - waiting for discovery broadcast
2023-10-30 12:31:40.185 INFO (MainThread) [custom_components.localtuya.common] [eb1...o2d] Trying to connect to 192.168.20.102...
2023-10-30 12:33:47.408 WARNING (MainThread) [custom_components.localtuya.common] [eb1...o2d] Failed to connect to 192.168.20.102: [Errno 110] Connect call failed ('192.168.20.102', 6668)
2023-10-30 12:34:40.188 INFO (MainThread) [custom_components.localtuya.common] [eb1...o2d] Trying to connect to 192.168.20.102...
2023-10-30 12:36:47.504 INFO (MainThread) [custom_components.localtuya.common] [eb1...o2d] Failed to connect to 192.168.20.102: [Errno 110] Connect call failed ('192.168.20.102', 6668)
2023-10-30 12:37:40.192 INFO (MainThread) [custom_components.localtuya.common] [eb1...o2d] Trying to connect to 192.168.20.102...
2023-10-30 12:39:47.472 INFO (MainThread) [custom_components.localtuya.common] [eb1...o2d] Failed to connect to 192.168.20.102: [Errno 110] Connect call failed ('192.168.20.102', 6668)
2023-10-30 12:40:40.196 INFO (MainThread) [custom_components.localtuya.common] [eb1...o2d] Trying to connect to 192.168.20.102...
2023-10-30 12:42:47.440 INFO (MainThread) [custom_components.localtuya.common] [eb1...o2d] Failed to connect to 192.168.20.102: [Errno 110] Connect call failed ('192.168.20.102', 6668)
2023-10-30 12:27:46.561 INFO (MainThread) [homeassistant.components.select] Setting up select.localtuya
2023-10-30 12:27:46.587 INFO (MainThread) [custom_components.localtuya.common] [eb1...o2d] Trying to connect to 192.168.20.102...
2023-10-30 12:27:46.617 INFO (MainThread) [custom_components.localtuya.common] [eb1...o2d] Successfully connected to 192.168.20.102
2023-10-30 12:30:49.867 WARNING (MainThread) [custom_components.localtuya.common] [eb1...o2d] Disconnected - waiting for discovery broadcast
2023-10-30 12:31:40.185 INFO (MainThread) [custom_components.localtuya.common] [eb1...o2d] Trying to connect to 192.168.20.102...
2023-10-30 12:33:47.408 WARNING (MainThread) [custom_components.localtuya.common] [eb1...o2d] Failed to connect to 192.168.20.102: [Errno 110] Connect call failed ('192.168.20.102', 6668)
2023-10-30 12:34:40.188 INFO (MainThread) [custom_components.localtuya.common] [eb1...o2d] Trying to connect to 192.168.20.102...
2023-10-30 12:36:47.504 INFO (MainThread) [custom_components.localtuya.common] [eb1...o2d] Failed to connect to 192.168.20.102: [Errno 110] Connect call failed ('192.168.20.102', 6668)
2023-10-30 12:37:40.192 INFO (MainThread) [custom_components.localtuya.common] [eb1...o2d] Trying to connect to 192.168.20.102...
2023-10-30 12:39:47.472 INFO (MainThread) [custom_components.localtuya.common] [eb1...o2d] Failed to connect to 192.168.20.102: [Errno 110] Connect call failed ('192.168.20.102', 6668)
2023-10-30 12:40:40.196 INFO (MainThread) [custom_components.localtuya.common] [eb1...o2d] Trying to connect to 192.168.20.102...
2023-10-30 12:42:47.440 INFO (MainThread) [custom_components.localtuya.common] [eb1...o2d] Failed to connect to 192.168.20.102: [Errno 110] Connect call failed ('192.168.20.102', 6668)
2023-10-30 12:43:40.198 INFO (MainThread) [custom_components.localtuya.common] [eb1...o2d] Trying to connect to 192.168.20.102...
2023-10-30 12:44:43.359 INFO (MainThread) [custom_components.localtuya.common] [eb1...o2d] Successfully connected to 192.168.20.102

@PeteRager
Copy link
Author

Review please.

PeteRager and others added 2 commits May 3, 2024 19:45
@PeteRager
Copy link
Author

PeteRager commented Dec 1, 2024

review requested

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants