Kodi Community Forum
Solved Connect Xiaomi Mi Box BT remotes to LibreELEC devices - Printable Version

Kodi Community Forum (https://forum.kodi.tv)
+-- Forum: Discussions (https://forum.kodi.tv/forumdisplay.php?fid=222)
+--- Forum: Hardware (https://forum.kodi.tv/forumdisplay.php?fid=112)
--- Thread: Solved Connect Xiaomi Mi Box BT remotes to LibreELEC devices (/showthread.php?tid=317011)

Pages: 1 2 3 4 5 6 7 8 9 10 11


Connect Xiaomi Mi Box BT remotes to LibreELEC devices - Petzi - 2017-06-21



MOD EDIT: Connect a Xiaomi Mi Box Bluetooth remote DIY (click)



Hi team,

Hope I've done my homework well before posting Big Grin

Been googling for days to find out a way to get the Xiaomi Mi Box bluetooth remote working with Kodi (Krypton) on a Raspberry Pi (2 + bluetooth dongle). It's a simple and cheap BT remote, pretty close to the Apple TV one, so I gave it a try. Oh boy, what a ride so far ...

The remote can be paired with Kodi. I can see it in /proc/bus/input/devices.

I can use evtest to see what codes it sends :

Code:
Event: time 1498063117.174288, type 4 (EV_MSC), code 4 (MSC_SCAN), value 70081
Event: time 1498063117.174288, type 1 (EV_KEY), code 114 (KEY_VOLUMEDOWN), value 1
Event: time 1498063117.174288, -------------- SYN_REPORT ------------
Event: time 1498063117.354399, type 4 (EV_MSC), code 4 (MSC_SCAN), value 70081
Event: time 1498063117.354399, type 1 (EV_KEY), code 114 (KEY_VOLUMEDOWN), value 0
Event: time 1498063117.354399, -------------- SYN_REPORT ------------

So I've used this thread to try to get the remote to work. No luck.

I've created the evmap file (how exciting ... KEY_VOLUMEUP = KEY_VOLUMEUP and so on). No luck (yes, the 99-eventlircd.rules is created, and the directory is mounted properly).

There are a few things that seem weird ... maybe it has nothing to do though. Xiaomi being a Chinese company, the name of the device is in Chinese :

From dmesg :

Code:
[   93.437676] input: 小米蓝牙遥控器 as /devices/virtual/misc/uhid/0005:2717:32B1.0001/input/input0
[   93.441379] hid-generic 0005:2717:32B1.0001: input,hidraw0: BLUETOOTH HID v10.0b Keyboard [小米蓝牙遥控器] on 00:19:86:00:0B:C1

So my 99- file contains this name, in Chinese. Not sure if there's a problem there (plus it says keyboard here, while Kodi shows it as a gamepad).

Code:
OpenELEC:~/.config/udev.rules.d # more 99-eventlircd.rules
SUBSYSTEMS=="bluetooth", GOTO="begin-bluetooth"
GOTO="end-bluetooth"
LABEL="begin-bluetooth"

ATTRS{name}=="小米蓝牙遥控器", \
 ENV{eventlircd_enable}="true", \
 ENV{eventlircd_evmap}="miboxremote.evmap"

LABEL="end-bluetooth"
Second, the codes sent by the remote seem to use a different BT protocol ?

Code:
> ACL data: handle 64 flags 0x02 dlen 15
   ATT: Handle notify (0x1b)
     handle 0x0030
     value 0x00 0x00 0x52 0x00 0x00 0x00 0x00 0x00
> ACL data: handle 64 flags 0x02 dlen 15
   ATT: Handle notify (0x1b)
     handle 0x0030
     value 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00

This is totally different from the (working) BT keyboard I've used for comparison (sends L2CAP codes instead).

I've tried the keymap editor, but nothing happens when I press the buttons ...

I also wanted to create a small eventclient to mimic what happens with the PS3 BD remote, but I'm stuck with some python libs that can't be installed. So no luck this way either.

Would anyone have other pointers to things I could try ? Debug settings to turn on to monitor the BT status in Kodi ?

Cheers,
Petzi


RE: Xiaomi Mi Box BT remote and Raspberry Pi - Petzi - 2017-06-23

Talking to myself ... first step to insanity, I know, I know...

Turned debugging on, and I can see that the remote is detected by Kodi ... (which, ironically, isn't a debug level message ... should have found it earlier Big Grin )

Code:
14:18:17.108 T:1566569376    INFO: Found input device /dev/input/event2
14:18:17.109 T:1566569376    INFO: opened device '小米蓝牙遥控器' (file name /dev/input/event2), m_bSkipNonKeyEvents 0

Still not the faintest clue as to why it isn't working ... Is there any specific debug for dumping the communications with a /dev/input device to a file ? I'm currently running with all values in the advanced settings file, but I can't see any communication between the remote and Kodi Sad


RE: Xiaomi Mi Box BT remote and Raspberry Pi - ashrafhumax - 2017-06-24

Hi

I think it is similar to my problem so please have a look here

Libreelec forum

Please keep me updated if you tried the fix

Regards


[Solved] Xiaomi Mi Box BT remote and Raspberry Pi - Petzi - 2017-06-24

Aaaaaaand I got it working.

A huge thanks to you ashrafhumax ! Two strangers sharing info on the Internet, possibly at remote ends of the planets ... Love it Big Grin

Here's what I did (there will be additional tweakings to get things working the way I want, and I'll leave other to make it cleaner if they want to Big Grin ). First of all, as I couldn't get it to work on openelec, I tried with LibreElecl. And got it working there, so I'll stick with LibreElec for the moment. This should probably as is with OpenElec.

I created a file 51-these-are-not-joysticks.rules in /storage/.config/udev.rules.d/ as per the info found in your message. I added this line :
Code:
ATTRS{vendor}=="2717", ENV{ID_INPUT_JOYSTICK}=""

2717 is Xiaomi ID

Then, I created the file 99-eventlircd.rules in the same directory and added this :
Code:
KERNEL=="event0", ENV{eventlircd_enable}="true", ENV{eventlircd_evmap}="aftvsremote.evmap"

The obvious limitation is that my remote must be /dev/input/event0, but that's not much of a problem (and still something that could be fixed with udev, but now that the remote is working, I'll move from a linux tweakers to a couch potato). The other one is that I'm doing a broad change, for all Xiaomi's devices. Could be a bit finer, but I don't plan on having more than one remote or BT equipment on that Raspberry Pi !

Also, my remote (Mi Box bluetooth remote) uses most of the keys of the Amazon fire TV remote, so I haven't updated the evmap yet. Will do, one day, when I'll be over my movies. Using the tricks found in the thread I linked to in my first message.


RE: [Solved] Xiaomi Mi Box BT remote and Raspberry Pi - ashrafhumax - 2017-06-24

Happy you managed to sort it out, it is a nice remote and worth the efforts to get it working.Big Grin


RE: [Solved] Xiaomi Mi Box BT remote and Raspberry Pi - wrxtasy - 2017-06-25

Thanks for this. It was on my back burner list of things to look at.

Will work really well for a dual WeTek Play2 that already has support for the Mi Box remote when using the AndroidTV ROM, surprisingly the remote also turns OFF/ON the Play2.

So now I can use it with LibreELEC as well. Smile

Please post up a link for where users can buy these nice aftermarket BT Mi Box remotes.

There are no rubber buttons on the original Mi Box remote, it a superb BT remote.


RE: [Solved] Xiaomi Mi Box BT remote and Raspberry Pi - clarkss12 - 2017-06-25

(2017-06-24, 02:05)ashrafhumax Wrote: Hi

I think it is similar to my problem so please have a look here

Libreelec forum

Please keep me updated if you tried the fix

Regards

I ordered one of those $2 remotes (imitation Xiaomi Mibox remote) from China that you linked for me. I will be using it on my Beelink minimx3 (Amlogic S905).


RE: [Solved] Xiaomi Mi Box BT remote and Raspberry Pi - clarkss12 - 2017-06-25

(2017-06-24, 19:47)Petzi Wrote: Aaaaaaand I got it working.

A huge thanks to you ashrafhumax ! Two strangers sharing info on the Internet, possibly at remote ends of the planets ... Love it Big Grin

Here's what I did (there will be additional tweakings to get things working the way I want, and I'll leave other to make it cleaner if they want to Big Grin ). First of all, as I couldn't get it to work on openelec, I tried with LibreElecl. And got it working there, so I'll stick with LibreElec for the moment. This should probably as is with OpenElec.

I created a file 51-these-are-not-joysticks.rules in /storage/.config/udev.rules.d/ as per the info found in your message. I added this line :
Code:
ATTRS{vendor}=="2717", ENV{ID_INPUT_JOYSTICK}=""

2717 is Xiaomi ID

Then, I created the file 99-eventlircd.rules in the same directory and added this :
Code:
KERNEL=="event0", ENV{eventlircd_enable}="true", ENV{eventlircd_evmap}="aftvsremote.evmap"

The obvious limitation is that my remote must be /dev/input/event0, but that's not much of a problem (and still something that could be fixed with udev, but now that the remote is working, I'll move from a linux tweakers to a couch potato). The other one is that I'm doing a broad change, for all Xiaomi's devices. Could be a bit finer, but I don't plan on having more than one remote or BT equipment on that Raspberry Pi !

