Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Error when starting the script (93, 'Protocol not supported') #5

Closed
therealhalifax opened this issue Nov 26, 2021 · 9 comments
Closed

Comments

@therealhalifax
Copy link

I dont get it running. When starting the script, taken from the example the following error appears:

Traceback (most recent call last):
File "/usr/src/homeassistant/homeassistant/components/websocket_api/commands.py", line 185, in handle_call_service
await hass.services.async_call(
File "/usr/src/homeassistant/homeassistant/core.py", line 1495, in async_call
task.result()
File "/usr/src/homeassistant/homeassistant/core.py", line 1530, in _execute_service
await handler.job.target(service_call)
File "/usr/src/homeassistant/homeassistant/components/script/init.py", line 280, in service_handler
await script_entity.async_turn_on(
File "/usr/src/homeassistant/homeassistant/components/script/init.py", line 384, in async_turn_on
await coro
File "/usr/src/homeassistant/homeassistant/components/script/init.py", line 410, in _async_run
return await self.script.async_run(script_vars, context)
File "/usr/src/homeassistant/homeassistant/helpers/script.py", line 1243, in async_run
await asyncio.shield(run.async_run())
File "/usr/src/homeassistant/homeassistant/helpers/script.py", line 353, in async_run
await self._async_step(log_exceptions=False)
File "/usr/src/homeassistant/homeassistant/helpers/script.py", line 371, in _async_step
await getattr(self, handler)()
File "/usr/src/homeassistant/homeassistant/helpers/script.py", line 571, in _async_call_service_step
await service_task
File "/usr/src/homeassistant/homeassistant/core.py", line 1495, in async_call
task.result()
File "/usr/src/homeassistant/homeassistant/core.py", line 1534, in _execute_service
await self._hass.async_add_executor_job(handler.job.target, service_call)
File "/usr/local/lib/python3.9/concurrent/futures/thread.py", line 52, in run
result = self.fn(*self.args, **self.kwargs)
File "/config/custom_components/timebox_mini/init.py", line 288, in handle_action
dev = Timebox(mac)
File "/config/custom_components/timebox_mini/init.py", line 34, in init
self.sock = bluetooth.BluetoothSocket(bluetooth.RFCOMM)
File "/usr/local/lib/python3.9/site-packages/bluetooth/bluez.py", line 155, in init
_sock = _bt.btsocket (proto)
_bluetooth.error: (93, 'Protocol not supported')

@mathoudebine
Copy link
Owner

Hi! Are you running Home Assistant from a Raspberry Pi? If yes maybe you can try this solution: https://support.plugable.com/t/bluetooth-home-automation-switch-btaps1-raspberry-pi-error/8554
Otherwise, it can be an issue with your Bluetooth hardware or driver, or your kernel might be incorrectly configured and lacking RFCOMM support.
Please provide some information about your hardware and HA version you're on.

@therealhalifax
Copy link
Author

Sorry for late reply, I was a bit offline :-(

I run HA in a VM on a Synology DSM7. Bluetooth is working as i have also some other BT sensors connected to my HA. I am running the latest HA version 2022.2

I also tried now to add the line in the config, but its doesnt change anything.

@mathoudebine mathoudebine reopened this Feb 21, 2022
@mathoudebine
Copy link
Owner

This plugin uses a special Bluetooth protocol to communicate with the Timebox called the RFCOMM protocol which does not seem supported in your configuration.
This is why it fails here even if you can have other BT sensors working (they may not use the same protocol)

If you use Docker to run HA on your Synology NAS, be sure to follow these instructions: https://philhawthorne.com/installing-home-assistant-io-on-a-synology-diskstation-nas/ (see Adding a Bluetooth Radio)

If you run HA as a VM, then it may be related to:

  • your Bluetooth USB dongle that does not support RFCOMM
  • the HA VM that does not have support for RFCOMM protocol
  • the Synology Linux that does not allow the VM to access to Bluetooth hardware using RFCOMM

Which Bluetooth USB do you use?
Also, can you try by temporary disabling other BT sensors?

@therealhalifax
Copy link
Author

finally I switched from my VM installation to a brand new dedicated x64 HW to run HA OS. I have much more access to my HW now (as expected). And I used your new HACS integration - thanks for that, it makes it much easier.

BUT

Its still not working :-( same error like before:

Traceback (most recent call last):
File "/usr/src/homeassistant/homeassistant/components/websocket_api/decorators.py", line 27, in _handle_async_response
await func(hass, connection, msg)
File "/usr/src/homeassistant/homeassistant/components/websocket_api/commands.py", line 552, in handle_execute_script
await script_obj.async_run(msg.get("variables"), context=context)
File "/usr/src/homeassistant/homeassistant/helpers/script.py", line 1243, in async_run
await asyncio.shield(run.async_run())
File "/usr/src/homeassistant/homeassistant/helpers/script.py", line 349, in async_run
await self._async_step(log_exceptions=False)
File "/usr/src/homeassistant/homeassistant/helpers/script.py", line 367, in _async_step
await getattr(self, handler)()
File "/usr/src/homeassistant/homeassistant/helpers/script.py", line 570, in _async_call_service_step
await service_task
File "/usr/src/homeassistant/homeassistant/core.py", line 1636, in async_call
task.result()
File "/usr/src/homeassistant/homeassistant/core.py", line 1679, in _execute_service
await self._hass.async_add_executor_job(
File "/usr/local/lib/python3.9/concurrent/futures/thread.py", line 58, in run
result = self.fn(*self.args, **self.kwargs)
File "/config/custom_components/timebox_mini/init.py", line 288, in handle_action
dev = Timebox(mac)
File "/config/custom_components/timebox_mini/init.py", line 34, in init
self.sock = bluetooth.BluetoothSocket(bluetooth.RFCOMM)
File "/usr/local/lib/python3.9/site-packages/bluetooth/bluez.py", line 155, in init
_sock = _bt.btsocket (proto)
_bluetooth.error: (93, 'Protocol not supported')

how to check if RFCOMM is availiable?

@mathoudebine
Copy link
Owner

Sorry to hear that ☹️
If you now have HomeAssistant directly running on an x64 machine instead of a VM but still get the message, then it surely is an issue with your Bluetooth hardware.
This extension uses a well-known and widely used Bluetooth library called Bluez that checks if RFCOMM is available on your hardware, so i would trust the error message if it says it is not.
What is the Bluetooth hardware you use ? Is it an external Bluetooth USB dongle ?

@therealhalifax
Copy link
Author

I tried with the internal first. I think its Intel as it's an Intel machine. And also try 2 external usb. But not sure If the externals are used. How could I Set this up?

@mathoudebine
Copy link
Owner

You can list your Bluetooth adapters with this command:
hcitool dev
You can plug/unplug your USB adapters to identify them.

Unfortunately with the Bluez library it is not easy to select which Bluetooth adapter to use. It think that by default it uses the first available one so the internal one.
You can try to disable the internal adapter to force the use of the external one:
hciconfig hciX down (may require admin rights)
Another way would be to completely disable internal Bluetooth HW in your machine BIOS/UEFI.

@therealhalifax
Copy link
Author

therealhalifax commented Mar 30, 2022

only bluetoothctl is working for me:
grafik

...:28 is the internal one. but i can force to use the external by unpluging and repluging it.

@mathoudebine
Copy link
Owner

mathoudebine commented Mar 30, 2022

I see one is listed as default, but i think it is only for bluetoothctl commands, not for HomeAssistant.
What you can try is force power off the internal adapter :

bluetoothctl
[bluetooth]# select 14:85:7F:4E:60:28
[bluetooth]# disconnect [your Timebox MAC address]
--> ignore if error
[bluetooth]# remove [your Timebox MAC address]
--> ignore if error
[bluetooth]# power off
--> should display "Changing power off succeeded"

Then power on external adapter but also force remove Timebox:

[bluetooth]# select 00:1A:7D:DA:71:0A
[bluetooth]# power on
[bluetooth]# disconnect [your Timebox MAC address]
--> ignore if error
[bluetooth]# remove [your Timebox MAC address]
--> ignore if error

At this point the Timebox should display the Bluetooth logo
If the Timebox does not display Bluetooth logo, check if it is not associated to another device like your phone.
Then pair the Timebox with the external adapter:

[bluetooth]# select 00:1A:7D:DA:71:0A
[bluetooth]# scan on
[bluetooth]# pair [your Timebox MAC address]
[bluetooth]# connect [your Timebox MAC address]

then restart HomeAssistant (not the computer) from the web UI and try to call the service again
If it doesn't work, you can do the same steps but switch between internal/external adapters.

@mathoudebine mathoudebine closed this as not planned Won't fix, can't repro, duplicate, stale Jun 8, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants