alextud / ha-switchbot-curtain

Controls switchbot curtain using Home Assistant
MIT License
55 stars 16 forks source link

bluepy.btle.BTLEManagementError: Management not available (permissions problem?) #19

Open nmajin opened 3 years ago

nmajin commented 3 years ago

Seeing these issues recently in the logs and it seems like the status cannot be captured; Google Assistant also mentions it cannot communicate although the curtain does work

2021-06-28 22:17:33 ERROR (MainThread) [homeassistant.helpers.entity] Update for cover.curtain fails
Traceback (most recent call last):
  File "/usr/src/homeassistant/homeassistant/helpers/entity.py", line 350, in async_update_ha_state
    await self.async_device_update()
  File "/usr/src/homeassistant/homeassistant/helpers/entity.py", line 558, in async_device_update
    raise exc
  File "/usr/local/lib/python3.8/concurrent/futures/thread.py", line 57, in run
    result = self.fn(*self.args, **self.kwargs)
  File "/config/custom_components/switchbot-curtain/cover.py", line 164, in update
    self._device.update()
  File "/usr/local/lib/python3.8/site-packages/switchbot/__init__.py", line 189, in update
    devices = bluepy.btle.Scanner().scan(scan_timeout)
  File "/usr/local/lib/python3.8/site-packages/bluepy/btle.py", line 852, in scan
    self.start(passive=passive)
  File "/usr/local/lib/python3.8/site-packages/bluepy/btle.py", line 790, in start
    self._mgmtCmd("le on")
  File "/usr/local/lib/python3.8/site-packages/bluepy/btle.py", line 309, in _mgmtCmd
    rsp = self._waitResp('mgmt')
  File "/usr/local/lib/python3.8/site-packages/bluepy/btle.py", line 366, in _waitResp
    raise BTLEManagementError("Management not available (permissions problem?)", resp)
bluepy.btle.BTLEManagementError: Management not available (permissions problem?)
nmajin commented 3 years ago

So I was looking at this again and tried running my HA docker instance with --privileged enabled and that resolved this issue and the battery reading as well, but obviously this is not the most secure option.

Any idea if we can get around this by passing in the bluetooth device or something else?