Closed lionhe1966 closed 2 years ago
Hello, I tried your configuration without "sudo" but I have some errors
2022-01-15 11:37:43,310 DEBUG bt-mqtt-gw.workers_manager workers_manager.py:168:update_all - Updating all workers
2022-01-15 11:37:43,371 ERROR bt-mqtt-gw logger.py:50:log_exception - Fatal error while executing worker command: BTLEManagementError
Traceback (most recent call last):
File "/home/dietpi/bt-mqtt-gateway/./gateway.py", line 90, in <module>
mqtt.publish(_WORKERS_QUEUE.get(timeout=10).execute())
File "/home/dietpi/bt-mqtt-gateway/workers_manager.py", line 48, in execute
messages = self._callback(*self._args)
File "/home/dietpi/bt-mqtt-gateway/workers/miscale.py", line 28, in status_update
results = self._get_data()
File "/home/dietpi/bt-mqtt-gateway/workers/miscale.py", line 105, in _get_data
scanner.scan(self.SCAN_TIMEOUT, passive=True)
File "/home/dietpi/bt-mqtt-gateway/.venv/lib/python3.9/site-packages/bluepy/btle.py", line 852, in scan
self.start(passive=passive)
File "/home/dietpi/bt-mqtt-gateway/.venv/lib/python3.9/site-packages/bluepy/btle.py", line 790, in start
self._mgmtCmd("le on")
File "/home/dietpi/bt-mqtt-gateway/.venv/lib/python3.9/site-packages/bluepy/btle.py", line 312, in _mgmtCmd
raise BTLEManagementError("Failed to execute management command '%s'" % (cmd), rsp)
bluepy.btle.BTLEManagementError: Failed to execute management command 'le on' (code: 20, error: Permission Denied)
Traceback (most recent call last):
File "/home/dietpi/bt-mqtt-gateway/./gateway.py", line 108, in <module>
raise e
File "/home/dietpi/bt-mqtt-gateway/./gateway.py", line 90, in <module>
mqtt.publish(_WORKERS_QUEUE.get(timeout=10).execute())
File "/home/dietpi/bt-mqtt-gateway/workers_manager.py", line 48, in execute
messages = self._callback(*self._args)
File "/home/dietpi/bt-mqtt-gateway/workers/miscale.py", line 28, in status_update
results = self._get_data()
File "/home/dietpi/bt-mqtt-gateway/workers/miscale.py", line 105, in _get_data
scanner.scan(self.SCAN_TIMEOUT, passive=True)
File "/home/dietpi/bt-mqtt-gateway/.venv/lib/python3.9/site-packages/bluepy/btle.py", line 852, in scan
self.start(passive=passive)
File "/home/dietpi/bt-mqtt-gateway/.venv/lib/python3.9/site-packages/bluepy/btle.py", line 790, in start
self._mgmtCmd("le on")
File "/home/dietpi/bt-mqtt-gateway/.venv/lib/python3.9/site-packages/bluepy/btle.py", line 312, in _mgmtCmd
raise BTLEManagementError("Failed to execute management command '%s'" % (cmd), rsp)
bluepy.btle.BTLEManagementError: Failed to execute management command 'le on' (code: 20, error: Permission Denied)
Hi @jumping2000, I ran into the same error and -- after some extensive DuckDuckGoing -- I now think I fixed it by allowing anyone to run bluepy-helper:
sudo setcap 'cap_net_raw,cap_net_admin+eip' .venv/lib/python3.9/site-packages/bluepy/bluepy-helper
I've fixed README some time ago. Maybe its good now ? If not please reopen
I have tried installing bt-mqtt-gateway on a fresh installation of bullseye on my Raspberry 0W as of 09/01/2022 I followed exactly the installation instructions. The interactive command
sudo ./gateway.sh
worked but the service did not start. This is the same as #195 (Error with the service startup).I then erased the installation and started again, trying to understand what the various installation commands actually do.
Up to here everything is correct. The culprit, in my opinion is the following
sudo pip3 install -r requirements.txt
this command does not seem to install the packages into the virtual environment. In my second (succesful) attempt I gave this command without sudo.Then instructions tell to install other dependencies without sudo, therefore packages are installed in the virtual enviroment (I have run this command after configuring the file
configure.yaml
)In my first attempt in which I followed rigorously instructions, I tested the installation with the sudo command interactively
but in my second attempt, sudo was not necessary.
So far the interactive test was successfull in both cases, but only when the installation is performed without sudo, the service starts correctly (following instructions it complains that yaml or paho-mqtt are not available).
My explanation is that with
sudo pip3 install -r requirements.txt
the installation of some packages is not performed in the virtual environment. The solutions suggested in #195 basically aim at installing all required packages with sudo, outside the virtual environment.