Core: After Update 0.88.1 i can't connect any bluetooth device

Created on 23 Feb 2019  ·  23Comments  ·  Source: home-assistant/core

Home Assistant release with the issue:

0.88.1

Last working Home Assistant release (if known):
0.88.0

Operating environment (Hass.io/Docker/Windows/etc.):

Virtual Env

Component/platform:

eq3 climate

Description of problem:
Hi, i've a home assistant Virtual Env installed on my RPI3 B+.
Recently i've upgraded home assistant and the rapsbian OS and i can't connect anymore to my bluetooth devices.

I have 4 device bluetooth: 2 eq3 climate and two bulb bluetooth magicblue (with a custom component).
Before the upgrade Everyone works fine, but after upgrade they stopped working.
I've also reinstall all the env removing home assistant from /srv and reinstall, but no work.
This is a bug of homeassistant or other?

Thanks

Problem-relevant configuration.yaml entries and (fill out even if it seems unimportant):


Traceback (if applicable):

on eq3-cli:

Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/srv/homeassistant/lib/python3.5/site-packages/bluepy/btle.py", line 353, in __init__
    self._connect(deviceAddr, 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 00:1A:22:0E:F2:BD, addr type: public

Additional information:

eq3btsmart stale

Most helpful comment

This have wrong labels and should get escalated somehow because bluetooth is a critical function for a lot of us.

All 23 comments

Looks like a potential problem with the dependency, but @rytilahti can you confirm?

Moreover i've seen that there isn't a polling of devices eq3 bluetooth (seeing the logs of HA). In the previous version there was much more logs about connections to eq3 bluetooth. Maybe is this the problem, that HA try only one connection on boot and nothing else?

Assuming it touches others besides eq3bt, I don't think it's a problem in the dependency then but likely on your OS' bluetooth stack. Do you see the devices while scanning with sudo hcitool lescan? Maybe you have changed your python environment and the current one does not have access to raw sockets (required by bluepy)?

I'm having the same issues since the last (?) update.

sudo hcitool lescan shows my climate devices (CC-RT-BLE) and Bluetooth presence detection is working too. So I think the problem is probably not my Bluetooth stack.

I'm using Home Assistant 0.88.1 in a Docker container.
Device: Raspberry Pi 3 B+ (using on-board Bluetooth)
OS: Raspbian Stretch (Kernel version 4.14.98-v7+)

Error log:

2019-02-26 08:37:29 ERROR (MainThread) [homeassistant.helpers.entity] Update for climate.thermostat_bedroom_dominique fails
Traceback (most recent call last):
  File "/usr/local/lib/python3.7/site-packages/eq3bt/connection.py", line 36, in __enter__
    self._conn.connect(self._mac)
  File "/usr/local/lib/python3.7/site-packages/bluepy/btle.py", line 408, in connect
    self._connect(addr, addrType, iface)
  File "/usr/local/lib/python3.7/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 00:1A:22:0C:51:63, addr type: public

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/usr/local/lib/python3.7/site-packages/homeassistant/helpers/entity.py", line 221, in async_update_ha_state
    await self.async_device_update()
  File "/usr/local/lib/python3.7/site-packages/homeassistant/helpers/entity.py", line 349, in async_device_update
    await self.hass.async_add_executor_job(self.update)
  File "/usr/local/lib/python3.7/concurrent/futures/thread.py", line 57, in run
    result = self.fn(*self.args, **self.kwargs)
  File "/usr/local/lib/python3.7/site-packages/homeassistant/components/climate/eq3btsmart.py", line 195, in update
    self.set_temperature(temperature=self._target_temperature)
  File "/usr/local/lib/python3.7/site-packages/homeassistant/components/climate/eq3btsmart.py", line 121, in set_temperature
    self._thermostat.target_temperature = temperature
  File "/usr/local/lib/python3.7/site-packages/eq3bt/eq3btsmart.py", line 203, in target_temperature
    self._conn.make_request(PROP_WRITE_HANDLE, value)
  File "/usr/local/lib/python3.7/site-packages/eq3bt/connection.py", line 71, in make_request
    with self:
  File "/usr/local/lib/python3.7/site-packages/eq3bt/connection.py", line 40, in __enter__
    self._conn.connect(self._mac)
  File "/usr/local/lib/python3.7/site-packages/bluepy/btle.py", line 408, in connect
    self._connect(addr, addrType, iface)
  File "/usr/local/lib/python3.7/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 00:1A:22:0C:51:63, addr type: public

I observed the Bluetooth communication with sudo btmon and noticed this:

@ MGMT Event: Connect Failed (0x000d) plen 8                      {0x0003} [hci0] 43.823940
        LE Address: 00:1A:22:0C:68:BE (eQ-3 Entwicklung GmbH)
        Status: Invalid Parameters (0x0d)
@ MGMT Event: Connect Failed (0x000d) plen 8                      {0x0001} [hci0] 43.823940
        LE Address: 00:1A:22:0C:68:BE (eQ-3 Entwicklung GmbH)
        Status: Invalid Parameters (0x0d)

I can confirm the same problem of @NullEnt1ty, using the sudo hcitool lescan i see two devices CC-RT-BLE but home assistant not connect to one of this devices and doesn't retry after start. Also i use a custom component for magicblue bulb bluetooth and i can't connect to this devices (in the version 0.87.x i hasn't thi problem) and disabling this custom component (removing the files on configuration and in custom_component folder) the problem persists.

I've reinstalled the pi-bluetooth library in my system (using sudo apt-get install --reinstall pi-bluetooth) and restarting the raspberry, but nothing.

I'am also using a 3 B and the internal BT, device tracking stopped working and more interestingly the whole home assistant startup hangs if I keep it in my config which caused 2 hours of headache.

Found a commit about bluetooth: https://github.com/home-assistant/home-assistant/commit/efa48848a5c27a175a29c282fc40f203bbce6609

In my case it can be fixed temporarily by calling hciconfig hci0 reset on the host. But sadly Bluetooth commands will stop working after a few minutes again as the device seems to be busy.
Is Home Assistant not releasing a resource or something like that? (Just a thought, my knowledge of Bluetooth LE is shallow)

Perhaps upgrading bluez could help. The version provided in the Raspbian repositories is quite old (5.43).

I've try hciconfig hci0 reset and works like @NullEnt1ty , the device connect but stop work after few minutes. Now i'm using the 0.88.2 but nothing change.

This have wrong labels and should get escalated somehow because bluetooth is a critical function for a lot of us.

i've now the 0.89.1 and eq3b component sometimes work and sometimes not work. I don't know if is a problem of library or other. Someone have see this bug?
i'm always using the RPi 3B+ with virtual env python

Here another stack trace and one of two device is connected

Log Details (ERROR)
Fri Mar 08 2019 16:48:19 GMT+0100 (Ora standard dell’Europa centrale)
Failed to connect to peripheral 00:1A:22:0E:F2:BD, addr type: public
Traceback (most recent call last):
  File "/srv/homeassistant/lib/python3.5/site-packages/eq3bt/connection.py", line 36, in __enter__
    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 00:1A:22:0E:F2:BD, addr type: public

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/srv/homeassistant/lib/python3.5/site-packages/homeassistant/components/websocket_api/commands.py", line 148, in handle_call_service
    connection.context(msg))
  File "/srv/homeassistant/lib/python3.5/site-packages/homeassistant/core.py", line 1133, in async_call
    self._execute_service(handler, service_call))
  File "/usr/lib/python3.5/asyncio/futures.py", line 380, in __iter__
    yield self  # This tells Task to wait for completion.
  File "/usr/lib/python3.5/asyncio/tasks.py", line 304, in _wakeup
    future.result()
  File "/usr/lib/python3.5/asyncio/futures.py", line 293, in result
    raise self._exception
  File "/usr/lib/python3.5/asyncio/tasks.py", line 239, in _step
    result = coro.send(None)
  File "/srv/homeassistant/lib/python3.5/site-packages/homeassistant/core.py", line 1155, in _execute_service
    await handler.func(service_call)
  File "/srv/homeassistant/lib/python3.5/site-packages/homeassistant/helpers/entity_component.py", line 188, in handle_service
    self._platforms.values(), func, call, service_name
  File "/srv/homeassistant/lib/python3.5/site-packages/homeassistant/helpers/service.py", line 278, in entity_service_call
    future.result()  # pop exception if have
  File "/usr/lib/python3.5/asyncio/futures.py", line 293, in result
    raise self._exception
  File "/usr/lib/python3.5/asyncio/tasks.py", line 241, in _step
    result = coro.throw(exc)
  File "/srv/homeassistant/lib/python3.5/site-packages/homeassistant/helpers/service.py", line 294, in _handle_service_platform_call
    await func(entity, data)
  File "/srv/homeassistant/lib/python3.5/site-packages/homeassistant/components/climate/__init__.py", line 564, in async_service_temperature_set
    await entity.async_set_temperature(**kwargs)
  File "/usr/lib/python3.5/asyncio/futures.py", line 380, in __iter__
    yield self  # This tells Task to wait for completion.
  File "/usr/lib/python3.5/asyncio/tasks.py", line 304, in _wakeup
    future.result()
  File "/usr/lib/python3.5/asyncio/futures.py", line 293, 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 "/srv/homeassistant/lib/python3.5/site-packages/homeassistant/components/climate/eq3btsmart.py", line 122, in set_temperature
    self._thermostat.target_temperature = temperature
  File "/srv/homeassistant/lib/python3.5/site-packages/eq3bt/eq3btsmart.py", line 203, in target_temperature
    self._conn.make_request(PROP_WRITE_HANDLE, value)
  File "/srv/homeassistant/lib/python3.5/site-packages/eq3bt/connection.py", line 71, in make_request
    with self:
  File "/srv/homeassistant/lib/python3.5/site-packages/eq3bt/connection.py", line 40, in __enter__
    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 00:1A:22:0E:F2:BD, addr type: public

