fphammerle / switchbot-mqtt

MQTT client controlling SwitchBot button automators & curtain motors, compatible with Home Assistant :house_with_garden: 🐳
https://pypi.org/project/switchbot-mqtt/
GNU General Public License v3.0
51 stars 9 forks source link

Cannot communicate with switchbot #223

Open jamescw opened 7 months ago

jamescw commented 7 months ago

Nice and great work!

Failed to communicate with the bot over bluetooth, not sure what the issue is, dbus was mapped properly, below is the error:

switchbot-mqtt    | Traceback (most recent call last):
switchbot-mqtt    |   File "/switchbot-mqtt/.venv/lib/python3.8/site-packages/switchbot/__init__.py", line 283, in _sendcommand
switchbot-mqtt    |     self._connect()
switchbot-mqtt    |   File "/switchbot-mqtt/.venv/lib/python3.8/site-packages/switchbot/__init__.py", line 232, in _connect
switchbot-mqtt    |     self._device = bluepy.btle.Peripheral(
switchbot-mqtt    |   File "/switchbot-mqtt/.venv/lib/python3.8/site-packages/bluepy/btle.py", line 391, in __init__
switchbot-mqtt    |     self._connect(deviceAddr, addrType, iface)
switchbot-mqtt    |   File "/switchbot-mqtt/.venv/lib/python3.8/site-packages/bluepy/btle.py", line 439, in _connect
switchbot-mqtt    |     raise BTLEDisconnectError("Failed to connect to peripheral %s, addr type: %s" % (addr, addrType), rsp)
switchbot-mqtt    | bluepy.btle.BTLEDisconnectError: Failed to connect to peripheral c8:c9:a9:33:64:4a, addr type: random
switchbot-mqtt    | Switchbot communication failed. Stopping trying
switchbot-mqtt    | NoneType: None
switchbot-mqtt    | failed to turn on switchbot c8:c9:a9:33:64:4a

I used the docker-compose to map the config, switchbot is on firmware 6.4.

fphammerle commented 7 months ago

switchbot-mqtt sends commands via the pySwitchbot library.

Could you try upgrading pySwitchbot to its latest version (within the container) and retry?

If that works, I need to loosen the version constraints of pySwitchbot in switchbot-mqtt.

If the upgrade does not make any difference, could you attempt to invoke pySwitchbot directly (via a python shell or small script)?

jamescw commented 6 months ago

Hi @fphammerle, yes for sure will try that and get back to you!