- Saved searches
- Use saved searches to filter your results more quickly
- License
- tjntomas/MI-Bluetooth-Remote-for-Home-Assistant
- Name already in use
- Sign In Required
- Launching GitHub Desktop
- Launching GitHub Desktop
- Launching Xcode
- Launching Visual Studio Code
- Latest commit
- Git stats
- Files
- README.md
- About
- Control any bluetooth device
- How to Enable Bluetooth in Windows 11
- Using the Action Center
- Using the Settings Menu
- Pair Windows 11 with a Bluetooth Device
- Remove or Disconnect a Bluetooth Device from Windows 11
- Use the Bluetooth Device Wizard
- Troubleshoot Bluetooth in Windows 11
- Using Bluetooth on Windows 11
Saved searches
Use saved searches to filter your results more quickly
You signed in with another tab or window. Reload to refresh your session. You signed out in another tab or window. Reload to refresh your session. You switched accounts on another tab or window. Reload to refresh your session.
Use a bluetooth remote control with Home Assistant
License
tjntomas/MI-Bluetooth-Remote-for-Home-Assistant
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Name already in use
A tag already exists with the provided branch name. Many Git commands accept both tag and branch names, so creating this branch may cause unexpected behavior. Are you sure you want to create this branch?
Sign In Required
Please sign in to use Codespaces.
Launching GitHub Desktop
If nothing happens, download GitHub Desktop and try again.
Launching GitHub Desktop
If nothing happens, download GitHub Desktop and try again.
Launching Xcode
If nothing happens, download Xcode and try again.
Launching Visual Studio Code
Your codespace will open once ready.
There was a problem preparing your codespace, please try again.
Latest commit
Git stats
Files
Failed to load latest commit information.
README.md
Use a bluetooth remote control connected to a linux device with Home Assistant
NOTE: There is a dockerized version here that might suit some persons better. Docker version of bluetooth remote for HA
I wanted to be able to use a spare Xiaomi MI Remote control and get the keypresses as events into Home Assistant so I can use it as general purpose remote. The remote I used can be bought for around $12 on banggood.com or wish.com. Mi bluetooth remote
The cheap WeChip G20S remotes will also work: WeChip remote
I paired the remote control with a NUC running Ubuntu that I use as a media player, but a Raspberry Pi or any other maching running a linux OS should work. I then wrote a simple python3 script to listen to the remote keypress events and send the events to Home Assistant.
To use the script, you need to:
- Install the dependencies in the script. They should all be present on your system with the exception of the evdev module which you can find here. https://pypi.org/project/evdev/
- Look in /dev/input and make a note of the highest numbered device
- Pair the remote control to the computer, as you would pair any bluetooth device.
- Look again in /dev/input and make note of the new device that has been created. This is your bluetooth remote control.
- Fill in the name of the path to your remote control device in the python script, i.e. /dev/input/event9
- Add the details for your Home Assistant instance in the script.
In total, you will need to edit the following lines in the script:
BASE_API = "http://192.168.1.20:8123/api/" # URL to your HA instance. DEV_INPUT = "/dev/input/event9" API_KEY = "A valid HA long-lived access token" HA_EVENT_NAME = "mi_bt_remote" # Arbitrary name of the event that will get fired. GRAB_DEVICE = False # Set to True to lock the device to this script. The system will not receive any events from the device. # i.e, the remote will not work as a volume control by default.
sudo python3 bt_remote_event.py
to see that it works. Sudo is necessary to access the input device. Then, in Home Assistant, you can subscribe to the mi_bt_remote event in developer tools.
Now, set up the script as a daemon by copying the btmon.service file to your service directory. You need to edit the path to the python script in the service file. Enable the service and start it. The service need to run as user root.
You can now use the events as triggers in automations in Home Assistant.
About
Use a bluetooth remote control with Home Assistant
Control any bluetooth device
Sick of wired devices? You can connect a mouse, keyboard, speakers, headphones, and a number of other devices to a Windows 11 PC with Bluetooth connectivity. Thankfully, connecting Bluetooth devices to a Windows 11 PC is a straightforward process. Here’s how to do it.
How to Enable Bluetooth in Windows 11
Whether Bluetooth is enabled or not will depend on your PC and how Windows 11 was installed. It can easily be turned on or off from the Action Center or the Settings menu, however.
Using the Action Center
To check, open Action Center using the keyboard shortcut Windows key + A (or select it in the bottom-left). Next, click the Bluetooth button to enable it.
Using the Settings Menu
You can also enable or disable Bluetooth via the Settings menu on Windows 11. To do this, click Start and select Settings. In the Settings menu, select Bluetooth & Devices from the left column. On the right, scroll down and toggle the Bluetooth switch on or off.
Pair Windows 11 with a Bluetooth Device
If your PC’s Bluetooth radio is on, you can now pair (connect) with a Bluetooth device. To do this, bring the Bluetooth device you want to connect within the pairing range of your Windows 11 PC. Also, make sure it’s powered on and in “pairing mode” so it’s discoverable. The steps to do this will vary, depending on your device. On your PC, open the Settings menu via Start. Select Bluetooth & Devices on the right, then click the Add Device button. You can press this at the top or bottom of the menu—both will work. In the Add a device menu, click the Bluetooth option at the top. Windows will then start scanning for nearby Bluetooth devices. When the one you want to connect appears, click on it. In this example, Windows 11 is connecting to a pair of Logitech MX Sound Bluetooth speakers. When the connection is established, you’ll receive a message letting you know the device has successfully paired with your PC. You can start using your Bluetooth device with Windows 11 immediately.
Remove or Disconnect a Bluetooth Device from Windows 11
If you want to remove a Bluetooth device, go to Start > Settings > Bluetooth & Devices. Find the Bluetooth device you want to remove and click the three dots icon in the upper-right corner. Next, click Disconnect if you want to unpair the device. That keeps it listed in your Bluetooth section, and you’ll be able to connect to it again when needed. To reconnect, click the Connect button. If you want to remove the device altogether, click Remove Device from the menu. To confirm, click Yes to the verification dialog.
Use the Bluetooth Device Wizard
You can still use classic Windows features to add Bluetooth devices to Windows 11. While these features are supported at launch, they may not work in the future. Make sure your device is in pairing mode, switched on, and discoverable. Next, press Start and type devicepairingwizard—select it from the Best match result at the top. This will open the classic pairing wizard and search for Bluetooth devices. Select the device you want to add, then click Next. You’ll see a progress bar while Windows 11 is connecting to the device. Once connected, the device will appear in the “Device and Printers” section of the classic Control Panel. It should also appear in the Bluetooth devices section in the Settings menu. If you want to disconnect and remove the device in the classic Control Panel, right-click on the device in the Devices and Printers menu. Next, click Remove Device from the menu that appears. Click Yes on the verification message that pops up to confirm the device removal.
Troubleshoot Bluetooth in Windows 11
- Check the device is powered on. It may seem obvious, but make sure the Bluetooth device is powered on, in pairing mode, so it’s discoverable, and ensure it’s in range.
- Disconnect other devices. If you have multiple devices connected, try disconnecting them, as they may interfere with each other.
- Update your PC. Manually run Windows Update to ensure your system and drivers are up to date.
- Update your Bluetooth device drivers. Make sure Bluetooth drivers are updated—you can do this via the Device Manager or by downloading a device driver from the manufacturer and installing it manually.
- To do this, right-click the Start button and click Device Manager from the menu that appears.
- Expand the Bluetooth option, right-click the driver to update, and click Update Driver from the menu.
- Note that you can also right-click the driver, click Uninstall, then restart your PC.
Using Bluetooth on Windows 11
The steps above should help you to connect and manage Bluetooth devices on Windows 11. You can easily connect to Bluetooth devices in Settings, but you can still use the classic Control Panel to connect to devices. Switching Bluetooth on or off is easy, thanks to the Action Center (as well as quick-access keyboard shortcuts).
If you haven’t upgraded to Windows 11, you can pair Bluetooth devices with Windows 10, but the steps may vary. For more on Windows 11, check out how to create a mobile hotspot or learn how you can customize quick actions in the Action Center.