Remote control for kodi

Hello, I have a problem, I have a raspberry pi zero w to which I have installed the dietpi distribution with the installed kodi and tvheadend. Everything works very well, the problem is that I have a Xenta Wireless Receiver (Keyboard and Mouse) and I would like to do is to press a button on the remote to open the kodi from the console (since the dietpi starts in text mode because I do not have a desktop installed) by means of a script or something, that is to say without lirc, since the control to be usb already works of luxury in kodi. I do not know if it’s possible what I want because I can not find anything anywhere. Thank you.

Have you tried the Autostart option inside Dietpi?
Kodi-startoption.png
dietpi-config > Autostart options

Maybe this little thing will already make what you want :slight_smile:

hello lucasmenno if that option had already contemplated but does not cover my needs, I’m not interested in the kodi start automatically at first but do so when I press a button on the remote control and meanwhile allow the system in text mode to that does not consume many resources because rasberry pi zero does not have much power. Thank you very much.

I note Lucasmenno you are using Banana PI M1, as am I - have you seen this thread:

https://dietpi.com/forum/t/banana-pi-m1/490/1

Yes I’ve seen this thread, but I’m not running kodi on my BPI :wink:
I thought he wanted to start kodi with the system.

Would a python script monitoring the wifi interface and when it sees the button entry presses then run a “kodi start” script work?

hello what you say sounds interesting but I think the name of the remote has confused (Xenta Wireless Receiver) since although it has that name does not work for wifi but for usb and infrared, anyway I am very lost in python you could guide me or tell me where I can document?

I was referring to the replacement .fex file not kodi…should have been more explicit.

As far as I know there are few people using DietPi with BananaPi M1.

Maybe just two :slight_smile:

Okay, haha. No I haven’t installed the fex files…
But I haven’t expirienced any troubles with this install.
1 time it was going too hot and shut itself off, that was when I tried YaCy, 15 minutes in and the ‘what is YaCy?’ was ended sooner as expected :smiley: .
My BPI has no fan or any cooling. It’s in a little cardboard box with a hdd. Temps are mostly around 45°C.
Would the fex make any significant differences?
Sry for using this thread for another topic :slight_smile:

Not sure, I just followed Fourdee’s advice that the .fex file for the other BPi may cause overvolting on the M1. Been running fine for months now.

Como configurar una tecla de un mando a distancia para abrir el kodi desde la terminal de Linux
Para realizar esta tarea vamos a crear un script python que este escuchando la tecla la cual queremos pulsar para que el realice la apertura de kodi.
Primero utilizamos el comando lsusb para ver que mandos usb tenemos conectados y sobre todo fijarnos el en Id de dicho dispositivo.
Al hacerlo podemos ver el id de nuestro mando en este caso el mío es el Xenta Wireless Receiver con un ID 1d57:ac01

root@DietPi:/# lsusb
Bus 001 Device 005: ID 1d57:ac01 Xenta Wireless Receiver (Keyboard and Mouse)
Bus 001 Device 004: ID 0fe6:9700 Kontron (Industrial Computer Source / ICS Advent) DM9601 Fast Ethernet Adapter
Bus 001 Device 003: ID 24ae:2000
Bus 001 Device 002: ID 1a40:0101 Terminus Technology Inc. 4-Port HUB
Bus 001 Device 001: ID 1d6b:0002 Linux Foundation 2.0 root hub
root@DietPi:/#

Después hacemos un cd /sys/kernel/debug/hid y ahí ejecutamos un ls -l como podemos ver .

root@DietPi:/sys/kernel/debug/hid# ls -l
total 0
drwxr-xr-x 2 root root 0 ene 1 1970 0003:1D57:AC01.0003
drwxr-xr-x 2 root root 0 ene 1 1970 0003:1D57:AC01.0004
drwxr-xr-x 2 root root 0 ene 1 1970 0003:24AE:2000.0001
drwxr-xr-x 2 root root 0 ene 1 1970 0003:24AE:2000.0002
root@DietPi:/sys/kernel/debug/hid#

Ahí vemos 4 carpetas y si nos fijamos las dos primeras contienen el ID de nuestro mando, yo entre en la primera de ellas no sé porque será por empezar por el principio. Ahí volví a ejecutar el comando ls-l y podemos ver dos archivos.

root@DietPi:/sys/kernel/debug/hid# cd 0003:1D57:AC01.0003/
root@DietPi:/sys/kernel/debug/hid/0003:1D57:AC01.0003# ls -l
total 0
-r-------- 1 root root 0 ene 1 1970 events
-r-------- 1 root root 0 ene 1 1970 rdesc
root@DietPi:/sys/kernel/debug/hid/0003:1D57:AC01.0003#

Vale pues si ahora hacemos un cat events el sistema se queda a la escucha para que pulsemos un botón de nuestro mando a distancia. Pulsamos la tecla a la cual le queremos dar la función para que abra nuestro kodi, si utilizamos el mando para más tareas sería bueno que eligiéramos un botón que no esté asignado a ninguna función.
Al pulsar el botón nos sale por pantalla unos códigos en mi caso estos:

report (size 8) (unnumbered) = 0c 00 28 00 00 00 00 00
Keyboard.00e0 = 0
Keyboard.00e1 = 0
Keyboard.00e2 = 1
Keyboard.00e3 = 1
Keyboard.00e4 = 0
Keyboard.00e5 = 0
Keyboard.00e6 = 0
Keyboard.00e7 = 0
Keyboard.0028 = 1

