basnijholt / miflora

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

Intended behavior upon connection error #31

Closed ThomDietrich closed 6 years ago

ThomDietrich commented 7 years ago

Hello, how is the library supposed to catch and propagate a connection problem?

Heres a minimal example:

flora_poller = MiFloraPoller(mac='11:22:33:44:55:66')
flora_poller.fill_cache()
print('Device name: "{}"'.format(flora_poller.name()))

This piece of code will produce:

Traceback (most recent call last):
  File "./mqtt-flora.py", line 85, in <module>
    print('Device name:  "{}"'.format(flora_poller.name()))
  File "/usr/local/lib/python3.4/dist-packages/miflora/miflora_poller.py", line 177, in name
    return ''.join(chr(n) for n in name)
TypeError: 'NoneType' object is not iterable

Other functions behave similarly. Shouldn't there be an exception thrown or a cache_available method or any other kind of error control mechanism?

ChristianKuehnel commented 6 years ago

Problem was already solved some time ago...