Controlling Android TV and Kodi with Flirc and Logitech Harmony

Posted by Sven Kiljan on in Android TV, Shield TV, Kodi, Flirc, Logitech Harmony

This is a short post about controlling Android TV using a Logitech Harmony infrared remote control using Flirc.

Recently I gifted an Nvidia Shield TV for Christmas. The Shield TV is an Android TV device which in this case would mostly be used for playing media through Kodi and Netflix.

The lucky recipient of the gift uses an older model Logitech Harmony universal infrared remote control. As the latest revision of the Shield TV ('16GB, 2017') lacks an infrared receiver, a Flirc USB was included. Flirc receives infrared commands and converts them to keypresses given by emulated USB human interface devices, such as keyboards and game controllers.

In Flirc's firmware is a built in Kodi profile that can be used with a Logitech Harmony remote immediately. The profile uses Kodi's keyboard controls. Unfortunately, the keyboard keys used do not match with other Android applications, which prevents a single Logitech Harmony activity from controlling Android TV in its entirety. In addition, the Harmony device configuration profile does not let the Android TV device sleep by default.

In this post all components (Logitech Harmony remote, FLIRC, Android TV and Kodi) are aligned so that they all work comfortably together.

Configuring the Logitech Harmony remote

Depending on which model remote you have, use either the older Harmony Remote Software or the newer MyHarmony.

Add a new device using the following information:

  • Device (only needed for Harmony Remote Software): Computer -> Media Center PC
  • Manufacturer: Flirc
  • Model: Kodi

A Shield TV can be switched on and off using Flirc, and possibly other Android TV devices as well. In the software for the Harmony remote, the new device's power settings can be configured as follows to allow activities to switch the device on and off when necessary:

  • "I want to turn off this device when (it's) not in use".
  • "A button on the remote for On, and a different button for Off" / "I press two different buttons for on and for off".
  • Use command "." (period) as the (only) power on command.
  • Use command "PowerOff" as the (only) power off command.

This is all the configuration that is strictly necessary for the Logitech Harmony remote. It is up to the user to configure one or more activities and to map commands to buttons on the remote. An example mapping is given in Appendix A.

Configuring Flirc

Use the Flirc configuration software with this configuration file. Alternatively, use the configuration overview in Appendix A to configure the Flirc manually.

Ensure that any built in profiles are disabled to avoid configuration conflicts. The infrared commands in the configuration file and in the Flirc Kodi profile for the Logitech Harmony are exclusively used by Flirc and should therefore not conflict with any other devices.

Configuring Kodi

In Android TV the Escape keyboard key is used for the Back command. In Kodi the Backspace key is used for this command, while Escape is used for other functions. It is possible to swap the functions of these keys in Kodi, which would make the Escape keyboard key's function consistent across both Android TV and Kodi.

Create on the Android TV device a new file, Android/data/org.xbmc.kodi/files/.kodi/userdata/keyboard.xml. Note that the exact path can differ between devices. The file needs the following content:

<?xml version="1.0" encoding="UTF-8"?>
      <escape mod="longpress"></escape>

Restart Kodi after the file is saved, and the functions of the Escape and Backspace keyboard keys should have been swapped.

Appendix A: Configuration overview

Below is an overview of the configuration between the Harmony remote and the Android TV device.

The first column concerns a reference mapping of the Harmony buttons to Harmony commands in the second column. This configuration is done in the Harmony configuration software. Note that a Harmony One was used for these columns. A different mapping might be more appropriate for other Harmony models.

Logitech Harmony One

The third and fourth column contain the Flirc keys mapped to Harmony commands in the second column.

The fifth column shows Android TV and Kodi functions that are available through the Harmony remote and Flirc. After configuration, the first and fifth column can be used as a reference functional mapping of user controls to system functions, hiding the technical details from the second, third and fourth columns. Note that a keyboard configuration change in Kodi is necessary for consistent use of the back key, as described earlier in this post.

Harmony buttonHarmony commandKeyboard keyMedia keyAndroid TV/Kodi function
(only used by activity)PwrOffwake/suspendPower off (discrete)
(only used by activity). (dot/period)Lshift+Lctrl+Lalt+F15Power on (discrete)
Channel upPageUpPage UpPage up
Channel downPageDownPage DownPage down
Fast forwardFastForwardFast forwardFast forward
Skip backSkipBackPreviousSkip backward
Skip forwardSkipForwardNextSkip forward
LCD - HomeParentFolderBackspacePrevious menu / Home screen / Exit full screen
LCD - Full screenFullScreenTabFullscreen playback
LCD - Toggle subtitlesShowSubtitlesTToggle subtitles
LCD - Next subtitleNextSubtitleLNext subtitle

The only key combination that is special in the table is for the power on function. An Nvidia Shield TV (and possible other Android TV devices) uses the wake/suspend media key on a USB keyboard to power off, but not to power on. In fact, every other button can be used to power on the device. This is by design. It allows for discrete power buttons on universal remotes (one button for power off, another button for power on), which prevents an unintended power off when the system should be powered on and vice versa.

For the power on function, a key combination is used that is unlikely to be used for something else. If a system is already powered on, the key combination will not perform an undesired action.