Version en Français
Here are the details of my latest side-project: controlling my TV from inside Minecraft! It’s surely slower than using the remote control, but it was interesting to make and it’s working!
You can see it in action in the video, and read about the technical aspects below.
How does it work ?
The different components of this project are developed in Python 3, and running on Linux (Ubuntu).
I suppose anyone could easily run it on another platform with minor modifications.
Here are the details of the implementation.
Controlling the TV
The TV is plugged into a Freebox, a set-top box provided by the french ISP Free. The box is connected to the network and we use UDP messages to simulate the remote control. The documentation about the protocol is light and it’s hard to find samples.
I found a draft of a Python implementation of the protocol made by Maxime Cheramy. It was really useful to get me started in UDP network programming and RUDP in Python. I also used the C sample provided by Free to better understand the packet format used to send the keys. I sniffed the UDP packets using Wireshark, and even took some time to write a dissector for Wireshark using the plugin WSGD.
The latest version of the Python code, as well as the wireshark dissector are available on my public Github.
Controlling the Minecraft server
I’m running an official Minecraft server (in Java). I wrote a small class allowing me to send commands to the server, and interpret the output. It’s quite hacky but it’s working well enough.
As I run the server in tmux, I can easily find the process using
tmux list-panes, send commands using
tmux send-keys and parse the server output using
The latest version of the code is here (minecraft.py).
Detecting player actions
In the Minecraft world I made for the occasion, each button of the virtual remote control is connected to a command block, as you can see in the screenshot below.
The associated commands set a game rule to a specific number, using
gamerule set remote <value>. A script is constantly checking for the state of this variable and if it changed, does the following:
- Converts the value to a key (using a .json configuration file)
- Sends the key through the network to the freebox, using the
- Use other fancy minecraft commands used to change the background of the “big” remote control in the game world, using the
As usual, the code is on Github.
That’s it, I hope you liked this post (first post in two years…).
Feel free to share, comment, or ask me anything at @Frozax!