klali / ha-plejd

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

More some help needed, than an issue =) #30

Closed soder82 closed 4 years ago

soder82 commented 4 years ago

I'm running an Unraid server with HA as an docker. I just bought some Plejd stuff I would like to get in to HA.

I got the crypto key from my android phone and also the devices and I cloned this projekt to /mnt/user/appdata/home-assistant/custom_components/plejd and edited configuration.yaml as in README.

I bought a USB dongle that my unraid server finds root@Tower:~# lsusb Bus 002 Device 005: ID 0a12:0001 Cambridge Silicon Radio, Ltd Bluetooth Dongle (HCI mode)

When I restarts HA it starts in failsafe mode and the error says. 2020-04-03 15:01:05 ERROR (SyncWorker_1) [homeassistant.util.yaml.loader] while scanning for the next token found character '\t' that cannot start any token in "/config/configuration.yaml", line 140, column 1 2020-04-03 15:01:05 ERROR (MainThread) [homeassistant.bootstrap] Failed to parse configuration.yaml: while scanning for the next token found character '\t' that cannot start any token in "/config/configuration.yaml", line 140, column 1. Activating safe mode

I got this error even yesterday, before I got the BT adapter.

  1. How do I make sure HA has access to the BT adapter?
  2. Do I need to change something with the config folder path since I use Unraid?

Thanks.

/Söder

klali commented 4 years ago

So.. Not knowing anything about unraid or the rest of your setup. The error that you get when starting is that you have a tab (\t) in your configuration.yaml on line 140.

If you've followed the README here and have the right things installed your BT adapter should be found on startup. Important things are, does your adapter support BLE?

soder82 commented 4 years ago

Thanks for the reply. Yes, that was a tab that created that error. Thanks.

Not it boot as it should, but I still can't find anything about Plejd in HA. Is there something else I should do to find them?

I'm gonna lock in to what I need to do with the BT adapter in unraid docker and all that stuff to.

EDIT: Now I got this problem, and I guess it still has to do with the BT adapter. 2020-04-04 13:30:05 ERROR (MainThread) [homeassistant.components.light] 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 417, 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 39, in init super().init(bus_address, bus_type, ProxyObject) File "/usr/local/lib/python3.7/site-packages/dbus_next/message_bus.py", line 72, in init self._setup_socket() File "/usr/local/lib/python3.7/site-packages/dbus_next/message_bus.py", line 499, in _setup_socket raise err File "/usr/local/lib/python3.7/site-packages/dbus_next/message_bus.py", line 493, in _setup_socket self._sock.connect(filename) FileNotFoundError: [Errno 2] No such file or directory

klali commented 4 years ago

No. You're (still) not getting through to contact with your adapter. This is a dbus error and the same as #27 and #29 the dbus package ha-plejd is using looks for /var/run/dbus/system_bus_socket by default, does that exist for you?

