custom-components / ble_monitor

BLE monitor for passive BLE sensors
https://community.home-assistant.io/t/passive-ble-monitor-integration/
MIT License
1.91k stars 247 forks source link

It is worth to add processing for the lack of necessary utilities #1

Closed Magalex2x14 closed 4 years ago

Magalex2x14 commented 4 years ago

Here are the details of the error in the absence of hcidump:

[homeassistant.components.sensor] Error while setting up platform mitemp_bt
Traceback (most recent call last):
  File "/srv/homeassistant/lib/python3.7/site-packages/homeassistant/helpers/entity_platform.py", line 150, in _async_setup_platform
    await asyncio.wait_for(asyncio.shield(task), SLOW_SETUP_MAX_WAIT)
  File "/usr/lib/python3.7/asyncio/tasks.py", line 416, in wait_for
    return fut.result()
  File "/usr/lib/python3.7/concurrent/futures/thread.py", line 57, in run
    result = self.fn(*self.args, **self.kwargs)
  File "/home/homeassistant/.homeassistant/custom_components/mitemp_bt/sensor.py", line 145, in setup_platform
    scanner.start()
  File "/home/homeassistant/.homeassistant/custom_components/mitemp_bt/sensor.py", line 109, in start
    self.hcidump = subprocess.Popen(['hcidump', '--raw', 'hci'], stdout=self.tempf, stderr=None)
  File "/usr/lib/python3.7/subprocess.py", line 775, in __init__
    restore_signals, start_new_session)
  File "/usr/lib/python3.7/subprocess.py", line 1522, in _execute_child
    raise child_exception_type(errno_num, err_msg, err_filename)
FileNotFoundError: [Errno 2] No such file or directory: 'hcidump': 'hcidump'
Ernst79 commented 4 years ago

Is this where we changed the error handling to pass pylint? Not sure what your issue exactly is? Can you clarify?

Magalex2x14 commented 4 years ago

in my previous comment, an example of an error that occurs if hcidump is not installed. It seemed to me then, that in the place where popen is called, it is worth catching the FileNotFound exception and return from setup_platform function. But now I'm not sure, because the python error in the log speaks for itself. What do you think?

Magalex2x14 commented 4 years ago

You can write in the log in human language that an installed hcitool or/and hcidump is required for the platform to work... For example.

Ernst79 commented 4 years ago

Yes, to my opinion, human readable errors messages are much better than these cryptic messages, especially for the less experienced user. So, yes, I would be in favor for adding a human readable error message, if possible with instructions how to solve.

Magalex2x14 commented 4 years ago

No longer relevant since 0.5.0