rytilahti / python-yeelightbt

Python library for Yeelight's bedside (btle) and candela lamps
83 stars 26 forks source link

Multiple lamps #10

Closed bachulator closed 6 years ago

bachulator commented 7 years ago

Hi,

First of thanks for the effort, it was rather huge surprise to see this rather exotic product get implemented to home automation.

But I have rather strange issue. I have two bedside lamps and it seem the yeelight_bt server can connect only to one of them in rather random order. I've been able to reproduce same issue in cli as well. Please find attached logs:

Traceback (most recent call last): File "/srv/homeassistant/lib/python3.5/site-packages/homeassistant/helpers/entity.py", line 225, in async_update_ha_state None, self.update) File "/usr/lib/python3.5/asyncio/futures.py", line 361, in iter yield self # This tells Task to wait for completion. File "/usr/lib/python3.5/asyncio/tasks.py", line 296, in _wakeup future.result() File "/usr/lib/python3.5/asyncio/futures.py", line 274, in result raise self._exception File "/usr/lib/python3.5/concurrent/futures/thread.py", line 55, in run result = self.fn(*self.args, **self.kwargs) File "/home/homeassistant/.homeassistant/custom_components/light/yeelight_bt.py", line 164, in update self._dev.state() File "/srv/homeassistant/lib/python3.5/site-packages/yeelightbt/lamp.py", line 41, in _wrap self.connect() File "/srv/homeassistant/lib/python3.5/site-packages/yeelightbt/lamp.py", line 88, in connect self._conn.connect() File "/srv/homeassistant/lib/python3.5/site-packages/yeelightbt/connection.py", line 58, in connect self._conn.connect(self._mac) File "/srv/homeassistant/lib/python3.5/site-packages/bluepy/btle.py", line 408, in connect self._connect(addr, addrType, iface) File "/srv/homeassistant/lib/python3.5/site-packages/bluepy/btle.py", line 402, in _connect "Failed to connect to peripheral %s, addr type: %s" % (addr, addrType)) bluepy.btle.BTLEException: Failed to connect to peripheral f8:24:41:e3:XX:XX, addr type: public

rytilahti commented 7 years ago

This is a known problem when trying to connect on multiple btle devices concurrently, but I'm unsure on what part of the stack the problem lies (chipset? bluez? bluepy?). Unfortunately there is no easy fix for it at the moment.

rytilahti commented 6 years ago

Considering there's nothing this library can do to alleviate the problem, I'm closing this for now.