The bluetooth device tracker is also broken with 89.1. It finds 1 device and then it hangs.

Hi, i've try reinstalling the firmware bluetooth using this:
sudo apt-get install --reinstall bluez bluez-firmware libbluetooth3 pi-bluetooth raspberrypi-sys-mods
and now i have a connection with the eq3b components, but there is always the message
bluepy.btle.BTLEException: Failed to connect to peripheral 00:1A:22:0E:F2:BD, addr type: public and sometimes i can't update the status of the thermostat.

So, good but not so good :)

Someone can try with "fix" on RPI?

Thanks.

hass version 90.1 still no change, startup takes ages, finds one device and hangs after that.

Thx @majuss, i've solved using the command in my last post. Now, after two
weeks testing, all woarks and i now running the 0.90.1.
So try the reinstallation with command in my last post, maybe works :)

Maybe we can leave the issue open to collect other same
problematics......... or not :)

Il giorno sab 23 mar 2019 alle ore 12:00 majuss notifications@github.com
ha scritto:

hass version 90.1 still no change, startup takes ages, finds one device
and hangs after that.


You are receiving this because you authored the thread.
Reply to this email directly, view it on GitHub
https://github.com/home-assistant/home-assistant/issues/21348#issuecomment-475860261,
or mute the thread
https://github.com/notifications/unsubscribe-auth/AFKRGhlYmy3UmcNMMh9_qup9ZMfhDX9Oks5vZglggaJpZM4bN1j3
.

