klali / ha-plejd

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

Worked for a while #26

Closed robehem closed 4 years ago

robehem commented 4 years ago

Thank you for your effort trying to integrate Plejd in Home Assistant!

I first try to install it in 0.86 and it didn't work. When I installed it in a fresh 0.103.4 it worked a while but stopped when I was adding more of my setup.

I looks good when it starts:

2020-01-06 15:33:50 DEBUG (SyncWorker_0) [custom_components.plejd.light] adding device 16 (plejd_matrum)
2020-01-06 15:33:50 DEBUG (SyncWorker_0) [custom_components.plejd.light] adding device 12 (plejd_toa_uppe)
2020-01-06 15:33:58 DEBUG (SyncWorker_7) [custom_components.plejd.light] Starting plejd connection

but I got error below when i try to turn on any device:

2020-01-06 15:35:44 WARNING (SyncWorker_13) [custom_components.plejd.light] Tried to turn on light when plejd is not connected
2020-01-06 15:35:48 WARNING (SyncWorker_18) [custom_components.plejd.light] Tried to turn on light when plejd is not connected

Do you have any idea what could be wrong?

klali commented 4 years ago

Not really, but do try the dbus branch instead, I've been running that for a couple of days and will be merging that in not to long. It seems more stable (and simpler) to me.

robehem commented 4 years ago

Thank you for your quick response. Now I have switched to dbus branch and got this error while booting. Maybe it has something to do with my virtual env?

Error doing job: Task exception was never retrieved
Traceback (most recent call last):
  File "/home/homeassistant/.homeassistant/custom_components/plejd/light.py", line 402, in _start_plejd
    await connect(plejdinfo)
  File "/home/homeassistant/.homeassistant/custom_components/plejd/light.py", line 147, in connect
    om_introspection = await bus.introspect(BLUEZ_SERVICE_NAME, '/')
  File "/srv/homeassistant/lib/python3.7/site-packages/dbus_next/aio/message_bus.py", line 152, in introspect
    return await asyncio.wait_for(future, timeout=timeout)
  File "/usr/lib/python3.7/asyncio/tasks.py", line 416, in wait_for
    return fut.result()
  File "/srv/homeassistant/lib/python3.7/site-packages/dbus_next/message_bus.py", line 170, in reply_notify
    BaseMessageBus._check_method_return(reply, err, 's')
  File "/srv/homeassistant/lib/python3.7/site-packages/dbus_next/message_bus.py", line 487, in _check_method_return
    raise DBusError._from_message(msg)
dbus_next.errors.DBusError: Rejected send message, 2 matched rules; type="method_call", sender=":1.22" (uid=999 pid=292 comm="/srv/homeassistant/bin/python3 /srv/homeassistant/") interface="org.freedesktop.DBus.Introspectable" member="Introspect" error name="(unset)" requested_reply="0" destination="org.bluez" (uid=0 pid=686 comm="/usr/lib/bluetooth/bluetoothd ")
klali commented 4 years ago

What are you running this on? hassio? hassbian?

You might have a permission issue, make sure your homeassistant user is part of the bluetooth group.

robehem commented 4 years ago

I came to the same conclusion earlier today when I read the instructions again and saw that I didn't read this line: "Make sure the homeassistant user has permissions to use bluetooth, this might require putting it in the bluetooth group." Now I see why, it's only in the instructions of the dbus branch :-) After one reboot of my RPi and one more only of Home Assistant it is working! Thank you very much for your effort! I'll do my best to feed you with bug reports if needed.