Switchbot keeps disconnecting


I have connected my switchbot and it works fine for the first 5 minutes and after that it keeps disconnecting the error log is below:

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/usr/src/app/homeassistant/components/websocket_api/commands.py", line 122, in handle_call_service
  File "/usr/src/app/homeassistant/core.py", line 1138, in async_call
    self._execute_service(handler, service_call))
  File "/usr/src/app/homeassistant/core.py", line 1160, in _execute_service
    await handler.func(service_call)
  File "/usr/src/app/homeassistant/helpers/entity_component.py", line 188, in handle_service
    self._platforms.values(), func, call, service_name
  File "/usr/src/app/homeassistant/helpers/service.py", line 314, in entity_service_call
    future.result()  # pop exception if have
  File "/usr/src/app/homeassistant/helpers/service.py", line 328, in _handle_service_platform_call
    await getattr(entity, func)(**data)
  File "/usr/local/lib/python3.7/concurrent/futures/thread.py", line 57, in run
    result = self.fn(*self.args, **self.kwargs)
  File "/usr/src/app/homeassistant/components/switchbot/switch.py", line 55, in turn_on
    if self._device.turn_on():
  File "/config/deps/lib/python3.7/site-packages/switchbot/__init__.py", line 59, in turn_on
    return self._sendpacket(ON_KEY)
  File "/config/deps/lib/python3.7/site-packages/switchbot/__init__.py", line 50, in _sendpacket
    if retry < 1 or not self._connect():
  File "/config/deps/lib/python3.7/site-packages/switchbot/__init__.py", line 36, in _connect
  File "/config/deps/lib/python3.7/site-packages/bluepy/btle.py", line 391, in __init__
    self._connect(deviceAddr, addrType, iface)
  File "/config/deps/lib/python3.7/site-packages/bluepy/btle.py", line 433, in _connect
    self._writeCmd("conn %s %s\n" % (addr, addrType))
  File "/config/deps/lib/python3.7/site-packages/bluepy/btle.py", line 305, in _writeCmd
BrokenPipeError: [Errno 32] Broken pipe

The above error keeps recurring if I was to turn the switch on/off from HA.

@Danielhiversen can you please look into it? Do we have to connect it to Bluetooth on the device running HA?