I have a branch (https://github.com/klali/ha-plejd/tree/dbus_path) that makes the path to the bus configurable if it's somewhere else, sometimes it's only available as /run/dbus/system_bus_socket then it might be useful to make it configurable.

soder82 commented 4 years ago

OK, well, I have nothing in the /var/run/dbus. I guess I will try to change to that branch instead then.

But I still don't understand what I need to do more to pass the adapter to the docker. I've used the extra parameter in HA with --device=/dev/bus/usb/002/005 like I did for my Conbee stick with Deconz docker (before I changed to /dev/ttyACM0).

But it's not enough now.

Thanks for the help.

EDIT: Just to be clear. Since I use HA as Docker on my Unraid server, it's the manual installation I shall use? Not running install scripts and stuff like that?

Also, if I'm root, does that mean "I'm in the BT group"? image

I'm now on that other branch. I also set Extra Parameter in the HA docker with "-v /var/run/dbus:/var/run/dbus". Now when in the console for that docker there's a system_bus_socket in /var/run/dbus.

But when I run hcitool dev Devices:

there's no devices?

When I run "hciconfig" I get this.

/run/dbus # hciconfig hci1: Type: Primary Bus: USB BD Address: 00:26:83:33:6B:21 ACL MTU: 1022:8 SCO MTU: 121:3 DOWN RX bytes:511 acl:0 sco:0 events:23 errors:0 TX bytes:339 acl:0 sco:0 commands:23 errors:0

hci0: Type: Primary Bus: USB BD Address: 00:1A:7D:DA:71:09 ACL MTU: 310:10 SCO MTU: 64:8 DOWN RX bytes:574 acl:0 sco:0 events:30 errors:0 TX bytes:368 acl:0 sco:0 commands:30 errors:0

And "hciconfig hci1 up" I get hciconfig hci1 up Can't init device hci1: Operation not permitted (1)

But running the HA docker as privilege I can boot get that last command running. But I still get error in HA about plejd. Can I install bluez to the HA docker?

Logginformation (ERROR) Logger: homeassistant.components.light Source: custom_components/plejd/light.py:153 Integration: Lampor (documentation, issues) First occurred: 13:29:07 (1 occurrences) Last logged: 13:29:07

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 153, in connect om_introspection = await bus.introspect(BLUEZ_SERVICE_NAME, '/') File "/usr/local/lib/python3.7/site-packages/dbus_next/aio/message_bus.py", line 153, in introspect return await asyncio.wait_for(future, timeout=timeout) File "/usr/local/lib/python3.7/asyncio/tasks.py", line 442, in wait_for return fut.result() File "/usr/local/lib/python3.7/site-packages/dbus_next/message_bus.py", line 176, in reply_notify BaseMessageBus._check_method_return(reply, err, 's') File "/usr/local/lib/python3.7/site-packages/dbus_next/message_bus.py", line 539, in _check_method_return raise DBusError._from_message(msg) dbus_next.errors.DBusError: The name org.bluez was not provided by any .service files

/Söder

On Sat, Apr 4, 2020 at 10:09 PM Klas Lindfors notifications@github.com wrote:

No. You're (still) not getting through to contact with your adapter. This is a dbus error and the same as #27 https://github.com/klali/ha-plejd/issues/27 and #29 https://github.com/klali/ha-plejd/issues/29 the dbus package ha-plejd is using looks for /var/run/dbus/system_bus_socket by default, does that exist for you?

I have a branch (https://github.com/klali/ha-plejd/tree/dbus_path) that makes the path to the bus configurable if it's somewhere else, sometimes it's only available as /run/dbus/system_bus_socket then it might be useful to make it configurable.

— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub https://github.com/klali/ha-plejd/issues/30#issuecomment-609082682, or unsubscribe https://github.com/notifications/unsubscribe-auth/AALNIBU5GIQ7XPFODCXOCNDRK6HXXANCNFSM4L4CJVXA .

klali commented 4 years ago

A bit slow with responding, but trying to answer your last questions here: Do you have a dbus socket in /run/dbus ? (if you do and it works to point at it, maybe I should merge that other branch pointing that out). If you run as root you shouldn't need any group changes.

klali commented 4 years ago

I'm closing this. Feel free to re-open or continue the conversation if you need/want.

rickardrockard commented 2 years ago

Adding to this conversation, since I'm also running Home Assistant Core in a Docker container on Unraid. To get everything working, one needs to have the bluez service running in Unraid, which is not there by default (as implied by the last line in the log posted by soder82). To get it one needs to install the Nerd Pack plugin, and install bluez through that. In addition, the container needs to be running in priviliged mode, and given read/write access to the path /var/run/dbus/ on the host (mapped to /var/run/dbus/ in the container). I'm not sure if that's needed, but I also mapped the path /org/bluez/hci0 on the host to /org/bluez/hci0 in the container. Using this approach, I managed to get the plugin to talk to my ASUS BT-500 adapter connected to the host.