basnijholt / miflora

☘️🌑🌼πŸ₯€πŸ‘ Mi Flora Plant sensor Python package
MIT License
362 stars 99 forks source link

Exit if no data because of sensor not in range #99

Closed JoanMCD closed 6 years ago

JoanMCD commented 6 years ago

Hello, I use ver 0.4 with miflora-mqtt-daemon from ThomDietrich. If a miFlora sensor is out of range I get a error in the miflora-mqtt-daemon.py -> miflora_poller.py -> gatttool.py

I don't can find out where exact is the problem, but I suppose it's in the backend support. Because python is not my primary language maybe someone can see the problem !?


Xiaomi Mi Flora Plant Sensor MQTT Client/Daemon
Source: https://github.com/ThomDietrich/miflora-mqtt-daemon

Adding sensor to device list and testing connection ...
Name:          "FloraCare01"
Traceback (most recent call last):
  File "/opt/miflora-mqtt-daemon/miflora-mqtt-daemon.py", line 218, in <module>
    flora_poller.fill_cache()
  File "/usr/local/lib/python3.5/dist-packages/miflora/miflora_poller.py", line 61, in fill_cache
    firmware_version = self.firmware_version()
  File "/usr/local/lib/python3.5/dist-packages/miflora/miflora_poller.py", line 104, in firmware_version
    res = connection.read_handle(_HANDLE_READ_VERSION_BATTERY)  # pylint: disable=no-member
  File "/usr/local/lib/python3.5/dist-packages/btlewrap/gatttool.py", line 23, in _func_wrapper
    return func(*args, **kwargs)
  File "/usr/local/lib/python3.5/dist-packages/btlewrap/gatttool.py", line 253, in read_handle
    raise BluetoothBackendException("Exit read_ble, no data ({})".format(current_thread()))
btlewrap.base.BluetoothBackendException: Exit read_ble, no data (<_MainThread(MainThread, started -1225092352)>)
ThomDietrich commented 6 years ago

An exception is thrown, hence I'd say this issue is not a problem with the library and we should solve it in https://github.com/ThomDietrich/miflora-mqtt-daemon/issues/39

As I said, PRs welcome!