From fee0dcd4dede74d0c0f97066742909024d6ea6d2 Mon Sep 17 00:00:00 2001 From: LarsAC Date: Mon, 28 May 2018 22:05:01 +0200 Subject: [PATCH] Implement suggested fix for issue #39 --- miflora-mqtt-daemon.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/miflora-mqtt-daemon.py b/miflora-mqtt-daemon.py index 17a52bb..b336e2f 100755 --- a/miflora-mqtt-daemon.py +++ b/miflora-mqtt-daemon.py @@ -13,7 +13,7 @@ from configparser import ConfigParser from unidecode import unidecode from miflora.miflora_poller import MiFloraPoller, MI_BATTERY, MI_CONDUCTIVITY, MI_LIGHT, MI_MOISTURE, MI_TEMPERATURE -from btlewrap import available_backends, BluepyBackend, GatttoolBackend, PygattBackend +from btlewrap import available_backends, BluepyBackend, GatttoolBackend, PygattBackend, BluetoothBackendException import paho.mqtt.client as mqtt import sdnotify @@ -221,7 +221,7 @@ def flores_to_openhab_items(flores, reporting_mode): flora_poller.fill_cache() flora_poller.parameter_value(MI_LIGHT) flora['firmware'] = flora_poller.firmware_version() - except IOError: + except (IOError, BluetoothBackendException): print_line('Initial connection to Mi Flora sensor "{}" ({}) failed.'.format(name_pretty, mac), error=True, sd_notify=True) else: print('Internal name: "{}"'.format(name_clean)) @@ -316,7 +316,7 @@ def flores_to_openhab_items(flores, reporting_mode): try: flora['poller'].fill_cache() flora['poller'].parameter_value(MI_LIGHT) - except IOError: + except (IOError, BluetoothBackendException): attempts = attempts - 1 if attempts > 0: print_line('Retrying ...', warning = True)