Logitech Harmony Custom Buttons with iR

The first topic I'll address is using adb to open apps on the Fire Stick or Android TV. I typed this post a while ago but did some quick edits.

Firstly, You have to download adb with the Android SDK platform tools:

sudo apt-get install -y android-tools-adb

To connect to your fire stick: Enable Developer Settings and ADB then;

adb connect fireIPaddress:5555

Make sure to authorize your pi once you press enter, a window will pop up, on your TV; remember the device and connect.

Here are a couple examples:
If you want to open Playstation Vue:

adb shell monkey -p com.snei.vue.firetv 1

Get the listings for your installed apps by doing this:

adb shell pm list packages

Copy the result to the clipboard and paste it in notepad so you can search it.

If an app is just nowhere to be found: Install it in your Android device from the play store and use another app that allows you to extract apks from your phone (apk extract).

Find the app and look at the package name, then reference the adb result you pasted in notepad. Replace the psvue (above) with the proper package name and run it as a test. HBO Max requires a special call:

adb shell monkey -p com.hbo.hbonow -c android.intent.category.LEANBACK_LAUNCHER 1

For Remote Commands:

adb shell input keyevent (code from above)

Personally, I exclusively use RPi to receive commands from my Harmony for switching apps, the commands that I have set up for a dummy device are received by a MCE Remote Receiver.

In the next section, I'll describe how to use the pi to invoke a piston by using irexec and curl

Ok. Once you have a learned remote, you'll first want to invoke a connection to the proper fire stick with a button press at the start of activity.

So, I have HDMI_1 for my Living Room Fire Stick

It executes this script in my ~ directory:

#! /bin/sh -e
adb kill-server
adb connect

I called this file adblr

This means HDMI_1 is pressed to execute the script above....

This should be run for all activities, as far up as you can get it in the power on sequence of the activity.

Next is to edit irexec:

sudo nano /etc/lirc/irexec.lircrc

   prog   = irexec
   remote = ACTIONS
   button = IR_INPUT_HDMI_1
   config = sh /home/pi/adblr

Do this for each button you learned that you want to execute a piston for, this will be at least 7 entries for the 4 HC buttons, the rocker, and the script above. You can assign them to whatever you want from the remote you learned.

The syntax for the irexec actions that you want your pi to execute is everything from 'begin' to 'end' (including the words and indentation)

Here is where the fun starts:

In irexec.lircrc you need to add things to execute for each button press.

   prog   = irexec
   remote = ACTIONS
   button = IR_INSTOP
   config = curl https://cloud.hubitat.com/api/apicall

In the syntax:
'remote' is the name of your remote that lirc can find in the lircd.conf.d directory (case sensitive)

'button' is pretty self explanatory, but must match exact name

'config' is what you want to execute

The curl API call is actually "External URL" on the piston.

After you make sure that your remote files have no second column of 0x0000000 in there and they are copied from your home folder to /etc/lirc/lircd.conf.d you can do:

sudo cp *.lircd.conf /etc/lirc/lircd.conf.d/.
sudo chown root:root /etc/lirc/lircd.conf.d/.
sudo systemctl restart lircd

First, execute 'irw' and press some buttons you have learned. They should show there.

Press control-c to end irw

If the buttons you pressed are repeating, you'll need to edit your remote file and add: min_repeat and suppress_repeat, around here:

gap          107843
min_repeat 1
suppress_repeat 2
toggle_bit_mask 0x0


sudo systemctl enable irexec
sudo systemctl start irexec
sudo systemctl restart lircd

That's it for tonight, I will compose the pistons tomorrow and post the import codes with explanations.


Reserved 2

Reserved 3

Reserved 4

This topic was automatically closed 365 days after the last reply. New replies are no longer allowed.