report (size 8) (unnumbered) = 00 00 00 00 00 00 00 00
Keyboard.00e0 = 0
Keyboard.00e1 = 0
Keyboard.00e2 = 0
Keyboard.00e3 = 0
Keyboard.00e4 = 0
Keyboard.00e5 = 0
Keyboard.00e6 = 0
Keyboard.00e7 = 0
Keyboard.0028 = 0

Ahí copie los códigos y me fije cuales son igual a 1 (Keyboard.00e2 = 1 Keyboard.00e3 = 1 Keyboard.0028 = 1) yo no sé porque razón cogí el ultimo código es decir el Keyboard.0028 = 1 y fue el que utilice el en código python.
Para crear el código python puse en pantalla nano kodi.py (yo utilizo nano porque me gusta más pero pueden utilizar el que más les guste) y ahí copie el siguiente código.

#!/usr/bin/python

import sys
import subprocess

x=‘si’

while x==‘si’:
tecla = sys.stdin.read(1)
subprocess.call(‘kodi’, shell=True)
print 'Has presionado ', tecla
if tecla==‘Keyboard.0028’:
x=‘no’

Bueno pues por ahora eso es todo lo que he realizado y ya funciona al apretar el botón que yo deseo se abre el kodi.
No sé si hay alguna manera de optimizar mejor la función se aceptan sugerencias y también me gustaría convertir ese código python en un servicio con lo cual espero que estoy sirva para otros que tengan mí mismo problema y que alguna alma caritativa me siga ayudando.

How to configure a key on a remote control to open the kodi from the Linux terminal
To perform this task we will create a python script that is listening to the key which we want to press for the kodi opening.
First we use the lsusb command to see which usb commands we have connected and above all to set the in Id of that device.
When doing so we can see the id of our command in this case mine is the Xenta Wireless Receiver with an ID 1d57: ac01

root @ DietPi: / # lsusb
Bus 001 Device 005: ID 1d57: ac01 Xenta Wireless Receiver (Keyboard and Mouse)
Bus 001 Device 004: ID 0fe6: 9700 Kontron (Industrial Computer Source / ICS Advent) DM9601 Fast Ethernet Adapter
Bus 001 Device 003: ID 24ae: 2000
Bus 001 Device 002: ID 1a40: 0101 Terminus Technology Inc. 4-Port HUB
Bus 001 Device 001: ID 1d6b: 0002 Linux Foundation 2.0 root hub
root @ DietPi: / #

Then we make a cd / sys / kernel / debug / hid and there we execute an ls -l as we can see.

root @ DietPi: / sys / kernel / debug / hid # ls -l
Total 0
drwxr-xr-x 2 root root 0 Jan 1 1970 0003: 1D57: AC01.0003
drwxr-xr-x 2 root root 0 Jan 1 1970 0003: 1D57: AC01.0004
drwxr-xr-x 2 root root 0 Jan 1 1970 0003: 24AE: 2000,0001
drwxr-xr-x 2 root root 0 Jan 1 1970 0003: 24AE: 2000,0002
root @ DietPi: / sys / kernel / debug / hid #

There we see 4 folders and if we look at the first two contain the ID of our command, I enter the first one I do not know because it will be to start at the beginning. There I ran the command ls-l again and we can see two files.

root @ DietPi: / sys / kernel / debug / hid # cd 0003 : 1D57 : AC01.0003 /
root @ DietPi: / sys / kernel / debug / hid / 0003: 1D57: AC01.0003 # ls -l
Total 0
-r -------- 1 root root 0 Jan 1 1970 events
-r -------- 1 root root 0 Jan 1 1970 rdesc
root @ DietPi: / sys / kernel / debug / hid / 0003: 1D57: AC01.0003 #

Okay, so if we do a cat events now, the system stays listening so we can press a button on our remote control. Press the key to which we want to give the function to open our kodi, if we use the command for more tasks it would be good to choose a button that is not assigned to any function.
When the button is pressed, a few codes appear in my case:

report (size 8) (unnumbered) = 0c 00 28 00 00 00 00 00
Keyboard.00e0 = 0
Keyboard.00e1 = 0
Keyboard.00e2 = 1
Keyboard.00e3 = 1
Keyboard.00e4 = 0
Keyboard.00e5 = 0
Keyboard.00e6 = 0
Keyboard.00e7 = 0
Keyboard.0028 = 1

report (size 8) (unnumbered) = 00 00 00 00 00 00 00 00 00
Keyboard.00e0 = 0
Keyboard.00e1 = 0
Keyboard.00e2 = 0
Keyboard.00e3 = 0
Keyboard.00e4 = 0
Keyboard.00e5 = 0
Keyboard.00e6 = 0
Keyboard.00e7 = 0
Keyboard.0028 = 0

There I copied the codes and I fixed which are equal to 1 (Keyboard.00e2 = 1 Keyboard.00e3 = 1 Keyboard.0028 = 1) I do not know why I took the last code ie Keyboard.0028 = 1 and it was the one use the in python code.
To create the python code I put on screen nano kodi.py (I use nano because I like more but can use the one that they like) and there copy the following code.

#! / usr / bin / python

import sys
import subprocess

x = ‘yes’

while x == ‘yes’:
key = sys.stdin.read (1)
subprocess.call (‘kodi’, shell = True)
print ‘Press’ key
if key == ‘Keyboard.0028’:
x = ‘no’

Well, for now that’s all I’ve done and it works by pressing the button I want the kodi to open.
I do not know if there is any way to better optimize the function I accept suggestions and I would also like to convert that python code into a service with which I hope I am useful to others who have myself problem and that some charitable soul will continue to help me.
Sorry for my English as a translator for Google, so I put it in Spanish first if someone understands me better.