Nope still no luck. Reinstalled everything and restarted the pi, no devices are showing up in known_devices :(

In know_devices? In my system I don't use the discovery component for
Bluetooth devices, because in Eq3 component doesn't use discovery...

Right?

Il sab 23 mar 2019, 12:49 majuss notifications@github.com ha scritto:

Nope still no luck. Reinstalled everything and restarted the pi, no
devices are showing up in known_devices :(


You are receiving this because you authored the thread.
Reply to this email directly, view it on GitHub
https://github.com/home-assistant/home-assistant/issues/21348#issuecomment-475863228,
or mute the thread
https://github.com/notifications/unsubscribe-auth/AFKRGkWOWvTag7iACAh8fzyjO_Q0sr8Xks5vZhS-gaJpZM4bN1j3
.

Yep I'am talking about the BT device_tracker.

Ok Thx :)

Il sab 23 mar 2019, 12:55 majuss notifications@github.com ha scritto:

Yep I'am talking about the BT device_tracker.


You are receiving this because you authored the thread.
Reply to this email directly, view it on GitHub
https://github.com/home-assistant/home-assistant/issues/21348#issuecomment-475863645,
or mute the thread
https://github.com/notifications/unsubscribe-auth/AFKRGh7lME-vXvqfCQPNlx1Gd8Wl-rgqks5vZhYqgaJpZM4bN1j3
.

Okay, big news. I got it working! It seems to be a firmware / driver problem rather than a bug in Home Assistant. Don't ask me why it started to be a problem suddenly. Maybe a bluetooth-related package upgrade caused the issues.

Anyway. I decided to move to Arch Linux, because the package sources are more bleeding edge compared to the conservative "Debian-way" that Raspbian is following (old but stable packages).

Arch Linux provides a newer version of bluez (5.50-6 at the time of writing). This version seems to be a lot more reliable regarding Bluetooth LE scans.

Here are a few specs of my new setup:

  • Device: Raspberry Pi 3B+
  • Kernel: Linux 4.19.30-2-ARCH
  • OS: Arch Linux ARM (ARMv7)
  • Bluez: 5.50-6
  • pi-bluetooth: 1.2_3-1

I followed these instructions to install Arch Linux on my Pi. Make sure to use the ARMv7 version. AArch64 did not work for me 100% correctly (Bluetooth was not working, system crashes, etc.).

I installed bluez 5.50 manually on raspbian (download, compile, install) but no change at all. So it's not the bluez lib alone.

There hasn't been any activity on this issue recently. Due to the high number of incoming GitHub notifications, we have to clean some of the old issues, as many of them have already been resolved with the latest updates.
Please make sure to update to the latest Home Assistant version and check if that solves the issue. Let us know if that works for you by adding a comment 👍
This issue now has been marked as stale and will be closed if no further activity occurs. Thank you for your contributions.

Hi, i've try reinstalling the firmware bluetooth using this:
sudo apt-get install --reinstall bluez bluez-firmware libbluetooth3 pi-bluetooth raspberrypi-sys-mods
and now i have a connection with the eq3b components, but there is always the message
bluepy.btle.BTLEException: Failed to connect to peripheral 00:1A:22:0E:F2:BD, addr type: public and sometimes i can't update the status of the thermostat.

So, good but not so good :)

Someone can try with "fix" on RPI?

Thanks.

@jempo
I have a randon disconnection and my eq3btsmart does not work, and i have the same issue , im on latest 0.9x how did you re install the drivers? I connected using ssh but there is no apt install command, so I'm not sure how to "update" would you mind help me? thanks

Was this page helpful?
0 / 5 - 0 ratings