HELP! How to Import IR Codes in NEC Format

Hello, noob here. I have a ThenAudio Guide-4 HDMI switch. I want to control the Inputs of the switch via the Flipper instead of having to press the button on the Guide-4 to switch sources. I obtained the IR Codes, they’re in NEC Format. I attempted to upload this as a .txt and .ir file to infrared>remote and it is not working. I assume some type of conversion needs to be done? I am not very familiar with how to do that and still learning things. Any help would be greatly appreciated. Here’s the IR Codes.

guide4_in1:
guide4_in1: NEC 0xdc 0x01
0000 006e 0000 0022 0156 00ab 0015 0015 0015 0015 0015 003f 0015 003f 0015 003f 0015 0015 0015 003f 0015 003f 0015 003f 0015 003f 0015 0015 0015 0015 0015 0015 0015 003f 0015 0015 0015 0015 0015 003f 0015 0015 0015 0015 0015 0015 0015 0015 0015 0015 0015 0015 0015 0015 0015 0015 0015 003f 0015 003f 0015 003f 0015 003f 0015 003f 0015 003f 0015 003f 0015 1d0b

guide4_in2:
guide4_in2: NEC 0xdc 0x02
0000 006e 0000 0022 0156 00ab 0015 0015 0015 0015 0015 003f 0015 003f 0015 003f 0015 0015 0015 003f 0015 003f 0015 003f 0015 003f 0015 0015 0015 0015 0015 0015 0015 003f 0015 0015 0015 0015 0015 0015 0015 003f 0015 0015 0015 0015 0015 0015 0015 0015 0015 0015 0015 0015 0015 003f 0015 0015 0015 003f 0015 003f 0015 003f 0015 003f 0015 003f 0015 003f 0015 1d0b

guide4_in3:
guide4_in3: NEC 0xdc 0x03
0000 006e 0000 0022 0156 00ab 0015 0015 0015 0015 0015 003f 0015 003f 0015 003f 0015 0015 0015 003f 0015 003f 0015 003f 0015 003f 0015 0015 0015 0015 0015 0015 0015 003f 0015 0015 0015 0015 0015 003f 0015 003f 0015 0015 0015 0015 0015 0015 0015 0015 0015 0015 0015 0015 0015 0015 0015 0015 0015 003f 0015 003f 0015 003f 0015 003f 0015 003f 0015 003f 0015 1d0b

guide4_in4:
guide4_in4: NEC 0xdc 0x04
0000 006e 0000 0022 0156 00ab 0015 0015 0015 0015 0015 003f 0015 003f 0015 003f 0015 0015 0015 003f 0015 003f 0015 003f 0015 003f 0015 0015 0015 0015 0015 0015 0015 003f 0015 0015 0015 0015 0015 0015 0015 0015 0015 003f 0015 0015 0015 0015 0015 0015 0015 0015 0015 0015 0015 003f 0015 003f 0015 0015 0015 003f 0015 003f 0015 003f 0015 003f 0015 003f 0015 1d0b

1 Like

Anyone?

Your data seems to be redundant.

There are two types of buttons in a flipper .ir file , ‘parsed’ and ‘raw’.

Example of raw: Flipper-IRDB/LED_Candles.ir at main · Lucaslhm/Flipper-IRDB · GitHub

name: POWER
type: raw
frequency: 38000
duty_cycle: 0.330000
data: 9751 4494 630 546 627 549 634 542 631 545 628 548 635 541 632 544 629 547 636 1645 629 1653 631 1650 634 1647 627 1654 630 1651 633 1648 636 1645 628 547 626 550 633 542 631 544 629 547 626 550 633 542 631 544 629 1653 631 1650 634 1647 627 1654 630 1651 633 1647 627 1654 630 1651 633 39795 9729 2233 627 95978 9727 2227 633

Example of parsed: Flipper-IRDB/Rgb_magic_lighting.ir at main · Lucaslhm/Flipper-IRDB · GitHub

name: On
type: parsed
protocol: NEC
address: 00 00 00 00
command: 07 00 00 00

Your data shows both. I would start with the encoded line.

name: guide4_in1
type: parsed
protocol: NEC
address: DC 00 00 00
command: 01 00 00 00

Sometimes the NEC codes are coming reversed. In that case you need to convert them to bin, reverse the string and convert the result to hex.
Some guys have done this here: Help translating command code to flipper zero format - #7 by LupusE

If this doesn’t work in one way or the other, we still have some kind of raw codes.
It seems they are hex and needed to be converted in dec… But keep this in mind for later.

1 Like

Thank you for your reply! I will try out the encoded line.

I copied and pasted those values from ThenAudio website. This is the link to their site that displays those values for the Guide4 HDMI Switch. https://www.thenaudio.com/wp-content/uploads/2022/11/guide4-ircodes.txt They also state: “The IR codes are NEC format with a device code of 0xDC. There are four commands 0x01, 0x02, 0x03, 0x04 corresponding to the selected input port.” I don’t know if this additional info would be helpful to you. On the Guide4 it has a single Momentary button that’s pressed to cycle through the 4 inputs so may be why the codes are redundant? If that made any sense lol. Thoughts? Thanks again!

