zewelor / bt-mqtt-gateway

A simple Python script which provides a Bluetooth to MQTT gateway, easily extensible via custom workers. See https://github.com/zewelor/bt-mqtt-gateway/wiki for more information.
MIT License
549 stars 116 forks source link

Switchbot #231

Closed MarcE85 closed 2 years ago

MarcE85 commented 3 years ago

Describe the bug I can't use my switchbot via bt-mqtt-gateway. My other device (MiFlora) is working perfect.

To Reproduce MQTT Command: pi-ble2mqtt/switchbot/upperfloor/upperfloorswitch/set MQTT Payload: "ON" or "PRESS"

Expected behavior Switchbot is pressing my light button :)

Config

    switchbot:
      args:
        devices:
          upperfloorswitch: D2:48:19:77:E2:39
        topic_prefix: switchbot/upperfloor
        state_topic_prefix: switchbot/upperfloor
      topic_subscription: switchbot/+/+/set
      update_interval: 30

Debug gateway logs 2021-05-28 14:46:35,723 DEBUG bt-mqtt-gw.workers.switchbot switchbot.py:31:status_update - Updating 1 switchbot devices 2021-05-28 14:46:35,726 DEBUG bt-mqtt-gw.workers.switchbot switchbot.py:33:status_update - Updating switchbot device 'upperfloorswitch' (D2:48:19:77:E2:39) 2021-05-28 14:46:35,729 DEBUG bt-mqtt-gw.workers_manager workers_manager.py:57:execute - Execution result of command SwitchbotWorker.status_update: [{'topic': 'switchbot/upperfloor/upperfloorswitch', 'payload': 'OFF'}] 2021-05-28 14:46:44,888 DEBUG bt-mqtt-gw.workers_manager workers_manager.py:194:_on_command_wrapper - Received command for switchbot on pi-ble2mqtt/switchbot/upperfloor/upperfloorswitch/set: b'"PRESS"' 2021-05-28 14:46:44,897 DEBUG bt-mqtt-gw.workers.switchbot switchbot.py:66:on_command - Setting "PRESS" on switchbot device 'upperfloorswitch' (D2:48:19:77:E2:39) 2021-05-28 14:46:45,917 ERROR bt-mqtt-gw.workers.switchbot logger.py:50:log_exception - Error setting "PRESS" on switchbot device 'upperfloorswitch' (D2:48:19:77:E2:39): BTLEDisconnectError Traceback (most recent call last): File "/opt/bt-mqtt-gateway/workers/switchbot.py", line 69, in on_command bot["bot"] = Peripheral(bot["mac"], "random") File "/usr/local/lib/python3.7/dist-packages/bluepy/btle.py", line 391, in __init__ self._connect(deviceAddr, addrType, iface) File "/usr/local/lib/python3.7/dist-packages/bluepy/btle.py", line 439, in _connect raise BTLEDisconnectError("Failed to connect to peripheral %s, addr type: %s" % (addr, addrType), rsp) bluepy.btle.BTLEDisconnectError: Failed to connect to peripheral D2:48:19:77:E2:39, addr type: random 2021-05-28 14:46:45,948 DEBUG bt-mqtt-gw.workers_manager workers_manager.py:57:execute - Execution result of command SwitchbotWorker.on_command: []

Server (please complete the following information):

Additional context I've already updated Bluez to Version 5.50

Regards Marc

MarcE85 commented 2 years ago

Additional Information: I've updated bluez to version 5.60, and its still not working.

Regards Marc