Skip to content

Commit 092c280

Browse files
committed
init: use a longer, non-hardcoded sleep time
1 parent 8dd8866 commit 092c280

1 file changed

Lines changed: 5 additions & 4 deletions

File tree

__init__.py

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@
2424

2525
UPDATE_TOPIC = f"{DOMAIN}_update"
2626
ERROR_ITERVAL_MAPPING = [0, 10, 60, 300, 600, 3000, 6000]
27+
ERROR_RECONNECT_INTERVAL = 300
2728
NOTIFICATION_ID = "ph803w_device_notification"
2829
NOTIFICATION_TITLE = "PH-803W Device status"
2930

@@ -115,13 +116,13 @@ def shutdown(event):
115116
self.device_client = device.Device(self.host)
116117
try:
117118
if not self.device_client.run(once=True):
118-
_LOGGER.info("Device found but no measurement was received, reconnecting in 1min")
119-
time.sleep(60)
119+
_LOGGER.info(f"Device found but no measurement was received, reconnecting in {ERROR_RECONNECT_INTERVAL} seconds")
120+
time.sleep(ERROR_RECONNECT_INTERVAL)
120121
continue
121122
except Exception as e:
122123
_LOGGER.info(f"Error connecting to device at {self.host}: {str(e)}")
123-
_LOGGER.info("Retrying connection in 1min")
124-
time.sleep(60)
124+
_LOGGER.info(f"Retrying connection in {ERROR_RECONNECT_INTERVAL} seconds")
125+
time.sleep(ERROR_RECONNECT_INTERVAL)
125126
continue
126127

127128
_LOGGER.debug("Registering callbacks")

0 commit comments

Comments
 (0)