Guide for dummies - Send IR signals with Homey Pro 2016-2019

I recently worked out how to control infrared devices by sending IR signals with Homey, so here’s a guide so you can do the same. It is way more complicated than it should be (if you have the old, white ball version of Homey), but at least there is a way. You need to create an app, set up flow cards and IR signals, and install it to your Homey. The steps are detailed below.

If you have a newer Homey Pro (flat black thingy), there should be flow cards available to send IR signals out of the box. Recording IR signals is not possible, though.

The guide is written for Windows computers, but should work much the same for Mac and Linux as well.

Step 0: Check if IR device already exist in Homey

Before going through all the work of creating you own app, check if the device already exist in Homey’s library. In the Homey App, go to

Device → New Device → Infrared

and search for your brand name. The search algorithm is wonky, so make sure you type the entire name. “Opto” gives 0 results, “Optoma” gives plenty.

Step 1: Get the IR signal

Option A: You have a remote (or something that sends the IR signal)

Download and install IR Scrutinizer ( IrScrutinizer – AppImages )

Head over to https://tools.developer.homey.app/ (and make sure you’re log in) and scroll down until you find “RF” in the left hand side menu.

In the dropdown meny next to the record button, select “Infrared”

Click the red record button

Click the button on your remote (or whatever is sending the IR signal), while pointing it towards Homey

The signal should appear as a bunch of comma separated numbers

(If this isn’t working, try turning off the led ring on your Homey and repeat)

Copy the numbers and open IR Scrutinizer

Click “Paste & Scr.”

You should now see a bunch of numbers and letters in groups of four. Copy these and store them somewhere (for instance in notepad).

Repeat for all other IR signals

Option B: You don’t have anything that sends this IR signal

Check out this database of IR codes ( GitHub - probonopd/irdb: One of the largest crowd-sourced, manufacturer-independent databases of infrared remote control codes on the web, and aspiring to become the most comprehensive and most accurate one ), or try searching online for your device, along with “ir prontohex” and see if anything shows up.

Step 2: Test the signal

Go back to https://tools.developer.homey.app/ and this time go to “Infrared” in the left side menu.

Paste the prontohex code you got from IR Scrutinizer or from the web, and enter “1” in the “Repetitions” box

Click send and verify that your device responded. If not, the device might be out of range or there’s something wrong with the prontohex signal.

Hopefully, you now have a list of all the IR signals you want and have checked that they work!

Step 3: Become a developer

Download Node.js to your computer and install ( Node.js — Download Node.js® )

Open command prompt and enter the following command: npm install -g homey

After it’s installed enter this command: homey login

Log in with your Homey account and click allow

Done!

(If you stuggle, check out the official video from Homey: https://www.youtube.com/watch?v=v_RUamZzby8)

Step 4: Create the app

In Command Propt, enter the following command: cd Desktop

Next, enter this command: homey app create

Give your app a name and description

Give your app an ID (The convention is to use the reverse of a domain name, but I think anything goes)

Select a category, and then hit Enter until you see green text saying your app is installing

Next, enter this command: cd *app ID*

(replace *app ID* with the ID you gave your app just moments ago)

Well done!

Step 5: Create the flow cards

For each signal, we need a flow card.

In Command Prompt, enter the following: homey app flow create

Select “Action (then)”

Give it a title and an ID (the title and ID should reflect a specific ir signal, for instance “Turn on receiver”)

Hit enter to skip the hint

Type No when asked about arguments

Click enter to create the flow card

Repeat this step for each of your signals

(Note: There is likely a way to add a dropdown argument so that only one action card is needed, and the argument refers to the IR signal you want to send. This task is left as an exercise to the reader (but do let me know if you work out how))

Step 6: Edit the app

Note: You can do all the editing in Notepad, as described in the steps, but using a software that understands code (notepad++, visual studio code, etc. will make it much easier to spot typing errors).

6.1 Create permission for infrared

Click Win + E (open file explorer) and navigate to your app. It should be under C:\Users\*username*\*app ID*

First, open the .homeycompose folder and find “app.json” (Note: this is different from the app.json in the main folder! Make sure you are looking in the .homeycompose folder)

Right click the file and select “edit in notepad”

Find “permissions”: [ ] and enter “homey:wireless:ir” (With the quotation marks) inside the square brackets. It should now look like

“permissions”: [ “homey:wireless:ir”],

Save and close the file

6.2 Create signal file

Open notepad and hit Ctrl + n (new document).

Enter the following:

{

“type”: “prontohex”,

“cmds”: {

"*signal 1*": "*prontohex code*",

"*signal 2*": "*prontohex code*"

}

}

Replace signal x with a name for each signal and prontohex code with the corresponding code from Step 2.

NB! Make sure there is a comma after each prontohex (after the quotation mark), except for the last one.

Click File → Save As, and navigate to C:\Users\*username*\*app ID*\.homeycompose\signals\ir

Change the name to “my_signal.json” and change the “Save as type” to “All files”

6.3 Edit the app.js file

Go back to file explorer and navigate to the main app folder (C:\Users\*username*\*app ID*)

Right click app.js and open in notepad (Note: we want app.js, NOT app.json)

Find “this.log(“My app has been initialized”);

Place your cursor right behind the semi colon and hit enter to create a new line.

Paste the following text: const mySignal = this.homey.rf.getSignalInfrared(“my_signal”)

Hit enter again to insert a new line, and paste the following command:

const *some name* = this.homey.flow.getActionCard(“*flow card ID*”);

Change *some name* into some name for this card (without spaces or special characters) and change *flow card ID* to the actual ID of one of your flow cards.

(For instance: const cardTV = this.homey.flow.getActionCard(“watch-tv”):wink:

Copy and paste the line, one for each flow card you’ve made, and change the name and ID correspondingly. (Make sure to hit enter each time so that they don’t appear right after each other on the same line)

(If you don’t remember the ID of your flow cards, look in C:\*users*\*app ID*\.homeycompose\flow\actions. The ID of the flow card is the same as the file name.)

Next, paste this chunk of code right below:

*some name*.registerRunListener(async () => {

await mySignal.cmd(“*IR signal name*”)

})


Change \*some name\* into the one of names you used above, and \*IR signal name\* to the corresponding name used for the signal in Step 6.2

Copy this chunck and paste it, once for each signal, and change the \*some name\* and \*IR signal name\* for each

(If you are confused at any point, compare your code to mine: https://github.com/jonsoln/com.jb.IR )

DONE! Your app should be ready now!

# Step 7: Test the app

In Command Prompt, type: homey app run

The app should hopefully initialize correctly without errors

Now, go to your Homey app on your phone, or to my.homey.app

Go to Flow → New Flow

Add a When-card, choose Flow → This Flow is started

Click Done

Add a Then-card, scroll down to apps and find your app

Select one of the flow cards

Click Done

Click the play button to test your flow.

Check that your IR device responded as expected.

Great success!

# Step 8: Install the app

In command prompt, hit CTRL + C to abort the testing

Type the following command: homey app install

You did it! Now you can create flows to send IR signals.

# Appendix

Shout out to Jamie ( https://community.homey.app/t/creating-an-infrared-ir-device/79385 ) for making a guide that got me thinking “I can do this!”
1 Like