Manage Xiaomi MITV emulating the remote control as it is an android bluetooth device


I’m new to Home Assistant, but I’ve knowledge about computers/devices/programming and this stuff.

I’ve a Xiaomi tv at home and I’m interested in controlling the TV from my home assistant via scripts and automation in general. But, in order to implement this functionality first the devices must be recognized by ha.

The first problem I faced is that in order to interact with the TV I need to enable ADB “Android Debug Bridge” and I have the feeling this is NOT the right way to go. Why shall I enable debugging of my TV device if all I want is to manage the volume, change the selected channel and turn it ON and OFF. Of course I’ve been able to install ADB in my TV-Box and I managed for the TV to be recognized by HA, but there are several collateral things unresolved starting with the fact that I can’t simply turn ON/OFF the TV.

On the other hand, the TV can be fully controlled by the remote control. It is a simple Bluetooth device paired with the TV. And the remote has all the functionality I need.

I’ve been exploring if there is a kind of “Android Remove TV” emulator integration available but I find nothing.

The entire purpose of this thread is to:

  1. Share experiences and ideas about this path.
  2. Share and collect other threads with information useful for this purpose.
  3. Develop or help develop a more simple mechanism to get access and control over devices at home, not linking directly with the device (it might not have internet connection at all) but via their own remote controllers or emulators of the remote controllers.

Any help is welcome. I’ll try to post here links to the documentation.


1 Like

Pointers to documentation for reference:

Google TV Pairing Protocol

Android TV overview

Anymote Protocol

Today I got a new Xiaomi TV.
Unfortunately I’m unable to turn it on or off by using Home Assistant.
I was able to cast a video from an url and control volume but if the tv is off, I can’t do anything to wake it up.
I went to enable the odb debugging options and it’s only available for USB, not that useful when you have a WiFi TV 10 meters away from the home assistant server.

Seems like we’re out of luck with this brand

I just found out I can turn on the TV by using wake on lan feature after enabling it on developer options!

Hi guys… same issue here.
Have you figured out a solution?

I’m using Xiaomi MI Stick and via ADB command it never powers ON… just by BT remote control.

To power off the SLEEP or POWER ADB commands works, but to power on just by remote control.

Any thoughts?

I have the xiaomi tv with build in chromecast. it can be turned on off from ha. i installed android remote app from apps store on my tv. I use powerline adapter for net connection to router. To stop tv from going into deep sleep I use binanry sensor

- platform: ping
  name: Android TV
  count: 1
  scan_interval: 15

Thanks for your solution! The problem here is that it will continue to heat and consume, as it if it was reproducing.

I think a good solution would be bluetooth pairing with Mi Box S to emulate a second remote in order to wake it up, as the title suggested. Unfortunately I haven’t found how to do it.

I’ve found this repo.
It enables to receive the commands from the remote into HA htrough bluetooth.
I wonder if it would be possible to send the same bluetooth command through a a proxy and power on the mi tv that way.

I’ve also heard about the mi box having an IR receiver, but that doesn’t seem the case :(.

I have noticed that the Android Google Tv app is able to wake up my Xiaomi box.
I captured bluetooth traffic and I discovered it is using L2CAP packets to wake up the box.

The packet looks like this :

I have currently no understanding of this protocol, but I guess the device is listening to some BLE command in order to wake out of deep sleep. Maybe there is a dev from another bluetooth integration that has some better understanding that can give us better insight.

I have a Mi Box TV and I finally found a way to connect via Bluetooth and turn on the device

Create a python file in home assistant with the following code, changing only the Bluetooth MAC Address

Attention! It’s the “MAC Address” of bluetooth, not wifi.


import socket
s = socket.socket(
s.connect(('XX:XX:XX:XX:XX:XX', 2))

Then create a new entity in the “configuration.yaml” file, as in the example below:

  - switch:
      name: Ligar TV
      command_on: python3 /config/

Restart your HA and test =)


This looks promising! I’m going to try it!

I just tried this now, and I’m doing something wrong. I added the python script, used the bluetooth MAC of my MiBox, added the configuration portion to the YAML file, restarted and tested. (I used a different filename from yours) Unfortunately, the logfile isn’t really giving me any clues:

2023-11-29 17:56:10.437 ERROR (SyncWorker_4) [homeassistant.components.command_line.utils] Command failed (with return code 1): python3 /config/
2023-11-29 17:56:10.438 ERROR (MainThread) [homeassistant.components.command_line] Command failed: python3 /config/

I’m not sure what step to try next. Is there a way to get a better error message? I’d appreciate any advice you have. Thanks.

You indicate “python3” using relative path and “/config/” using absolute path. Make sure that “python3” executable is available on the PATH environment variable and /config is the at the root level of the directory path


Have you changed something on tv?
OSError: [Errno 112] Host is down.

For anyone struggling with Xiaomi devices that goes into deep sleep and not waking up. I have managed to compile a integration that uses a built-in RPI4 bluetooth device, and force a pair connection with Mibox, just like Google TV app mentioned by davidclaeys. Pairing but not connecting to a bluetooth seems to do a trick, that wakes up MIBOX.

Note: I haven’t tested it against other Xiaomi boxes or TVs.

I read your answer a couple of days ago and just got around getting a dongle and testing it out. I can confirm it works as expected with my mi box. It required setting the switch entity on and off though. I’m very happy I finally got around it.

same here!
I’m running haos as a VM and I’m passing through an USB bt dongle.
Working flawlessly

Does this work with BT Proxy?

1 Like