From b9feb1572c7a32cb84191965e839f6d5c442f876 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bj=C3=B6rn=20Augustsson?= Date: Sun, 27 Feb 2022 15:56:13 +0100 Subject: [PATCH] Handle AttributeError from request_environmental_data() (#18) --- main.py | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/main.py b/main.py index 332281e..79c3e59 100755 --- a/main.py +++ b/main.py @@ -85,7 +85,10 @@ def _timer_callback(self): if self.is_connected: logging.debug( 'Requesting updated environmental data from %s', self.serial) - self.libdyson.request_environmental_data() + try: + self.libdyson.request_environmental_data() + except AttributeError: + logging.error('Race with a disconnect? Skipping an iteration.') self._refresh_timer() else: logging.debug('Device %s is disconnected.', self.serial)