Home Assistant: avoid disconnecting a Bluetooth dongle

Does your Bluetooth dongle for Home Assistant disconnect regularly? We have the solution : AUTOMATIC POWER ON !

If you use BLE, your Bluetooth USB dongle connected to Raspberry (Pi4) may turn off by itself randomly. This is normal, it is a kernel problem, or kernel, of the Raspbery Pi with Home Assistant OS. Fortunately, it is possible to bypass it by automating a regular switching on of the dongle. Here is how to do it.

  1. Prerequisites :

    - A Bluetooth USB dongle like the Sena Parani UD100
    - Home Assistant OS (installation tutorial),
    - " SSH & Web Terminal »Installed, with root as username (Obligatory)

    If you already have a username entered in the settings of SSH & Web Terminal, change it to " root ».

    In the Terminal, it is possible to see the status of the Bluetooth Controller.

    Orders : "Bluetoothctl" then "show"

    "Powered" must be on "yes"

    If this is not the case, it is possible to turn it on manually with the command: « power on »

    Unfortunately, this manipulation comes up a little too often. So we will fix this problem permanently.

  2. Step 1: Prepare the SSH login without password

    Connect in SSH from a computer Windows or Mac, if you have changed your usernameit will take delete the file " known_host », the terminal will give you the path to your computer to find it, then type this command, replacing the following “@” with your Home Assistant IP address.

    ssh [email protected][HASSIOIP]

    Create the folder with this command:

    mkdir /config/.ssh

    Create the key by typing:


    And have it stored here with this command:


    Do not put a password! Validate with Enter several times without putting any.

  3. Step 2: Create the Shell Commands

    In Home Assistant now, in the file " configuration.yaml », add the following lines:

    turn_bluetooth_off: 'ssh -o UserKnownHostsFile = / dev / null -o StrictHostKeyChecking = no -i /config/.ssh/id_rsa [email protected] sudo bluetoothctl power off 'turn_bluetooth_on:' ssh -o UserKnownHostsFile = / dev / null -o StrictHostKeyChecking = no -i /config/.ssh/id_rsa [email protected] sudo bluetoothctl power on '
  4. Step 3: Create Automation

    This automation will be used to make a power off then a power on Bluetooth dongle, every 5 minutes (duration to be adapted as needed).
    We also added " when starting Home Assistant As a trigger.

    alias: Restart Bluetooth description: '' trigger: - platform: time_pattern minutes: / 5 condition: [] action: - service: shell_command.turn_bluetooth_off - service: shell_command.turn_bluetooth_on mode: single


Make a restart by Home Assistant to take these changes into account, and your dongle will no longer cause you to worry about disconnecting!
We would like to thank Vincent Ghesquiere, member of the Home Assistant Facebook group - Entraide Francophone, which was incredibly efficient in compiling and assembling the solutions. Thank you !
Passionate about technology, I discovered the world of Smart Home with Xiaomi, then Alexa and Les Alexiens led me to become passionate about Home Assistant, which I master better every day!