Pointers to documentation for reference:
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
host: 192.168.31.5
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.
Example: ligar_tv.py
import socket
s = socket.socket(
socket.AF_BLUETOOTH,
socket.SOCK_STREAM,
socket.BTPROTO_RFCOMM,
)
s.connect(('XX:XX:XX:XX:XX:XX', 2))
Then create a new entity in the “configuration.yaml” file, as in the example below:
command_line:
- switch:
name: Ligar TV
command_on: python3 /config/ligar_tv.py
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/bluetoothPing.py
2023-11-29 17:56:10.438 ERROR (MainThread) [homeassistant.components.command_line] Command failed: python3 /config/bluetoothPing.py
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/bluetoothPing.py” 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
Hi,
Have you changed something on tv?
Error:
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.
https://github.com/frlequ/mibox_socket
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?
The mi socket integration doesn’t work trough proxies.
It would be a nice addition but right now you’ll need a dongle.
Thank you for finding a workaround. I have been waiting for this since a long time as I was owning a mi box s and now mi stick, luckily found this thread. I have followed the steps as you have described but there is one question. Could you please let me know if I need to toggle the switch on and off like for 15 sec or leave it on when using it in any automation steps ? Thank you in advance
Good day all,
On the proxy option I found in github this project using an esp32 to mimic a xiaomi remote.
I’ve tested it myself and with the tv on it does indeed control it. However, with the tv off the power button is unable to turn the tv on.
I’m adding an issue to the repo in the hope the developer may take a look at this.
Moreover, if anyone here has the knowledge and could support this package it would finally make a decent solution.