MiPower is a Home Assistant integration that allows you to control the power state of media players that don't support traditional Wake-on-LAN (WOL), but can be "woken up" with a Bluetooth pairing request. It's specifically designed for devices like Xiaomi Mi Box, but may work with other similar Android TV boxes.
This integration creates a switch entity in Home Assistant:
- TURNING ON the switch wakes up the device by sending a series of Bluetooth commands via
bluetoothctl - TURNING OFF the switch calls the
media_player.turn_offservice for the linked device - The switch state automatically synchronizes with the linked media player entity's state
MiPower is developed with the vision of contributing value to the open-source community. Your support is vital to maintain this project's continuity and development speed.
If you appreciate my work, you can support me through GitHub Sponsorships or the platforms below. Thank you in advance!
Alternatively, you can click the Sponsor button (❤️) in the top right corner of the repository to see all funding options.
- Home Assistant OS / Supervised / Container: This integration requires a Linux-based Home Assistant installation where the
bluetoothctlcommand-line tool is available and accessible. It DOES NOT WORK on Windows-based Home Assistant Core installations.
This integration is available as a custom repository in HACS.
- Go to your HACS control panel.
- Click on Integrations.
- Click the three dots in the top right corner and select "Custom repositories".
- Enter the following information in the dialog:
- Repository:
https://github.com/DenizOner/MiPower - Category:
Integration
- Repository:
- Click "Add".
- "MiPower" integration will now appear in your HACS list. Click on it.
- Click "Download" and then "Download" again in the next window.
- After download completes, RESTART HOME ASSISTANT for the integration to load.
Although HACS is the recommended method, you can also install the integration manually.
- Download or clone this repository to your local machine.
- Copy the
custom_components/mipowerfolder from the repository. - Paste the copied
mipowerfolder into your Home Assistant configuration directory'scustom_componentsfolder. Create thecustom_componentsfolder if it doesn't exist.- The final path should look like:
.../config/custom_components/mipower/
- The final path should look like:
- Restart Home Assistant.
After restarting, you can add and configure the MiPower switch.
- Go to Settings > Devices & Services.
- Click the "+ Add Integration" button in the bottom right corner.
- Search for "MiPower" and click on it.
This is the simplest way to configure the integration.
- When prompted, select "Easy Setup".
- The integration will automatically discover Bluetooth-enabled media players in your system.
- Select your target device (e.g., "Xiaomi Mi Box 4") from the dropdown list.
- Click "Submit".
That's it! The integration will create a switch linked to your media player.
Use this method if Easy Setup doesn't find your device or if you need to configure advanced timing settings from the start.
- Step 1: Device Selection
- Select "Advanced Setup".
- Choose your target media player from the list of all media players in your Home Assistant.
- Step 2: MAC Address
- The integration will try to find the Bluetooth MAC Address of the selected device.
- If found, it will be pre-filled. Make sure it's correct.
- If not found, you'll need to manually enter your device's Bluetooth MAC Address.
- Step 3: Timing Settings
- You can configure various timeouts and delays for Bluetooth commands. Default values work well for most users.
- Click "Submit" to complete the setup.
After configuring your MiPower switch, you can adjust timing settings at any time.
- Go to Settings > Devices & Services.
- Find the MiPower integration and click "Configure".
- Adjust the sliders for debounce, timeouts, and delays as needed.
If you're experiencing issues with your MiPower integration, you can access detailed diagnostics information:
- Go to Settings > Devices & Services.
- Find the MiPower integration and click on it.
- Click the "System Options" (three dots) menu in the top right corner.
- Select "Download Diagnostics" to get comprehensive troubleshooting information including:
- Your current configuration settings
- Discovered Bluetooth devices
- Media player discovery results
- Entity information and status
In the configuration or options menu, you can fine-tune the timing of Bluetooth commands. Default values work well for most users.
-
Turn-On Debounce (seconds): Minimum time that must pass before the 'turn-on' command can be executed again. This prevents spamming the device with wake-up signals if the switch is toggled rapidly. Also serves as the overall timeout for the wake-up operation - if the device doesn't respond within this time, the operation fails.
-
Turn-Off Debounce (seconds): Minimum time that must pass before the 'turn-off' command can be executed again.
-
Inter-Step Delay (seconds): Delay between major steps in the wake-up process. This gives each step time to complete properly.
-
Process Spawn Timeout (seconds): Maximum time to wait for the
bluetoothctlprocess to start. If it doesn't start within this time, the wake-up attempt fails. -
Bluetooth Signal Duration (seconds): How long the Bluetooth pairing signal is broadcast. If the media player becomes available during this broadcast, the signal stops early to avoid unnecessary Bluetooth activity.
-
Bluetooth Scan Duration (seconds): How long to scan for Bluetooth devices before attempting to send pairing commands. Longer scans help find devices that announce their presence slowly.
-
Bluetooth Scan Stop Timeout (seconds): Maximum time to wait for the scan to stop cleanly.
The integration uses a smart wake-up algorithm:
-
Checks if the media player is already on/available before sending any Bluetooth commands
-
Broadcasts pairing signals for the configured duration (or stops early if device becomes available)
-
Waits for the device to fully wake up with timeout
-
Provides detailed logging for troubleshooting