[LINUX] Logitech Harmony Ultimate on Linux Bluetooth + Support for Bluez 5
#1
If this helped you than you should hit the thank button Smile

Post 1# Kodibuntu + Bluez 4
Post 2# Ubuntu 16 + Kodi 16.1 + Bluez 5

I made this new post cause i had to do several steps from several post. This is the solution that worked for me after trying several days Tongue I dont know what exactly happens in the code, but this few steps got my Logitech Harmony Ultimate working on Linux (KODIbuntu) I also got it finally to work on higher bluez version, which i explain in post #2.

I used IR first, but the response whas so sluggish, so i was desperate to try bluetooth, I do notice a much faster response.

Thanks To All Users In This Post That Helped On This Project:
http://forum.kodi.tv/showthread.php?tid=50717

Special Thanks To:
CrazyCoder For harmony Injection

If this guide works for you, you may wanne thank the posts.

[My hardware]
1. HTPC with KODIbuntu 14.04.1 LTS
2. Logitech Harmony Ultimate
3. Bus 008 Device 002: ID 0a12:0001 Cambridge Silicon Radio, Ltd Bluetooth Dongle (HCI mode)

[Step 1.]
First of all create a new Device (Sony Playstation 3) and a fresh activity in Logitech Harmony Remote Software.

Image

Then comes the fun part


[Step 2.]
Get and install bluez + patch
Code:
sudo apt-get update
sudo apt-get install bluez libdbus-1-dev libglib2.0-dev python-dbus python-gobject

[Additional step for: OSMC you need to install make & essential]
Code:
apt-get install make
apt-get install build-essential
reboot

Continue

Code:
sudo service bluetooth stop
cd ~
wget https://dl.dropboxusercontent.com/u/89032099/XBMC/bluez_ps3remote_4.91.diff
wget http://www.kernel.org/pub/linux/bluetooth/bluez-4.94.tar.gz
tar xvfz bluez-4.94.tar.gz
cd bluez-4.94

[Step 3.]
Inject the Logitech Harmony PS3 remote device in fakehid.c
Code:
cd input
nano ./fakehid.c

Around line 343, you should find the following code:
Code:
static struct fake_hid fake_hid_table[] = {
        /* Sony PS3 remote device */
        {
                .vendor         = 0x054c,
                .product        = 0x0306,
                .connect        = fake_hid_common_connect,
                .disconnect     = fake_hid_common_disconnect,
                .event          = ps3remote_event,
                .setup_uinput   = ps3remote_setup_uinput,
                .devices        = NULL,
        }

        { },
};

These lines teach Bluez how to recognize Sonys official PlayStation 3 bluetooth remote. Modify this structure and make it look like the following:
Code:
static struct fake_hid fake_hid_table[] = {
        /* Sony PS3 remote device */
        {
                .vendor         = 0x054c,
                .product        = 0x0306,
                .connect        = fake_hid_common_connect,
                .disconnect     = fake_hid_common_disconnect,
                .event          = ps3remote_event,
                .setup_uinput   = ps3remote_setup_uinput,
                .devices        = NULL,
        },

        /* Logitech Harmony PS3 remote device */
        {
                .vendor         = 0x046d,
                .product        = 0xc129,
                .connect        = ps3remote_connect,
                .disconnect     = ps3remote_disconnect,
                .event          = ps3remote_event,
                .setup_uinput   = ps3remote_setup_uinput,
                .devices        = NULL,
        },

        { },
};

[Step 4.]
Continue with bluez install code: cd to ~/bluez-4.94 folder
Code:
cd ..
patch -p1 < ../bluez_ps3remote_4.91.diff
./configure --prefix=/usr && make
sudo make install
sudo ln -s /etc/bluetooth/input.conf /usr/etc/bluetooth/input.conf
sudo ln -s /etc/bluetooth/audio.conf /usr/etc/bluetooth/audio.conf
sudo ln -s /etc/bluetooth/serial.conf /usr/etc/bluetooth/serial.conf
sudo reboot

[Step 5.]
Pair the PS3 Remote
Code:
cd ~
wget https://dl.dropboxusercontent.com/u/89032099/XBMC/ps3pair.tar.gz
tar xvfz ps3pair.tar.gz
cd ps3pair
sudo python ps3_pair.py

Activate the PS3 Activity on youre Harmony and follow the instructions

It Should now find the remote in the SSH

