MyHarmony

From MythTV Official Wiki
Jump to: navigation, search


Software-update-available.png This page is up-to-date as of MythTV version 0.27.6, the current release is 0.28.1


Introduction

My Harmony is the method for configuring newer Logitech Harmony remote controls. Unlike the previous method you cannot browse categories to pick a device. This makes configuring a Harmony remote for use with MythTV hit and miss.

Requirements

  • A Logitech Harmony remote control
  • The My Harmony software to configure the remote control (and a Windows machine to run it on. If you do not have a windows machine Microsoft offers free VirtualBox images)
  • An IR Receiver
  • LIRC
  • inputlirc
  • ir-keytbale
  • A GNU/Linux kernel with support for event devices (evdev).
  • MythTV Frontend

Hardware

For the below examples the hardware being used is:

  • A Philips eHome receiver (USB ID 0471:0815) - this is an RC-5 and RC-6 mceusb receiver
  • A Logitech Harmony Ultimate One remote control
  • A Debian host

For the purposes of the example the follow information is used:

  • The ir receiver is device rc0 and linked to the event16 event device with a symplink to /dev/input/myremote
  • The user running the mythtv-frontend instance is mythtv
  • GDM is being used as the X session manager

Installing Software

MythTV Frontend Machine

You will need to install the LIRC, inputlirc, and ir-keytable software for your distribution. Also install evtest for testing purposes. On a Debian or derived system run

sudo aptitude install lirc inputlirc ir-keytable evtest

My Harmony Software

To install the My Harmony software on a Windows or MacOSX machine visit http://www.myharmony.com and click on the Set Up link at the top of the page. From there select the relevant remote control device and click the "Get the App & Software" link. Once the file has downloaded install and launch the software.

Configuring Software

Before you start you should know what type of receiver you have (this example is using an mceusb RC-6 receiver). Determine which event device your receiver is mapping to. You should also ensure that lircd, X, and inputlirc are not running.

*** TIP You can create a custom udev rule so that your receiver device ends up with a constant symlink in /dev/input/. For the example device a rule like:

KERNEL=="event*",ATTRS{manufacturer}=="Philips",ATTRS{idProduct}=="0815",SYMLINK="input/myremote

can be added to your udev rules using the following command

echo 'KERNEL=="event*",ATTRS{manufacturer}=="Philips",ATTRS{idProduct}=="0815",SYMLINK="input/myremote"' | sudo tee --append /etc/udev/rules.d/10-persistent-ir.rules


ir-keytable

Copy the default keytable for the remote you are emulating into /etc/rc_keymaps/. In Debian these are stored in /lib/udev/rc_keymaps/. So for using an RC-6 MCE remote in Debian perform the following:

cp /lib/udev/rc_keymaps/rc6_mce /etc/rc_keymaps/

This gives you a keymap that you can customise, should you wish to rename any of the scancodes the remote is sending, or add new scancodes.

Test ir-keymap

Running ir-keytable with no arguments provides a list of remote control devices and their capabilities:

sudo ir-keytable
Found /sys/class/rc/rc0/ (/dev/input/event16) with:
        Driver mceusb, table rc-rc6-mce
        Supported protocols: unknown other lirc rc-5 jvc sony nec sanyo mce-kbd rc-6 sharp xmp 
        Enabled protocols: lirc rc-6 
        Name: Media Center Ed. eHome Infrared 
        bus: 3, vendor/product: 0471:0815, version: 0x0000
        Repeat delay = 500 ms, repeat period = 125 ms

Clear the keytable for the device

sudo ir-keytable -d /dev/input/myremote -c
Old keytable cleared

Write the new keytable to the device and reset the active protocols

sudo ir-keytable -d /dev/input/myremote-p lirc,rc6 -w /etc/rc_keymaps/rc6_mce
Wrote 63 keycode(s) to driver

If ir-keytable segfaults on this do not be alarmed - apparently it is something that happens and has no fix.

LIRC

LIRC is configured in the following files:

/etc/lirc/hardware.conf

# /etc/lirc/hardware.conf
#
# Arguments which will be used when launching lircd
LIRCD_ARGS=""

#Don't start lircmd even if there seems to be a good config file
START_LIRCMD=false

#Don't start irexec, even if a good config file seems to exist.
START_IREXEC=false

#Try to load appropriate kernel modules
LOAD_MODULES=true

# Run "lircd --driver=help" for a list of supported drivers.
DRIVER="devinput"
DEVICE="/dev/lirc0"
MODULES="mceusb"

# Default configuration files for your hardware if any
LIRCD_CONF="mceusb/lirc.cong.mceusb"

/etc/lirc/lircd.conf

include "/usr/share/lirc/remotes/mceusb/lircd.conf.mceusb"

Input LIRCD

To configure inputlirc all that is needed is to edit the default file for it:

/etc/default/inputlirc

EVENTS="/dev/input/myremote"
OPTIONS="-c -g -m 0"

Passing the -c option allows modifier keys (shift/alt/ctrl/meta) to be captured.

Passing the -g option ensures that only inputlirc/LIRC will use this device. This means that the device will not be recognised as a keyboard by X, which would open the device and stop LIRC from using it.

Passing the -m 0 option means all keycodes are captured.

Starting the Software

Once the software has been configured you can either reboot(not my preferred method), or restart the software in the following order