Since we’ve tried the reversing some time ago with Excel, and Excel does not support string reversing natively, I’ve wanted to try it in python, some day. It seems this topic will pop up more often in future.

Not very pretty to do it in one line. But it is working.

        btnaddr_arr = btnaddr.split(" ")
        btncomm_arr = btncomm.split(" ")

        sserdda = format(int(((bin(int('1'+btnaddr_arr[0], 16))[3:])[::-1]), 2),'X').zfill(2)
        dnammoc = format(int(((bin(int('1'+btncomm_arr[0], 16))[3:])[::-1]), 2),'X').zfill(2)

It is twice, because of the ‘command’ and the ‘address’ field.
btnaddr_arr[0] - After split by " ", take only the first element
(bin(int('1'+ [ ] , 16))[3:]) - convert hex to bin, ‘1’ to keep the leading 0(s)
[::-1] - reverse the whole string
format(int( [ ] ), 2),'X') - convert bin to hex
.zfill(2) - add leading zero

At the moment only the first two digits are relevant. Later we can use it in a loop on every block of 2.

A first POC for 'take the file, process all buttons and print the result on the console: FlipperMgmt/reverse-NEC.py at main · LupusE/FlipperMgmt · GitHub

2 Likes
name: guide4_in1
type: parsed
protocol: NEC
address: DC 00 00 00
command: 01 00 00 00

So this worked for Input 1, thanks a lot!. However I I am lost on how to convert for the other codes. Are you able to convert the remaining inputs , 2, 3 and 4 for me please? I would really appreciate it! Thanks!

1 Like

I’d consider him our local expert on IR. Nothing should change for any of the other buttons accept for what you want to name the button and the line that says
command: 01 00 00 00

The digits that represent the part that changes are as follows.

0x01
0x02
0x03
0x04

Split the codes in half with a space.
0x 01
0x 02
0x 03
0x 04

Reverse the two chunks.
01 0x
02 0x
03 0x
04 0x

0x means the rest of the code is all zeros. We know the code contains eight digits so here is what they are.

01 00 00 00
02 00 00 00
03 00 00 00
04 00 00 00

Now we know the last line just goes up like this.

command: 01 00 00 00
command: 02 00 00 00
command: 03 00 00 00
command: 04 00 00 00

1 Like

When this button is working, than no conversion/reversing is needed. And I’ve put so much brain cells in this script :frowning:
Just copy-and-paste the buttons and replace the lines name: and command:.

Create a file, with some_rememberable_name.ir

Filetype: IR signals file
Version: 1
# 
name: guide4_in1
type: parsed
protocol: NEC
address: DC 00 00 00
command: 01 00 00 00
# 
name: guide4_in2
type: parsed
protocol: NEC
address: DC 00 00 00
command: 02 00 00 00
# 
name: guide4_in3
type: parsed
protocol: NEC
address: DC 00 00 00
command: 03 00 00 00
# 
name: guide4_in4
type: parsed
protocol: NEC
address: DC 00 00 00
command: 04 00 00 00

Not quite a challenge, but it was nice to take a look at the possibilities. Thanks for your feedback.
If you’d like to thank, please consider to upload your tested and working file to the Flipper-IRDB.

  1. Login in your Github.com account or create one.
  2. Go to GitHub - logickworkshop/Flipper-IRDB: A collective of different IRs for the Flipper
  3. Clone this repo to your account (on the top right you’ll find the button fork. Click it and choose + Create a new fork.
  4. Go to your Repo, browse to Converters
  5. Add a folder, named Thenaudio. (I really have no Idea how to create a Folder in the Webclient)
  6. Upload your file named Guide-4_HDMI_Switch.ir in the former created folder.
  7. On the top of the files list something like ’ This branch is [1 commit ahead] of Lucaslhm:main.’. At the end of this Line you’ll get a Button Contribute.
  8. Click this Button and chose Open pull request. Fill out every field you can.
    Maybe you are better than me and post the link to your source or to this forum post in the description.
  9. The people from the Flipper-IRDB will review your file and accept or deny it.
1 Like

Thank you so much for the time and effort you put in to helping me! I really appreciate it! I was confused, but it is all clear now! I have a working IR file for my Guide4. Again, thank you so much to @LupusE and @jmr for your help. A double thanks to @LupusE for burning a ton of brain cells on this! :smiley: I will upload the working codes for the Guide 3 and 4 since it uses the same codes minus Input 4.

Thank you! This, along with @LupusE input helped me understand all of this. I am an IT guy, but IR is totally new to me. Not much of a Python guy unless I am SSH’ing into stuff, like Routers and Switches, etc. The Flipper has led me to learn many new things, which is why I bought it!

1 Like

The Flipper is an amazing learning tool. I’ve learned some cool new things and I’m far from done. I’ve heard people say the Flipper is something you buy and toss in a drawer after a couple weeks. They’ve missed the point in my opinion.