im-0 / cometblue

Command line tool and python library for "Comet Blue" thermostat
GNU General Public License v3.0
34 stars 24 forks source link

connect: Device or resource busy (16) #12

Closed danielkucera closed 5 years ago

danielkucera commented 5 years ago

After some time, the communiation gets stuck and I have to restart bluetoothd. Any ideas how to fix this?

root@orangepioneplus:~# cometblue -f shell-var device -p 0000 B7:1E:5A:99:BF:21 get temperatures
Traceback (most recent call last):
  File "/usr/local/bin/cometblue", line 10, in <module>
    sys.exit(main())
  File "/usr/local/lib/python2.7/dist-packages/cometblue/cli.py", line 682, in main
    return _main(obj=_ContextObj())
  File "/usr/local/lib/python2.7/dist-packages/click/core.py", line 764, in __call__
    return self.main(*args, **kwargs)
  File "/usr/local/lib/python2.7/dist-packages/click/core.py", line 717, in main
    rv = self.invoke(ctx)
  File "/usr/local/lib/python2.7/dist-packages/click/core.py", line 1137, in invoke
    return _process_result(sub_ctx.command.invoke(sub_ctx))
  File "/usr/local/lib/python2.7/dist-packages/click/core.py", line 1137, in invoke
    return _process_result(sub_ctx.command.invoke(sub_ctx))
  File "/usr/local/lib/python2.7/dist-packages/click/core.py", line 1137, in invoke
    return _process_result(sub_ctx.command.invoke(sub_ctx))
  File "/usr/local/lib/python2.7/dist-packages/click/core.py", line 956, in invoke
    return ctx.invoke(self.callback, **ctx.params)
  File "/usr/local/lib/python2.7/dist-packages/click/core.py", line 555, in invoke
    return callback(*args, **kwargs)
  File "/usr/local/lib/python2.7/dist-packages/click/decorators.py", line 17, in new_func
    return f(get_current_context(), *args, **kwargs)
  File "/usr/local/lib/python2.7/dist-packages/cometblue/cli.py", line 622, in real_get_fn
    pin=ctx.obj.pin) as device:
  File "/usr/local/lib/python2.7/dist-packages/cometblue/device.py", line 450, in __enter__
    security_level=self._security_level)
RuntimeError: connect: Device or resource busy (16)
root@orangepioneplus:~# service bluetooth restart
root@orangepioneplus:~# cometblue -f shell-var device -p 0000 B7:1E:5A:99:BF:21 get temperatures
COMETBLUE_CURRENT_TEMP='24.500000'
COMETBLUE_MANUAL_TEMP='24.000000'
COMETBLUE_TARGET_TEMP_L='19.000000'
COMETBLUE_TARGET_TEMP_H='22.000000'
COMETBLUE_OFFSET_TEMP='0.000000'
COMETBLUE_WINDOW_OPEN_DETECTION='4'
COMETBLUE_WINDOW_OPEN_MINUTES='10'
root@orangepioneplus:~# 
danielkucera commented 5 years ago

looks like following command fixes the error too: echo "disconnect B7:1E:5A:99:BF:21" | bluetoothctl

Benjalien commented 5 years ago

Hi Daniel, I have the same issue, so I tried your suggestion and it doesn't really help on my setup :( I just wanted to let you know. Thanks for sharing!

danielkucera commented 5 years ago

@Benjalien , I switched to this fork and it works without problems: https://github.com/xrucka/cometblue

Benjalien commented 5 years ago

I'll have a look at it :)