Also, my remote (Mi Box bluetooth remote) uses most of the keys of the Amazon fire TV remote, so I haven't updated the evmap yet. Will do, one day, when I'll be over my movies. Using the tricks found in the thread I linked to in my first message.

When I get my Bluetooth remote, I will be using your tutorial to get it to work with my Amlogic S905 box running LibreELEC. thanks


RE: [Solved] Xiaomi Mi Box BT remote and Raspberry Pi - Petzi - 2017-06-25

(2017-06-25, 03:28)wrxtasy Wrote: Please post up a link for where users can buy these nice aftermarket BT Mi Box remotes.

There you go. I took one with a pink/red silicon skin, I can spot it from miles away.


RE: [Solved] Xiaomi Mi Box BT remote and Raspberry Pi - wrxtasy - 2017-06-25

More info pls.
Are the buttons rubber (without the Skin) or the Hardened plastic like a genuine Mi Box remote ?

(I never trust advertising)


RE: [Solved] Xiaomi Mi Box BT remote and Raspberry Pi - ashrafhumax - 2017-06-25

Hi all,

I ordered several editions of this remote from ebay

First one is the original Bluetooth one that use 2 AA batteries, it arrived boxed in mi box and build quality is excellent however it connect as game pad and needs the above fix, I recommend this one for excellent build quality