sudo ir-keytable -d /dev/input/myremote-p lirc,rc6 -w /etc/rc_keymaps/rc6_mce
sudo /etc/init.d/lirc start
sudo /etc/init.d/inputlirc start
sudo /etc/init.d/gdm3 start

**NOTE: If you are not using GDM to start your X, then substitute your normal method for starting X.

Configuring Remote Control

On your Windows or Mac machine launch the My Harmony software and connect the remote control.


Select the remote control

Harmony Home.png


and go to Your Devices

Harmony Dev1.png


and then Add Device

Harmony Dev2.png


In the Manufacturer box enter 'Mircosoft' For the example provided it is best to use 'MCE_2006' in the Device Model Number box.

Harmony Dev Add.png


Once this is completed you should add any other devices you use when you use MythTV Frontend (in the case of the author this is a TV, as a monitor, and a surround sound system), and any other devices you wish to control with your Harmony remote control. You should also create a MythTV activity that contains all the devices you use with your MythTV Frontend, and that performs the correct actions when you start and stop using MythTV Frontend.

This will configure most of the hard buttons on the remote control, but you may want to go to the Buttons section of the software to check everything is where you want it. It was found that the Menu button was not set at all, and that some of the other buttons did not have the desired configuration (this is, of course, all personal preference)

Harmony Button.png


MythTV Frontend user configuration

The user running mythtv-frontend (for this example mythtv) will need to have a .lircrc file in place to allow them to map the lirc intercepted keycodes into usable mythtv-frontend commands. The following is the .lircrc file used with the example hardware. It is placed in ~mythtv/ and symlinked into ~/mythtv/.mythtv

# begin mythtv

begin
    prog = irexec
    button = KEY_POWER
    config = /usr/local/bin/toggleMonitor.sh
    repeat = 0
end

begin
    prog = mythtv
    button = KEY_GOTO
# Swap the PiP windows
    config = N
end

begin
    prog = mythtv
    button = KEY_NUMERIC_1
    config = 1
end

begin
    prog = mythtv
    button = KEY_NUMERIC_2
    config = 2
end

begin
    prog = mythtv
    button = KEY_NUMERIC_3
    config = 3
end

begin
    prog = mythtv
    button = KEY_NUMERIC_4
    config = 4
end

begin
    prog = mythtv
    button = KEY_NUMERIC_5
    config = 5
end

begin
    prog = mythtv
    button = KEY_NUMERIC_6
    config = 6
end

begin
    prog = mythtv
    button = KEY_NUMERIC_7
    config = 7
end

begin
    prog = mythtv
    button = KEY_NUMERIC_8
    config = 8
end

begin
    prog = mythtv
    button = KEY_NUMERIC_9
    config = 9
end

begin
    prog = mythtv
    button = KEY_BACK
    config = Esc
end

begin
    prog = mythtv
    button = KEY_NUMERIC_0
    config = 0
end

begin
    prog = mythtv
    button = KEY_MENU
    config = M
end

begin
   prog = mythtv
   button = KEY_RED
   config = C
end

begin
   prog = mythtv
   button = KEY_GREEN
   config = I
end

begin
   prog = mythtv
   button = KEY_YELLOW
   config = V
end
begin
   prog = mythtv
   button = KEY_BLUE
   config = N
end

# Note the "repeat =" strings in the volume and channel.
# This means that if you hold down the key, every nth instance will be
# passed.  This depends on your system, so you may want to increase or
# decrease this and see what happens.  repeat = 1 is probably too
# fast.

begin
    prog = mythtv
    button = KEY_CHANNELUP
    repeat = 3
    config = Up
end

begin
    prog = mythtv
    button = KEY_CHANNELDOWN
    repeat = 3
    config = Down
end

begin
    prog = mythtv
    button = KEY_VOLUMEDOWN
    repeat = 3
    config = F10
end

begin
    prog = mythtv
    button = KEY_VOLUMEUP
    repeat = 3
    config = F11
end

begin
    prog = mythtv
    button = KEY_OK
    config = Return
end

begin
    prog = mythtv
    button = KEY_MUTE
    config = F9
end

begin
    prog = mythtv
    button = KEY_REWIND
    repeat = 3
    config = Left
end

begin
    prog = mythtv
    button = KEY_PLAY
    config = P
end

begin
    prog = mythtv
    button = KEY_FASTFORWARD
    repeat = 3
    config = Right
end

begin
  prog = mythtv
  button = KEY_RECORD
  config = R
end

begin
   prog = mythtv
   button = KEY_STOP
   config = Esc
end

begin
    prog = mythtv
    button = KEY_PAUSE
    config = P
end

begin
   prog = mythtv
   button = KEY_LAST
# Use for backwards commercial skip
    config = Q
end

begin
   prog = mythtv
   button = KEY_NEXT
# Use for forward commercial skip
    config = Z
end

begin
   prog = mythtv
   button = KEY_EPG
# Use for showing program
    config = S
end

begin
   prog = mythtv
   button = KEY_UP
# Use it
    config = Up
end

begin
   prog = mythtv
   button = KEY_LEFT
# Use it
    config = Left
end

begin
   prog = mythtv
   button = KEY_RIGHT
# Use it
    config = Right
end

begin
   prog = mythtv
   button = KEY_DOWN
# Use it
    config = Down
end

begin
   prog = mythtv
   button = KEY_EXIT
   config = Esc
end

begin
   prog = mythtv
   button = KEY_INFO
   config = i
end

begin
   prog = mythtv
   button = KEY_DVD
   config = m
end

# end mythtv