Code:
Searching for devices, please wait...
Found:
1: 00:04:20:E7:2B:0A [Unknown]
Select the device you wish to add [1]:

Select the device you wish to add

After this the Harmony said Unable to Pair, so i did the following:
Code:
sudo bluez-test-input connect XX:XX:XX:XX:XX:XX (replace with own mac)
And the harmony Ultimate is now Connected/Paired

[Step 5.]
Download keymap, cd to youre home/username folder:
Code:
cd .kodi/userdata/keymaps/
wget https://dl.dropboxusercontent.com/u/89032099/XBMC/keyboard.xml
cd /etc/bluetooth
sudo mv input.conf input.conf.bak
sudo wget https://dl.dropboxusercontent.com/u/89032099/XBMC/input.conf
sudo reboot

After reboot it still works great!

[Check Connection]
Code:
root@kodi:~/ps3pair# /usr/share/doc/bluez/examples/list-devices

Code:
[ /org/bluez/1056/hci0 ]
    Name = kodi-0
    Powered = 1
    Devices =
    DiscoverableTimeout = 0
    PairableTimeout = 0
    Discoverable = 0
    Address = 00:09:DD:50:8A:1F
    Discovering = 0
    Pairable = 1
    Class = 4718848
    UUIDs = 0x1000 0x1001 0x1112 0x111f 0x110a 0x110c 0x110e

[Tips]
In the ps3pair folder there is an ps3unpair.py script to repair the connection, may it ever fails.

Further customization of the Harmony Buttons, defined in:

Example: If we look at <F2> in keyboard.xml it runs the command Runaddon NetFlix, , KEY_F2 in input.conf = L2 button on the PS3 Device in Harmony, you will see on the left side of the picture L2 and that refers to NetFlix button. Thats how it works.

