klali / ha-plejd

Plejd component for Home Assistant
Apache License 2.0
69 stars 15 forks source link

FileNotFoundError #27

Closed Emlben closed 4 years ago

Emlben commented 4 years ago

Hi!

I have not been able to get this to work on Hass on a RPi4. Running HASS 0.103.6 on Raspian Buster

Please advice.

This is the log output in HASS: Error while setting up platform plejd Traceback (most recent call last): File "/usr/src/homeassistant/homeassistant/helpers/entity_platform.py", line 150, 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 414, in async_setup_platform await connect(plejdinfo) File "/config/custom_components/plejd/light.py", line 149, in connect bus = await MessageBus(bus_type=BusType.SYSTEM).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

klali commented 4 years ago

I'm guessing this might be due to dbus not running? The socket file this seems to be looking for (by default) is /var/run/dbus/system_bus_socket does that exist for you?

You will also need bluez installed, maybe I should add that to the README.

Emlben commented 4 years ago

Thank you for fast response!

I'm guessing this might be due to dbus not running? The socket file this seems to be looking for (by default) is /var/run/dbus/system_bus_socket does that exist for you?

That do exist for me:

ls -l
total 0
srw-rw-rw- 1 root root 0 Jan  8 23:28 system_bus_socket

Also, I ran this command trying to verify:

ps -ef | grep dbus | grep -v grep
message+   356     1  0 Jan08 ?        00:00:01 /usr/bin/dbus-daemon --system --address=systemd: --nofork --nopidfile --systemd-activation --syslog-only
pi         700   646  0 Jan08 ?        00:00:00 /usr/bin/dbus-daemon --session --address=systemd: --nofork --nopidfile --systemd-activation --syslog-only
pi        1455     1  0 Jan08 ?        00:00:00 dbus-launch --autolaunch 833277ea9d604b378d02e5cc674e183c --binary-syntax --close-stderr
pi        1456     1  0 Jan08 ?        00:00:00 /usr/bin/dbus-daemon --syslog-only --fork --print-pid 5 --print-address 7 --session

You will also need bluez installed, maybe I should add that to the README. I have bluez 5.52 installed and seems to be running

klali commented 4 years ago

huh. so not issues with that then.

does running this work: $ dbus-monitor --address unix:path=/run/dbus/system_bus_socket

Emlben commented 4 years ago

$ dbus-monitor --address unix:path=/run/dbus/system_bus_socket dbus-monitor: unable to enable new-style monitoring: org.freedesktop.DBus.Error.AccessDenied: "Rejected send message, 1 matched rules; type ="method_call", sender=":1.42" (uid=1000 pid=9990 comm="dbus-monitor --address unix:path=/run/dbus/system_") interface="org.freedesktop.DBu s.Monitoring" member="BecomeMonitor" error name="(unset)" requested_reply="0" destination="org.freedesktop.DBus" (bus)". Falling back to ea vesdropping. signal time=1578599157.564803 sender=org.freedesktop.DBus -> destination=:1.42 serial=2 path=/org/freedesktop/DBus; interface=org.freedeskt op.DBus; member=NameAcquired string ":1.42" signal time=1578599162.843903 sender=:1.0 -> destination=(null destination) serial=8934 path=/org/freedesktop/systemd1; interface=org.freed esktop.systemd1.Manager; member=UnitNew string "hostapd.service" object path "/org/freedesktop/systemd1/unit/hostapd_2eservice" signal time=1578599162.844312 sender=:1.0 -> destination=(null destination) serial=8935 path=/org/freedesktop/systemd1; interface=org.freed esktop.systemd1.Manager; member=UnitRemoved string "hostapd.service" object path "/org/freedesktop/systemd1/unit/hostapd_2eservice" signal time=1578599162.897889 sender=:1.0 -> destination=(null destination) serial=8936 path=/org/freedesktop/systemd1; interface=org.freed esktop.systemd1.Manager; member=UnitNew string "dnsmasq.service" object path "/org/freedesktop/systemd1/unit/dnsmasq_2eservice" signal time=1578599162.898171 sender=:1.0 -> destination=(null destination) serial=8937 path=/org/freedesktop/systemd1; interface=org.freed esktop.systemd1.Manager; member=UnitRemoved string "dnsmasq.service" object path "/org/freedesktop/systemd1/unit/dnsmasq_2eservice" signal time=1578599227.862275 sender=:1.0 -> destination=(null destination) serial=8938 path=/org/freedesktop/systemd1; interface=org.freedesktop.systemd1.Manager; member=UnitNew string "hostapd.service" object path "/org/freedesktop/systemd1/unit/hostapd_2eservice" signal time=1578599227.862446 sender=:1.0 -> destination=(null destination) serial=8939 path=/org/freedesktop/systemd1; interface=org.freedesktop.systemd1.Manager; member=UnitRemoved string "hostapd.service" object path "/org/freedesktop/systemd1/unit/hostapd_2eservice" signal time=1578599227.897626 sender=:1.0 -> destination=(null destination) serial=8940 path=/org/freedesktop/systemd1; interface=org.freedesktop.systemd1.Manager; member=UnitNew string "dnsmasq.service" object path "/org/freedesktop/systemd1/unit/dnsmasq_2eservice" signal time=1578599227.897902 sender=:1.0 -> destination=(null destination) serial=8941 path=/org/freedesktop/systemd1; interface=org.freedesktop.systemd1.Manager; member=UnitRemoved string "dnsmasq.service" object path "/org/freedesktop/systemd1/unit/dnsmasq_2eservice"

klali commented 4 years ago

Yeah, that looks to be working. I'll get a raspbian up and running to see if I can reproduce.

You could modify /usr/local/lib/python3.7/site-packages/dbus_next/message_bus.py around line 441, if you remove the try/except before there it might be helpful to see the full exception.

Emlben commented 4 years ago

hmmm, Just realising I did not tell you the whole story here (As always)... ;) One more thing: hass is running in a Docker container.

I do not have such a path at my OS installation but it does exist within one docker container. /var/lib/docker/overlay2/333033efed2668034583e470802eb9d2ca965c494075bd5c1e1ea06406e22b67/merged/usr/local/lib/python3.7/site-packages/dbus_next/message_bus.py

klali commented 4 years ago

and is the dbus socket file only available in the containing os? in that case you should probably map that through to the container (in the expected place).

I guess you ran dbus-monitor in the host, not the container?

Emlben commented 4 years ago

Thank you!

The docker thing was the issue. The socketfile did not exist within docker I just added -v /var/run/dbus:/var/run/dbus to the docker run command and now it works beatiful! So, in my setup: the bluez are installed on the host-OS and then the socket directory is mounted in Docker.

So maybe you want to add that to the readme.

Thanks again!