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.
- A Bluetooth USB dongle like the Sena Parani UD100
- Home Assistant OS (installation tutorial),
- " SSH & Web Terminal »Installed, with root as username (Obligatory)€48,00Domadoo.fr
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.
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:
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.
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 '
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