[/home/username/userdata/keymaps/keyboard.xml
]
Code:
<keymap>
  <global>
    <keyboard>
    <!-- Jixel Custom Keys -->
      <f2>RunAddon(plugin.video.netflixbmc)</f2>
      <f4>RunAddon(plugin.audio.tuneinradio)</f4>
      <f5>ActivateWindow(Videos,TvShowTitles)</f5>
      <f6>ActivateWindow(Videos,MovieTitles)</f6>
      <f7>ActivateWindow(MusicLibrary,nfs://192.168.1.4/MediaLibrary/Music/,Return)</f7>
      <f8>RunAddon(plugin.video.pulsar,Return)</f8>
      <f9>RunScript(&quot;script.ipcam&quot;)</f9>
      <f10>RunAddon(plugin.video.youtube,Return)</f10>
      <f11>Quit</f11>
      <pause>Pause</pause>
    <!-- Unused keys: F1(L1), F2(L2), F3(L3), INSERT(Select) -->
    </keyboard>
  </global>
  <FullscreenVideo>
      <keyboard>
      <g>showtime</g>
      <f1>ActivateWindow(SubtitleSearch)</f1>
      <f5>XBMC.ActivateWindow(osdvideosettings)</f5>
      <f6>AudioNextLanguage</f6>
      <f7>XBMC.ActivateWindow(osdaudiosettings)</f7>
    </keyboard>
  </FullscreenVideo>
</keymap>

Image

Putting old image back to verify all steps.


EDIT:
I changed some steps to make it noob proof, everyone with linux a supported bluetooth module and a harmony can follow this steps to get the job done.
Reply
#2
Wink 
Ubuntu 16 + Bluez 5

It is much easier then the old guide, but i took 60 + hours to find this out. Anyway the main difference is that we add a Windows Computer to the Harmony by the mobile app. (you can choose linux in the setup but this wont give us the commands to send so please choose Windows instead).

Step 1. Install latest Ubuntu (atm. V16). (It will automatically install bluez)
sudo apt-get install libglib2.0-dev
sudo apt-get install libdbus-1-dev
sudo apt-get install libudev-dev
sudo apt-get install libical-dev
sudo apt-get install libreadline-dev

Step 2. Get the Harmony App on Samsung or iPhone.
Step 3. Go to the Harmony App and follow the next pictures: (from left to right)
watch gallery


Step 4. Go to Terminal and type:
Code:
bluetoothctl
agent KeyboardOnly (case sensitive)
default-agent
scan on
(at this moment please choose RETRY on the harmony app on the phone)

You will see a list now and you will also see Harmony Keyboard with an MAC adress:
Code:
pair <MAC:ADRESS> (ex. pair 00:04:20:E7:2B:0A) (make sure you choose the Harmony Keyboard)
trust 00:04:20:E7:2B:0A
connect 00:04:20:E7:2B:0A

It should connect by now and you can test it. (also after reboot it automaticly reconnects)

----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------

About mapping the buttons:

First method:
Remote Control Buttons that should work always: (also outside of Kodi)
In Logitech harmony application bind buttons to the remote buttons. Like i have F1 on red F2 on green F3 yellow and F4 on blue.
Then go to ubuntu system settings-> keyboard -> shotcuts -> custom shortcuts
And here you can easily create the button actions like run a script when press F1 (red) -> F1 = python /usr/share/hyperion/scripts/effectswitch.py

Image

Second method:
You can also use /home/%username%/.kodi/userdata/keymaps/keyboard.xml to add F1 till F12, or others and give it names here. (when you add them in keyboard.xml the buttons only work within the Kodi app)
Add F1 till F12 in Harmony remote and give them names, as example, In the harmony app i configured a soft button F5 in the activity Home Theater
Image

My keyboard.xml (/home/iiidefconiii/.kodi/userdata/keymaps)
Code:
<keymap>
<global>
<keyboard>
<!-- Jixel Custom Keys -->
<f3>ActivateWindow(Videos,TvShowTitles)</f3>
<f5>RunAddon(scipt.globalsearch)</f5>
<f6>ActivateWindow(Videos,MovieTitles)</f6>
<f7>ActivateWindow(MusicLibrary,nfs://192.168.1.7/MediaLibrary/Music/,Return)</f7>
<f8>RunAddon(plugin.audio.tuneinradio)</f8>
<f9>RunAddon(plugin.video.youtube,Return)</f9>
<f11>RunAddon(script.ipcam,Return)</f11>
<f12>System.Exec(skype,Return)</f12>
<!-- Unused keys: F1(L1), F2(L2), F3(L3), INSERT(Select) -->
</keyboard>
</global>
<FullscreenVideo>
<keyboard>
<g>showtime</g>
</keyboard>
</FullscreenVideo>
</keymap>

To reconnect after a reinstall, use the phone app again -> go to hardware and press a button -> it will try to search for a new device.
Make sure youre harmony is in the activity were is uses the bluetooth (so for me Kodi)(HTPC) yous could be the activity Linux or such so. If you forget this step the connection keeps braking.
In terminal
Code:
bluetoothctl
remove MACADRESS
exit
sudo reboot
then follow the steps from step 4. again in the first section of this post.

The media start/stop buttons didnt work oob cause there were assigned by default in ubuntu keyboard settings. To make the start/stop work in Kodi:
Disable standard media keys in Ubuntu Settings - > keyboard - > Shortcuts -> Sound and Media
Image

Dont forget post youre results!
Reply
#3
This is brilliant, thanks ever so much.
Have been messing around with IR rubbish for years on harmon remotes.
Will be giving this a go, top stuff.

Can I ask if you notice the response much improved from the standard IR setup, that's the one thing that annoys me with the harmony remotes, the sluggish response is very annoying.
Reply
#4
(2015-09-17, 20:21)robo989 Wrote: This is brilliant, thanks ever so much.
Have been messing around with IR rubbish for years on harmon remotes.
Will be giving this a go, top stuff.

Can I ask if you notice the response much improved from the standard IR setup, that's the one thing that annoys me with the harmony remotes, the sluggish response is very annoying.

Thats exaclty why i tried this so freeking hard, the sluggish response. And yes I do notice a much faster response.
Reply
#5
Weird, I have never noticed any sluggishness or lag with my Harmony Smart Control: it's just as instant as the original remotes, if not better.
Reply
#6
(2015-09-17, 21:59)bobones Wrote: Weird, I have never noticed any sluggishness or lag with my Harmony Smart Control: it's just as instant as the original remotes, if not better.

Strange, which IR did you used?
Try Yatse App from Play Store and see difference
Reply
#7
(2015-09-17, 22:00)IIIdefconIII Wrote:
(2015-09-17, 21:59)bobones Wrote: Weird, I have never noticed any sluggishness or lag with my Harmony Smart Control: it's just as instant as the original remotes, if not better.

Strange, which IR did you used?
Try Yatse App from Play Store and see difference
It controls all sorts of devices so it's not the receiver. If the hub is the same as your Ultimate, then it must be your handset that introduces the lag. There is no perceptible lag with the Smart Control handset: I would guess the reaction time is 20ms or less: it seems more or less instant to me.
Reply
#8
(2015-09-18, 00:24)bobones Wrote:
(2015-09-17, 22:00)IIIdefconIII Wrote:
(2015-09-17, 21:59)bobones Wrote: Weird, I have never noticed any sluggishness or lag with my Harmony Smart Control: it's just as instant as the original remotes, if not better.

Strange, which IR did you used?
Try Yatse App from Play Store and see difference
It controls all sorts of devices so it's not the receiver. If the hub is the same as your Ultimate, then it must be your handset that introduces the lag. There is no perceptible lag with the Smart Control handset: I would guess the reaction time is 20ms or less: it seems more or less instant to me.


Could be anyway this guide killed the lag for mw
Reply
#9
(2015-09-17, 21:59)bobones Wrote: Weird, I have never noticed any sluggishness or lag with my Harmony Smart Control: it's just as instant as the original remotes, if not better.

You're the one in a million then Wink
Have experienced the same lag with Harmony 555 (two of), 650, 900 (two of), Harmony One (two of), Harmony Ultimate (two of)

Across Xbox 360, XBMC, TV (4 of)...probs lots more.

As has everyone else.

Not to be rude, just saying Smile
Reply
#10
(2015-09-19, 21:46)robo989 Wrote:
(2015-09-17, 21:59)bobones Wrote: Weird, I have never noticed any sluggishness or lag with my Harmony Smart Control: it's just as instant as the original remotes, if not better.

You're the one in a million then Wink
Have experienced the same lag with Harmony 555 (two of), 650, 900 (two of), Harmony One (two of), Harmony Ultimate (two of)

Across Xbox 360, XBMC, TV (4 of)...probs lots more.

As has everyone else.


Not to be rude, just saying Smile
Bollocks.

Which is a bit rude. But true.
Reply
#11
(2015-09-19, 22:02)trogggy Wrote:
(2015-09-19, 21:46)robo989 Wrote:
(2015-09-17, 21:59)bobones Wrote: Weird, I have never noticed any sluggishness or lag with my Harmony Smart Control: it's just as instant as the original remotes, if not better.

You're the one in a million then Wink
Have experienced the same lag with Harmony 555 (two of), 650, 900 (two of), Harmony One (two of), Harmony Ultimate (two of)

Across Xbox 360, XBMC, TV (4 of)...probs lots more.

As has everyone else.


Not to be rude, just saying Smile
Bollocks.

Which is a bit rude. But true.

Fair enough, always thought that it was a concensus on that though? I'm clearly mistaken.

@IIIdefconIII would you mind sharing what BT dongle you are using, or will anyone do? Assuming any old junk is fine...?
Many thanks again for the guide.
Reply
#12
(2015-09-20, 00:41)robo989 Wrote: @IIIdefconIII would you mind sharing what BT dongle you are using, or will anyone do? Assuming any old junk is fine...?
Many thanks again for the guide.

See OP

3. Bus 008 Device 002: ID 0a12:0001 Cambridge Silicon Radio, Ltd Bluetooth Dongle (HCI mode)

Should work with all bluetoot devices that are installed correctly on linux
Reply
#13
(2015-09-19, 21:46)robo989 Wrote:
(2015-09-17, 21:59)bobones Wrote: Weird, I have never noticed any sluggishness or lag with my Harmony Smart Control: it's just as instant as the original remotes, if not better.

You're the one in a million then Wink
Have experienced the same lag with Harmony 555 (two of), 650, 900 (two of), Harmony One (two of), Harmony Ultimate (two of)

Across Xbox 360, XBMC, TV (4 of)...probs lots more.

As has everyone else.

Not to be rude, just saying Smile
I have a Smart Control, not any of the handsets you mention. There is no detectable lag with the Smart control so come back to me when you have tried one of them.
Reply
#14
You must use "Microsoft Media Center Extender" as the device to remove any lag from the Harmony remote using IR.

I would be interested to test it up against the bluetooth response speed though.
Reply
#15
(2015-09-21, 12:56)zag Wrote: You must use "Microsoft Media Center Extender" as the device to remove any lag from the Harmony remote using IR.

I would be interested to test it up against the bluetooth response speed though.

Thanks for the info. it tried several devices, this is the way for me
Reply

Logout Mark Read Team Forum Stats Members Help
[LINUX] Logitech Harmony Ultimate on Linux Bluetooth + Support for Bluez 50