Confusion around Sony Infrared codes (SIRC)

Heyhey, might be a bit farfetched, but maybe I’m lucky. I’m currently working on replacing my default IR tv remote control with an esphome-based one. Part of that is that I’d like to make the HDMI inputs directly selectable, without having to press the input button to cycle through the available inputs until I’m at the right one. My current remote control doesnt have dedicated buttons for that.
So I started with connecting an IR receiver to an esp32 and documenting existing codes via GitHub - IRMP-org/IRMP: Infrared Multi Protocol Decoder

The codes I get for the relevant buttons I also want to use (volume up/down, mute, play, pause, …) all line up nicely with what I find online about the Sony protocol (e.g. on So funktioniert das SONY SIRCS/CTRL-S Protokoll / How SONY's SIRCS/CTRL-S protocol works):
12 for volume up, 13 for volume down, 14 for mute, etcetc


The problem I’m facing: my remote doesnt have dedicated “switch to hdmi1”, “switch to hdmi2” etc buttons. They do exist for sony tvs, I found a remote controller online:

And when I’m searching for other SIRC lists I can find entries that mention the hdmi buttons, but they dont match the code format that I get for my remote. Here is a list e.g. (Codes for IR Remotes - Tasmota) where volume up and down hsa different codes than mine:

In case I’m lucky: does anyone here have experience with SIRC across different devices and device classes and can explain the differences to me? First I thought I just need to transform the values, but now I think that Sony got less consequent with its code usage over the years…

Thanks in advance! Cheers :slight_smile:

Okay, in the end I figured it out, might wright a longer post some time for others who are struggling with what they find on the web (or who like me didnt have enough math and informatics in school/university :wink: ), but for now the short version by going through one example (for 12bit codes, 15 and 20 work similar though):

“Volume up” code in hexadecimal (command and address in one, 12 bit version of SIRC): 0x490

Converted to binary: 010010010000

Now the first 7 bits are the command, the remaining 5 are the address

0100100 => command
10000 => address

BUT: the sony protocol/remote sends the binary command the other way around. Therefore:

0100100 => 0010010
10000 => 00001

0010010 converted to hex is 12, converted to decimal is 18
00001 converted to hex is 1, same for decimal

Depending on which resource for sony codes you use, they might use different methods to provide the codes.

Codes for IR Remotes - Tasmota uses the “command and address in one hex value” format: 0x490 for “volume up”

So funktioniert das SONY SIRCS/CTRL-S Protokoll / How SONY's SIRCS/CTRL-S protocol works uses “command and address separate, still in hex” format: 12 for “volume up”

SB-Projects - IR - Sony SIRC Protocol uses the “command and address separate, but in decimal” format: 18 for “volume up”

With that in mind you can basically use any (correct) Sony SIRC list on the web and calculate back and forth to the format that your code needs. esphome uses the “command and address in one hex number” version, the arduino libs I used so far use the “command and address separate, both hex” version.

I used Hex to Binary Converter to convert back and forth. Oh, one thing left: when you convert something that is supposed to be from the 15bit protocol (0x2CE9 for play/pause), a converter will give you 16 bits. Just cut off the first zero in that case, before you split up and revert the rest of the code as in the example above.