diff --git a/miflora-mqtt-daemon.py b/miflora-mqtt-daemon.py index 6c7b3b2..510a6df 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 @@ -218,7 +218,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)) @@ -314,7 +314,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)