eBay item number: 172283014079 you can search this number in ebay search bar

Image
Image
Image
Image
Image
Image
Image

The second one is a clone, very cheap, build quality is OK but I didn't like the rubber buttons, connects as Xiaomi RC without any problems

eBay item number: 182262602775

Image
Image
Image
Image

Both shipped from Hong Kong using airmail and delivery was fast about one week
I hope these information are helpful for you all

Regards


RE: [Solved] Xiaomi Mi Box BT remote and Raspberry Pi - clarkss12 - 2017-06-25

This is the one I ordered for $2 US, that ashrafhumax linked me to. Will be testing it when it arrives.

http://www.ebay.com/itm/122558282372


RE: [Solved] Xiaomi Mi Box BT remote and Raspberry Pi - ashrafhumax - 2017-06-25

Please be careful when buying from china, there are similar remotes that works using IR only so please make sure to read the description carefully and search for the word Bluetooth and make sure there is a Bluetooth logo on the back.
Please use eBay item numbers above to be on the safe side when ordering.


RE: [Solved] Xiaomi Mi Box BT remote and Raspberry Pi - wrxtasy - 2017-06-25

@ashrafhumax, Wow thanks - exactly what users are looking for.

These BT remote's make great additions to the unofficial Android TV ROM's for the WeTek Hub & Play2.

I extracted all the Xiaomi Vendor Keylayouts from the Mi Box for inclusion in the ATV ROM's.
So they Pair & work out of the box, even allowing the Hub & Play2 to Sleep / Wake surprisingly. Smile

Original Genuine Xiaomi Bluetooth Remote - $10.88


RE: [Solved] Xiaomi Mi Box BT remote and Raspberry Pi - clarkss12 - 2017-06-25

(2017-06-25, 18:31)ashrafhumax Wrote: Please be careful when buying from china, there are similar remotes that works using IR only so please make sure to read the description carefully and search for the word Bluetooth and make sure there is a Bluetooth logo on the back.
Please use eBay item numbers above to be on the safe side when ordering.

Thanks for that information. Guess if it is IR only, it will be useless for me, but for $2 I can't complain.


This forum uses Lukasz Tkacz MyBB addons.