Mi IR Remote Controller

Hi,

Last few days I’m browsing through community and try to setup my IR Remote controller. I have already set it up with my Xiaomi Mi Home app and it is working as wanted.

Now I’m preparing to use the same commands with my OpenHAB setup.
-I managed to bind the controller with Mi IO binding.
-Got the thing and it is online
-created items

Now the main part. How to send IR commands? I figure it should be (somehow) possible to capture the IR string which is already set in the Mi Home App?
I tried with wireshark and monitored either the IP from which the app is running and also the IP of the destination - IR Remote. But I don’t seem to be capturing the right packet.

What Am I missing? I know there are some topics regarding this but I was not (for now) successful and I’m apologizing for extra topic.

Is it possible to find the command with the android-backup-tookit?

Thank you.

I figueree it out. The problem was as I was copying commands from community threads and applying them in PaperUI, some characters were not formatted correctly and nothing happened…

Copy/paste unformated and got all my commands.

Thanks again and great stuff in forums!

Hi fellow openhabians,

I setup my ir remote system and would appreciate your opinion regarding rules. If they are ok, if anything could be optimized or removed/changed.

WIth IR I learned 8 commands:
-Power ON
-Power OFF
-23
-24
-25
-Cool
-Heat
-Dry

My rules file:

//Variables
var boolean AC_On = false
var AC_Temp = 25
var AC_Mode = 0

//POWER
rule "AC Power ON/OFF"
when
    Item ACPower changed
then
    if( AC_On == false && ACPower.state == ON ) {
        MiIRRemoteActionsCommands.sendCommand('miIO.ir_play {"key":"1","code":"xxx"}')
        AC_On = true
    }
    else if( AC_On = true && ACPower.state == OFF ) {
        MiIRRemoteActionsCommands.sendCommand('miIO.ir_play {"key":"1","code":"xxx"}')
        AC_On = false
    }
end

//TEMPERATURE
rule "AC Temp Setting"
when
    Item actemp received command 
then
    if( AC_On == true && AC_Temp !=25 && actemp.state == 25) {
        MiIRRemoteActionsCommands.sendCommand('miIO.ir_play {"key":"1","code":"xxx"}')
        AC_Temp = 25
    }
    else if( AC_On == true && AC_Temp !=24 && actemp.state == 24 ) {
        MiIRRemoteActionsCommands.sendCommand('miIO.ir_play {"key":"1","code":"xxx"}')
        AC_Temp = 24
    }
    else if( AC_On == true && AC_Temp !=23 && actemp.state == 23 ) {
        MiIRRemoteActionsCommands.sendCommand('miIO.ir_play {"key":"1","code":"xxx"}')
        AC_Temp = 23
    }
end

//MODE
rule "AC Mode"
when
    Item acmode received command
then
    if( AC_On == true && AC_Mode != 0 && acmode.state == 0 ) {
        MiIRRemoteActionsCommands.sendCommand('miIO.ir_play {"key":"1","code":"xxx"}')
        AC_Mode = 0
    }
    else if( AC_On == true && AC_Mode != 1 && acmode.state == 1 ) {
        MiIRRemoteActionsCommands.sendCommand('miIO.ir_play {"key":"1","code":"xxx"}')
        AC_Mode = 1
    }
    else if( AC_On == true && AC_Mode != 2 && acmode.state == 2 ) {
        MiIRRemoteActionsCommands.sendCommand('miIO.ir_play {"key":"1","code":"xxx"}')
        AC_Mode = 2
    }
end

I want to know if I’m using the variable correctly.

Thank you and best regards,

1 Like

Hey Mario, did i get that right?
you took the command channel in Paper UI and just put some commands in there and executed them?

Where could I get the commands from for my Samsung TV for example?
And can I link these commands to buttons and switches in the sitemap?
Do you know that?

Best,
Timo

You can execute 3 commands with PaperUI Control:

  1. LEARN
    miIO.ir_learn {“key”: “1”}

  2. READ
    miIO.ir_read {“key”: “1”}

  3. PLAY
    miIO.ir_play {“key”:“1”,“code”:"Xxxx”}

If i remember correctly first I had to enable learning mode (step 1), next step is to make the ir read next command - executing step 2 and sending IR command from for example TV remote power button to IR remote controler. The “code” can be found in OH logs.

And with step 3 (play) you execute the “copied” command with the “code” being what you saw in logs.

Found all I needed in this community.

Hope this helps :slight_smile:

Yea this helped! Maybe a little more step by step How to would be…

  1. Acticate the Command Channel in “Show More” of the thing in OH Configuration

  2. In OH Control > Command Channel of the Remote Controller execute miIO.ir_learn {“key”: “2”} #keynumber is the id of the command. for example 1 is used for power on/off, 2 for volume up etc…

  3. Press a key on your remote pointing to the xiaomi device

  4. Execute miIO.ir_read {“key”: “2”} and the events.log will give you miio_generic_06F9867A_actions_commands changed from miIO.ir_read {“key”: “2”} to {“id”:26,“result”:{“key”:“2”,“code”:“xyz”}}

  5. Take the code and put it into…miIO.ir_play {“freq”: 38400, “code”: “xyz”} and execute it in the command channel…there you go!