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

pi4 docker issues #237

Open jjbrunton opened 2 years ago

jjbrunton commented 2 years ago

[] I've read the Troubleshooting Wiki, my problem is not described there and I am already using the specified minimum bluez version.

Describe the bug A clear and concise description of what the bug is.

To Reproduce Steps to reproduce the behavior:

  1. Use the docker version of the application
  2. Fill out the config similar to:
    lywsd03mmc:
      args:
        devices:
          bedroom: A4:C1:38:48:58:28
          living_room: A4:C1:38:06:57:E0
          office: A4:C1:38:0B:5F:2A
          bathroom: A4:C1:38:52:DB:35
          vivarium: A4:C1:38:B7:B1:16
        topic_prefix: mijasensor_gen2
        passive: false            # Set to true for sensors running custom firm>
        #command_timeout: 30       # Optional timeout for getting data for non->
        #scan_timeout: 20          # Optional timeout for passive scanning
      update_interval: 300
  3. Start the container
  4. Errors show:
2021-09-25 09:05:45,435 DEBUG bt-mqtt-gw.workers.lywsd03mmc lywsd03mmc.py:67:connected - A4:C1:38:52:DB:35 - connected 

2021-09-25 09:05:45,447 ERROR bt-mqtt-gw.workers.lywsd03mmc logger.py:50:log_exception - Failed connect from lywsd03mmc to device 'bathroom': BTLEDisconnectError

Traceback (most recent call last):

  File "/application/workers/lywsd03mmc.py", line 44, in status_update

    ret = lywsd03mmc.readAll()

  File "/application/workers/lywsd03mmc.py", line 80, in readAll

    with self.connected() as device:

  File "/usr/local/lib/python3.8/contextlib.py", line 113, in __enter__

    return next(self.gen)

  File "/application/workers/lywsd03mmc.py", line 69, in connected

    device.connect(self.mac)

  File "/usr/local/lib/python3.8/site-packages/bluepy/btle.py", line 445, in connect

    self._connect(addr, addrType, iface)

  File "/usr/local/lib/python3.8/site-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 A4:C1:38:52:DB:35, addr type: public

Expected behavior Home assistant using the ble addon from HACS is able to query the information from these devices, it appears as though this app has an issue (I also notice it doesn't take the encryption key?)

Server (please complete the following information):

Micha70 commented 2 years ago

If you use on PI 4 check the following topic: https://github.com/RPi-Distro/firmware-nonfree/issues/8#issuecomment-608344384

I had a similar problem. And after downgrading wifi firmware like described here

$ wget http://archive.raspberrypi.org/debian/pool/main/f/firmware-nonfree/firmware-brcm80211_20190114-1+rpt3_all.deb $ sudo dpkg -i ./firmware-brcm80211_20190114-1+rpt3_all.deb

is working like a charm.

As far as I understood, there is a conflict between wifi 2.4Ghz and bluetooth. As an alternative you disable 2.4Ghz Wifi.