Close

Stepping into the Digital World: Roku Remote Emulation

A project log for 2020 HDP Dream Team: UCPLA

The 2020 HDP Dream Teams are participating in a two month engineering sprint to address their nonprofit partner. Follow their journey here.

kelvin-chowKelvin Chow 09/06/2020 at 06:480 Comments

Previous project developments have heavily focused on physical hardware prototyping of a keyboard and motion-based remote controller.  One of the tasks that haven't been explored in depth is the peripheral digital devices that we can control with our prototypes.  We have discussed some ways to control a Roku media player as a proof-of-concept starting point and in this log, I will detail one method using an ESP32 microcontroller through Home Assistant to emulate a Roku remote.  

Simple ESP32 Keyboard

While we are working on a more developed keyboard prototype, I created a low-fidelity one for the purposes of debugging.  This is shown below.  It is 8 tactile switches connected to an input pin on the controller.  The uploaded sketch publishes a message (UP, DOWN, HOME, etc.) to an MQTT broker, which will be used as a trigger to perform an action on the Roku.  

Home Assistant on a Raspberry Pi

There are many possibilities on how we can communicate from a microcontroller to the Roku.  I chose to use Home Assistant because it was simple to setup, easy to learn, and has integrations with the majority of smart devices.  This last point is important because it makes it easy to translate from controlling a Roku to controlling another device like an Amazon Echo or Google Nest. 

Setup Procedure

The setup to install Home Assistant on a Raspberry Pi was followed from the Home Assistant website.  After, the Roku and MQTT broker integrations were setup for this specific example.  

Roku and Mosquito MQTT broker integrations configured, shown on the Home Assistant dashboard.

The next step was to establish a connection between Home Assistant to the Roku media player.  Tests scripts were written where a button on the Home Assistant dashboard could be used to send Roku commands.

Left: Two sample scripts shown of up and down roku commands.  Right: Script execution buttons on Home Assistant dashboard. 

Once that was done, the ESP32 microcontroller needed to send messages to Home Assistant.  With the MQTT broker configured, short messages were published to HA, which could be seen from the Home Assistant dashboard.  

Screenshot from Home Assistant Dashboard MQTT broker configuration page.  Waiting for button presses on the ESP32 controller, and receives messages (HOME, BACK, SELECT, DOWN).  

Finally, an automation routine was written to combine the trigger from the microcontroller and to perform actions on the Roku media player.  Two simple automation scripts are shown below.

Two automation scripts shown.  First script waits for the message, LEFT, to trigger the action of pressing the left button on the Roku.  

The video below shows the ability to use the 8 buttons to emulate Roku remote to control a Roku media player.  

Discussions