Closed davidvirdeforshh closed 4 years ago
I don't know what you get installed/running with raspbian.
Are you running home-assistant in a container or straight on raspbian?
The file dbus looks for is usually /var/run/dbus/system_bus_socket does that exist for you?
You can check what user home-assistant runs as with something like: ps aux | grep hass
username is in first column, that user will have to be in the bluetooth group or have permissions to send dbus messages to bluez.
You can also look at #27 for someone else who had similar errors.
Thanks for your swift response @klali !
HA Supervised is running HA as a docker container.
@klali You where right:
/var/run/dbus/system_bus_socket is available from host system, but not from within the docker container.
Even though
-v /var/run/dbus:/var/run/dbus
is added to the docker run command, as mentioned in #27.
I'm at a loss here, but it could be that this issue is on home assistant supervised, rather than ha-plejd.
home assistant says that ha-plejd should "look in the right place". I can not see how that would be achieved. Any ideas?
I wonder what the right path is.
This is controlled by the dbus implementation in https://github.com/altdesktop/python-dbus-next/blob/master/dbus_next/_private/address.py#L43 and can be pointed at a different location by the environment variable DBUS_SYSTEM_BUS_ADDRESS
So it might be that the path inside the supervisor is /run/dbus/system_bus_socket instead, I've just pushed a branch (https://github.com/klali/ha-plejd/tree/dbus_path) that gives the ability to set the dbus address, if you use this branch and add: dbus_address: unix:path=/run/dbus/system_bus_socket
to the plejd section of your configuration it might find the bus.
I appreciate you adding that feature @klali.
I do believe that line: 420 in light.py should have brackets instead of parentheses:
plejdinfo["dbus_address"] = config[CONF_DBUS_ADDRESS]
But even after changing that I got this error:
Error while setting up plejd platform for light Traceback (most recent call last): File "/usr/src/homeassistant/homeassistant/helpers/entity_platform.py", line 179, in _async_setup_platform await asyncio.wait_for(asyncio.shield(task), SLOW_SETUP_MAX_WAIT) File "/usr/local/lib/python3.7/asyncio/tasks.py", line 442, in wait_for return fut.result() File "/config/custom_components/plejd/light.py", line 424, in async_setup_platform await connect(plejdinfo) File "/config/custom_components/plejd/light.py", line 151, in connect bus = await MessageBus(bus_type=BusType.SYSTEM, bus_address=pi["dbus_address"]).connect() File "/usr/local/lib/python3.7/site-packages/dbus_next/aio/message_bus.py", line 38, in __init__ super().__init__(bus_address, bus_type, ProxyObject) File "/usr/local/lib/python3.7/site-packages/dbus_next/message_bus.py", line 71, in __init__ self._setup_socket() File "/usr/local/lib/python3.7/site-packages/dbus_next/message_bus.py", line 447, in _setup_socket raise err File "/usr/local/lib/python3.7/site-packages/dbus_next/message_bus.py", line 441, in _setup_socket self._sock.connect(filename) FileNotFoundError: [Errno 2] No such file or directory
This leads me to believe that setting this this up on supervised HA is non trivial. I will try "normal" HA instead.
Yes, that should be [], I pushed that to the branch.
Looking a bit at this (setting it up in a virtual machine), the hassio_supervisor container gets the dbus socket mapped through to it, but in the homeassistant container (where homeassistant actually runs) doesn't get the dbus socket. The code for this is at https://github.com/home-assistant/supervisor/blob/dev/supervisor/docker/homeassistant.py#L49
Yes, that should be [], I pushed that to the branch.
Looking a bit at this (setting it up in a virtual machine), the hassio_supervisor container gets the dbus socket mapped through to it, but in the homeassistant container (where homeassistant actually runs) doesn't get the dbus socket. The code for this is at https://github.com/home-assistant/supervisor/blob/dev/supervisor/docker/homeassistant.py#L49
That is a dead link nowadays
Was there ever a solution to this? I'm stuck on exactly this problem. I'm running HA in a container with image homeassistant/raspberrypi3-homeassistant:2021.6.4
. Not a clue on what to do. Stacktrace:
Traceback (most recent call last):
File "/usr/src/homeassistant/homeassistant/helpers/entity_platform.py", line 250, in _async_setup_platform
await asyncio.shield(task)
File "/config/custom_components/plejd/light.py", line 478, in async_setup_platform
await connect(plejdinfo)
File "/config/custom_components/plejd/light.py", line 174, in connect
bus = await MessageBus(bus_type=BusType.SYSTEM, bus_address=pi["dbus_address"]).connect()
File "/usr/local/lib/python3.8/site-packages/dbus_next/aio/message_bus.py", line 122, in __init__
super().__init__(bus_address, bus_type, ProxyObject)
File "/usr/local/lib/python3.8/site-packages/dbus_next/message_bus.py", line 86, in __init__
self._setup_socket()
File "/usr/local/lib/python3.8/site-packages/dbus_next/message_bus.py", line 569, in _setup_socket
raise err
File "/usr/local/lib/python3.8/site-packages/dbus_next/message_bus.py", line 542, in _setup_socket
self._sock.connect(filename)
FileNotFoundError: [Errno 2] No such file or directory
You need to check that the dbus socket is mapped through to the container, and as what it's mapped on the inside.
You need to check that the dbus socket is mapped through to the container, and as what it's mapped on the inside.
Not sure I follow. I did the same thing as @davidvirdeforshh, namely -v /var/run/dbus:/var/run/dbus
and I can see the socket file as /var/run/dbus/system_bus_socket
both in the container and outside. The stack trace doesn't actually say what file it is attempting to use to connect so what do I do?
I changed the default to look for /run/dbus/system_bus_socket
so map it as such and it should be found. I guess this could be made better by catching that error and trying to explain what goes wrong and what the solution might be.
https://github.com/klali/ha-plejd/pull/49 would be code for giving a better error here, try it please? =)
/run/dbus/system_bus_socket
which is super helpful for anyone in my position! I changed -v /var/run/dbus:/var/run/dbus
when starting the container to -v /run/dbus:/run/dbus
and am no longer getting the error. Thanks!
I can not get my plejd device to show up in HA. I get the following error in the HA logs:
HA Log
Setup
HW: Raspberry Pi 4 SW: Home Assistant Supervised i.e. running Home Assistant on a generic (Raspbian Lite) Linux Dist.
Install
Got the latest branch cloned into: /usr/share/hassio/homeassistant/custom_components/plejd which contains the following files.
hcitool
Running hcitool as user 'pi':
configuration.yaml:
Please help.
I've not moved any. user to bluetooth group. To be honest I 'm not sure which user Home Asssistant is running as.