Xiaomi Mi Infrared Remote Control

So I’ve registered the device, extracted the token and created a unsupported item with all necessary informations.
Using the cmd channel is no problem, but how can I retrieve the IR commands sent to the IR Receiver?

I have problem with learn ir code from panasonic remote ac, it has 1 button on/off but i can’t find ir code of off mode ! thanks
anybody know ?

Hi everyone,

I have a short question regarding a volume UP/DOWN command. Currently the command is executed proper once each time I press e.g. UP. So I have to press 50 times UP to get my value. I could create a rule that executes 50 times but I was hoping that it exists sth. Like a long press. With my enocean binding this is working perfect that when I press the button command is send out and if I release it the command stops.

Does sth. Like this exists for thé IR-Remote?

Thx

Woogi

No one an idea?

@Manbearpig73; @marcel_verpaalen is sth. like a longpress for xiaomi IR-remote possible? I would like to avoid to execute my command 50 times instead of keep button pressed for let’s say 15 seconds.

thx

@Woogi sorry, no idea. I don’t have such a IR device.

Hello everyone,

I have got this device working.
But have one remaining problem.

I use this device to controle my radio and created a couple of virtual switches to activate functions like the volume.
The switches triggers rules that sends the correct code to the Xiaomi device.
This workes correct. But only when I press the “volume button” very slowly.

But when I press a switch a few times fast, I notice a annoying lag.
At first I thougt it was the Xiaomi device or maybe my wifi.
But when I test simular functions on the app “my home” (supplied by Xiaomi) de device works relatively fast (sometimes 1 or 2 seconds of delay, but nothing realy disturbing).

I have attaced some logging.
In this test case I have pressed the volume button"(switch) 15 times, in about 5 seconds.
The first 5 commands where processed relatively fast, but then the lagging starts en it takes almost a minute to process the lot. (as can be seen in the logging)
I have noticed that the first 5 commands seem to be processed serial. But then they seem to be queued (or something).

I have increased the thread pool to a higher value
editing /etc/openhab2/service/runtime.cfg and adding line

(org.eclipse.smarthome.threadpool:RuleEngine=10)

But this did not seem to help in my case.
I have experimented by adding a timer delay. But to now reveale.
https://community.openhab.org/t/why-have-my-rules-stopped-running-why-thread-sleep-is-a-bad-idea/47695.

I am new to the software and don’t realy know how te proceed.
Any help would be greately appreciated.

rules:
rule “Volume”
when Item Volume_media received command
then if (receivedCommand == ON){
createTimer(now, [|
MIio_executeCmnd.sendCommand(‘miIO.ir_play {“freq”: 38400, “code”:“nE5mkwlk0mk3mEsms2mEsmM2AI8ANJqAGwB9gD8Bz4GtAW2BTYEHg1eCl4NngIOEr4MfgMeCV4MlgI3MIAA=”}’)
])
Volume_media.postUpdate(NULL)
}
else if (receivedCommand == OFF){
createTimer(now, [|
MIio_executeCmnd.sendCommand(‘miIO.ir_play {“freq”: 38400, “code”:“nE5mcwlk0mk3mEsms1mEsmM2nABDgItNZsAP4A/gc+AQ4EMTkAMpkBTYLVzQCjwIKAI8EPwhvBs8B/wnfBj4Pr5hAA==”}’)
])
Volume_media.postUpdate(NULL)
}

items:
Group Media
Switch Power_media “ON OF Switch”
Switch Volume_media “Volume up down” {autoupdate=“false”}
Switch Mute_media “Mute” {autoupdate=“false”}
Number Source_media “Source Channel”
String MIio_executeCmnd “Mi IO Execute Command” { channel=“miio:generic:07682051:actions#commands” }

events.log

2020-01-05 20:57:41.336 [ome.event.ItemCommandEvent] - Item 'MIio_executeCmnd' received command miIO.ir_play {"freq": 38400, "code":"nE5mkwlk0mk3mEsms2mEsmM2AI8ANJqAGwB9gD8Bz4GtAW2BTYEHg1e>
2020-01-05 20:57:41.340 [nt.ItemStatePredictedEvent] - MIio_executeCmnd predicted to become miIO.ir_play {"freq": 38400, "code":"nE5mkwlk0mk3mEsms2mEsmM2AI8ANJqAGwB9gD8Bz4GtAW2BTYEHg1eCl4N>
2020-01-05 20:57:41.342 [vent.ItemStateChangedEvent] - MIio_executeCmnd changed from {"id":217,"result":["ok"]} to miIO.ir_play {"freq": 38400, "code":"nE5mkwlk0mk3mEsms2mEsmM2AI8ANJqAGwB9>
2020-01-05 20:57:41.991 [vent.ItemStateChangedEvent] - MIio_executeCmnd changed from miIO.ir_play {"freq": 38400, "code":"nE5mkwlk0mk3mEsms2mEsmM2AI8ANJqAGwB9gD8Bz4GtAW2BTYEHg1eCl4NngIOEr4>
2020-01-05 20:57:41.992 [vent.ItemStateChangedEvent] - MiIO_ExecuteCommand changed from {"id":217,"result":["ok"]} to {"id":227,"result":["ok"]}
2020-01-05 20:57:42.414 [ome.event.ItemCommandEvent] - Item 'Volume_media' received command ON
2020-01-05 20:57:42.425 [ome.event.ItemCommandEvent] - Item 'MIio_executeCmnd' received command miIO.ir_play {"freq": 38400, "code":"nE5mkwlk0mk3mEsms2mEsmM2AI8ANJqAGwB9gD8Bz4GtAW2BTYEHg1e>
2020-01-05 20:57:42.428 [nt.ItemStatePredictedEvent] - MIio_executeCmnd predicted to become miIO.ir_play {"freq": 38400, "code":"nE5mkwlk0mk3mEsms2mEsmM2AI8ANJqAGwB9gD8Bz4GtAW2BTYEHg1eCl4N>
2020-01-05 20:57:42.429 [vent.ItemStateChangedEvent] - MIio_executeCmnd changed from {"id":227,"result":["ok"]} to miIO.ir_play {"freq": 38400, "code":"nE5mkwlk0mk3mEsms2mEsmM2AI8ANJqAGwB9>
2020-01-05 20:57:42.930 [vent.ItemStateChangedEvent] - MIio_executeCmnd changed from miIO.ir_play {"freq": 38400, "code":"nE5mkwlk0mk3mEsms2mEsmM2AI8ANJqAGwB9gD8Bz4GtAW2BTYEHg1eCl4NngIOEr4>
2020-01-05 20:57:42.932 [vent.ItemStateChangedEvent] - MiIO_ExecuteCommand changed from {"id":227,"result":["ok"]} to {"id":228,"result":["ok"]}
2020-01-05 20:57:43.516 [ome.event.ItemCommandEvent] - Item 'Volume_media' received command ON
2020-01-05 20:57:43.524 [ome.event.ItemCommandEvent] - Item 'MIio_executeCmnd' received command miIO.ir_play {"freq": 38400, "code":"nE5mkwlk0mk3mEsms2mEsmM2AI8ANJqAGwB9gD8Bz4GtAW2BTYEHg1e>
2020-01-05 20:57:43.529 [nt.ItemStatePredictedEvent] - MIio_executeCmnd predicted to become miIO.ir_play {"freq": 38400, "code":"nE5mkwlk0mk3mEsms2mEsmM2AI8ANJqAGwB9gD8Bz4GtAW2BTYEHg1eCl4N>
2020-01-05 20:57:43.533 [vent.ItemStateChangedEvent] - MIio_executeCmnd changed from {"id":228,"result":["ok"]} to miIO.ir_play {"freq": 38400, "code":"nE5mkwlk0mk3mEsms2mEsmM2AI8ANJqAGwB9>
2020-01-05 20:57:43.752 [vent.ItemStateChangedEvent] - MIio_executeCmnd changed from miIO.ir_play {"freq": 38400, "code":"nE5mkwlk0mk3mEsms2mEsmM2AI8ANJqAGwB9gD8Bz4GtAW2BTYEHg1eCl4NngIOEr4>
2020-01-05 20:57:43.753 [vent.ItemStateChangedEvent] - MiIO_ExecuteCommand changed from {"id":228,"result":["ok"]} to {"id":229,"result":["ok"]}
2020-01-05 20:57:44.903 [ome.event.ItemCommandEvent] - Item 'Volume_media' received command ON
2020-01-05 20:57:44.911 [ome.event.ItemCommandEvent] - Item 'MIio_executeCmnd' received command miIO.ir_play {"freq": 38400, "code":"nE5mkwlk0mk3mEsms2mEsmM2AI8ANJqAGwB9gD8Bz4GtAW2BTYEHg1e>
2020-01-05 20:57:44.913 [nt.ItemStatePredictedEvent] - MIio_executeCmnd predicted to become miIO.ir_play {"freq": 38400, "code":"nE5mkwlk0mk3mEsms2mEsmM2AI8ANJqAGwB9gD8Bz4GtAW2BTYEHg1eCl4N>
2020-01-05 20:57:44.914 [vent.ItemStateChangedEvent] - MIio_executeCmnd changed from {"id":229,"result":["ok"]} to miIO.ir_play {"freq": 38400, "code":"nE5mkwlk0mk3mEsms2mEsmM2AI8ANJqAGwB9>
2020-01-05 20:57:45.391 [vent.ItemStateChangedEvent] - MIio_executeCmnd changed from miIO.ir_play {"freq": 38400, "code":"nE5mkwlk0mk3mEsms2mEsmM2AI8ANJqAGwB9gD8Bz4GtAW2BTYEHg1eCl4NngIOEr4>
2020-01-05 20:57:45.392 [vent.ItemStateChangedEvent] - MiIO_ExecuteCommand changed from {"id":229,"result":["ok"]} to {"id":230,"result":["ok"]}
2020-01-05 20:57:46.570 [ome.event.ItemCommandEvent] - Item 'Volume_media' received command ON
2020-01-05 20:57:46.581 [ome.event.ItemCommandEvent] - Item 'MIio_executeCmnd' received command miIO.ir_play {"freq": 38400, "code":"nE5mkwlk0mk3mEsms2mEsmM2AI8ANJqAGwB9gD8Bz4GtAW2BTYEHg1e>
2020-01-05 20:57:46.585 [nt.ItemStatePredictedEvent] - MIio_executeCmnd predicted to become miIO.ir_play {"freq": 38400, "code":"nE5mkwlk0mk3mEsms2mEsmM2AI8ANJqAGwB9gD8Bz4GtAW2BTYEHg1eCl4N>
2020-01-05 20:57:46.587 [vent.ItemStateChangedEvent] - MIio_executeCmnd changed from {"id":230,"result":["ok"]} to miIO.ir_play {"freq": 38400, "code":"nE5mkwlk0mk3mEsms2mEsmM2AI8ANJqAGwB9>
2020-01-05 20:57:49.642 [ome.event.ItemCommandEvent] - Item 'Volume_media' received command ON
2020-01-05 20:57:49.650 [ome.event.ItemCommandEvent] - Item 'MIio_executeCmnd' received command miIO.ir_play {"freq": 38400, "code":"nE5mkwlk0mk3mEsms2mEsmM2AI8ANJqAGwB9gD8Bz4GtAW2BTYEHg1e>
2020-01-05 20:57:49.651 [nt.ItemStatePredictedEvent] - MIio_executeCmnd predicted to become miIO.ir_play {"freq": 38400, "code":"nE5mkwlk0mk3mEsms2mEsmM2AI8ANJqAGwB9gD8Bz4GtAW2BTYEHg1eCl4N>
2020-01-05 20:57:50.116 [ome.event.ItemCommandEvent] - Item 'Volume_media' received command ON
2020-01-05 20:57:50.125 [ome.event.ItemCommandEvent] - Item 'MIio_executeCmnd' received command miIO.ir_play {"freq": 38400, "code":"nE5mkwlk0mk3mEsms2mEsmM2AI8ANJqAGwB9gD8Bz4GtAW2BTYEHg1e>
2020-01-05 20:57:50.128 [nt.ItemStatePredictedEvent] - MIio_executeCmnd predicted to become miIO.ir_play {"freq": 38400, "code":"nE5mkwlk0mk3mEsms2mEsmM2AI8ANJqAGwB9gD8Bz4GtAW2BTYEHg1eCl4N>
2020-01-05 20:57:50.574 [ome.event.ItemCommandEvent] - Item 'Volume_media' received command ON
2020-01-05 20:57:50.577 [ome.event.ItemCommandEvent] - Item 'MIio_executeCmnd' received command miIO.ir_play {"freq": 38400, "code":"nE5mkwlk0mk3mEsms2mEsmM2AI8ANJqAGwB9gD8Bz4GtAW2BTYEHg1e>
2020-01-05 20:57:50.580 [nt.ItemStatePredictedEvent] - MIio_executeCmnd predicted to become miIO.ir_play {"freq": 38400, "code":"nE5mkwlk0mk3mEsms2mEsmM2AI8ANJqAGwB9gD8Bz4GtAW2BTYEHg1eCl4N>
2020-01-05 20:57:51.049 [ome.event.ItemCommandEvent] - Item 'Volume_media' received command ON
2020-01-05 20:57:51.090 [ome.event.ItemCommandEvent] - Item 'MIio_executeCmnd' received command miIO.ir_play {"freq": 38400, "code":"nE5mkwlk0mk3mEsms2mEsmM2AI8ANJqAGwB9gD8Bz4GtAW2BTYEHg1e>
2020-01-05 20:57:51.094 [nt.ItemStatePredictedEvent] - MIio_executeCmnd predicted to become miIO.ir_play {"freq": 38400, "code":"nE5mkwlk0mk3mEsms2mEsmM2AI8ANJqAGwB9gD8Bz4GtAW2BTYEHg1eCl4N>
2020-01-05 20:57:51.591 [ome.event.ItemCommandEvent] - Item 'Volume_media' received command ON
2020-01-05 20:57:51.595 [ome.event.ItemCommandEvent] - Item 'MIio_executeCmnd' received command miIO.ir_play {"freq": 38400, "code":"nE5mkwlk0mk3mEsms2mEsmM2AI8ANJqAGwB9gD8Bz4GtAW2BTYEHg1e>
2020-01-05 20:57:51.597 [nt.ItemStatePredictedEvent] - MIio_executeCmnd predicted to become miIO.ir_play {"freq": 38400, "code":"nE5mkwlk0mk3mEsms2mEsmM2AI8ANJqAGwB9gD8Bz4GtAW2BTYEHg1eCl4N>
2020-01-05 20:57:52.057 [ome.event.ItemCommandEvent] - Item 'Volume_media' received command ON
2020-01-05 20:57:52.061 [ome.event.ItemCommandEvent] - Item 'MIio_executeCmnd' received command miIO.ir_play {"freq": 38400, "code":"nE5mkwlk0mk3mEsms2mEsmM2AI8ANJqAGwB9gD8Bz4GtAW2BTYEHg1e>
2020-01-05 20:57:52.062 [nt.ItemStatePredictedEvent] - MIio_executeCmnd predicted to become miIO.ir_play {"freq": 38400, "code":"nE5mkwlk0mk3mEsms2mEsmM2AI8ANJqAGwB9gD8Bz4GtAW2BTYEHg1eCl4N>
2020-01-05 20:57:52.563 [ome.event.ItemCommandEvent] - Item 'Volume_media' received command ON
2020-01-05 20:57:52.566 [ome.event.ItemCommandEvent] - Item 'MIio_executeCmnd' received command miIO.ir_play {"freq": 38400, "code":"nE5mkwlk0mk3mEsms2mEsmM2AI8ANJqAGwB9gD8Bz4GtAW2BTYEHg1e>
2020-01-05 20:57:52.567 [nt.ItemStatePredictedEvent] - MIio_executeCmnd predicted to become miIO.ir_play {"freq": 38400, "code":"nE5mkwlk0mk3mEsms2mEsmM2AI8ANJqAGwB9gD8Bz4GtAW2BTYEHg1eCl4N>
2020-01-05 20:57:53.091 [ome.event.ItemCommandEvent] - Item 'Volume_media' received command ON
2020-01-05 20:57:53.096 [ome.event.ItemCommandEvent] - Item 'MIio_executeCmnd' received command miIO.ir_play {"freq": 38400, "code":"nE5mkwlk0mk3mEsms2mEsmM2AI8ANJqAGwB9gD8Bz4GtAW2BTYEHg1e>
2020-01-05 20:57:53.097 [nt.ItemStatePredictedEvent] - MIio_executeCmnd predicted to become miIO.ir_play {"freq": 38400, "code":"nE5mkwlk0mk3mEsms2mEsmM2AI8ANJqAGwB9gD8Bz4GtAW2BTYEHg1eCl4N>
2020-01-05 20:57:53.603 [ome.event.ItemCommandEvent] - Item 'Volume_media' received command ON
2020-01-05 20:57:53.607 [ome.event.ItemCommandEvent] - Item 'MIio_executeCmnd' received command miIO.ir_play {"freq": 38400, "code":"nE5mkwlk0mk3mEsms2mEsmM2AI8ANJqAGwB9gD8Bz4GtAW2BTYEHg1e>
2020-01-05 20:57:53.609 [nt.ItemStatePredictedEvent] - MIio_executeCmnd predicted to become miIO.ir_play {"freq": 38400, "code":"nE5mkwlk0mk3mEsms2mEsmM2AI8ANJqAGwB9gD8Bz4GtAW2BTYEHg1eCl4N>
2020-01-05 20:57:54.140 [ome.event.ItemCommandEvent] - Item 'Volume_media' received command ON
2020-01-05 20:57:54.145 [ome.event.ItemCommandEvent] - Item 'MIio_executeCmnd' received command miIO.ir_play {"freq": 38400, "code":"nE5mkwlk0mk3mEsms2mEsmM2AI8ANJqAGwB9gD8Bz4GtAW2BTYEHg1e>
2020-01-05 20:57:54.146 [nt.ItemStatePredictedEvent] - MIio_executeCmnd predicted to become miIO.ir_play {"freq": 38400, "code":"nE5mkwlk0mk3mEsms2mEsmM2AI8ANJqAGwB9gD8Bz4GtAW2BTYEHg1eCl4N>
2020-01-05 20:58:02.372 [vent.ItemStateChangedEvent] - MIio_executeCmnd changed from miIO.ir_play {"freq": 38400, "code":"nE5mkwlk0mk3mEsms2mEsmM2AI8ANJqAGwB9gD8Bz4GtAW2BTYEHg1eCl4NngIOEr4>
2020-01-05 20:58:02.375 [vent.ItemStateChangedEvent] - MiIO_ExecuteCommand changed from {"id":230,"result":["ok"]} to {"id":232,"result":["ok"]}
2020-01-05 20:58:33.352 [vent.ItemStateChangedEvent] - MIio_executeCmnd changed from {"id":232,"result":["ok"]} to {"id":234,"result":["ok"]}
2020-01-05 20:58:33.353 [vent.ItemStateChangedEvent] - MiIO_ExecuteCommand changed from {"id":232,"result":["ok"]} to {"id":234,"result":["ok"]}
2020-01-05 20:58:33.481 [vent.ItemStateChangedEvent] - MIio_executeCmnd changed from {"id":234,"result":["ok"]} to {"id":235,"result":["ok"]}
2020-01-05 20:58:33.482 [vent.ItemStateChangedEvent] - MiIO_ExecuteCommand changed from {"id":234,"result":["ok"]} to {"id":235,"result":["ok"]}
2020-01-05 20:58:33.763 [vent.ItemStateChangedEvent] - MIio_executeCmnd changed from {"id":235,"result":["ok"]} to {"id":237,"result":["ok"]}
2020-01-05 20:58:33.764 [vent.ItemStateChangedEvent] - MiIO_ExecuteCommand changed from {"id":235,"result":["ok"]} to {"id":237,"result":["ok"]}
2020-01-05 20:58:36.629 [vent.ItemStateChangedEvent] - MiIO_ExecuteCommand changed from {"id":237,"result":["ok"]} to {"id":238,"result":["ok"]}
2020-01-05 20:58:36.630 [vent.ItemStateChangedEvent] - MIio_executeCmnd changed from {"id":237,"result":["ok"]} to {"id":238,"result":["ok"]}
2020-01-05 20:58:36.950 [vent.ItemStateChangedEvent] - MIio_executeCmnd changed from {"id":238,"result":["ok"]} to {"id":239,"result":["ok"]}
2020-01-05 20:58:36.951 [vent.ItemStateChangedEvent] - MiIO_ExecuteCommand changed from {"id":238,"result":["ok"]} to {"id":239,"result":["ok"]}
2020-01-05 20:58:37.151 [vent.ItemStateChangedEvent] - MiIO_ExecuteCommand changed from {"id":239,"result":["ok"]} to {"id":240,"result":["ok"]}
2020-01-05 20:58:37.152 [vent.ItemStateChangedEvent] - MIio_executeCmnd changed from {"id":239,"result":["ok"]} to {"id":240,"result":["ok"]}
2020-01-05 20:58:37.332 [vent.ItemStateChangedEvent] - MIio_executeCmnd changed from {"id":240,"result":["ok"]} to {"id":241,"result":["ok"]}
2020-01-05 20:58:37.334 [vent.ItemStateChangedEvent] - MiIO_ExecuteCommand changed from {"id":240,"result":["ok"]} to {"id":241,"result":["ok"]}

Well I noticed, that the IR signals seems to work fine, when there is a pause of 1 second between the commands.
I guess that the binding or device gets confused when there are many parallel connections or commands.

I wrote a script that delay’s every command with one second. In the case that I press for example 10 times fast. I would have to wait 10 seconds before all the commands are processed (instead of a minute like before).
For me that works fine.

Working of the script:

  • Switch button “Volume_media” is presented to the app.
  • When pressed it updates a Number item “volIteration_media”. Default value = 0. Every volume down decreases with it with -1 and every volume add’s 1 to the Number item.
  • When the item “volIteration_media” receives a update, this starts a loop in rule “Volume test - Commander HW”
  • Switch “chkVolLoop_media” is actived when the loop starts. This virtual switch auto deactivates after 10 second’s or when the the commands end.
    This Switch prevents another loop from starting, when there is a active loop present.
  • When the loop finishes it will reset the “volIteration_media”, back to zero.
  • When the number in “volIteration_media” is positive and you press volume down, the number is first reset to 0 before it will go in to the negative number.

items file
Switch Volume_media “Volume up down” {autoupdate=“false”}
Number volIteration_media “Volume iteration”
Switch chkVolLoop_media “Check if Volume loop runs” {expire=“10s,command=OFF”}

Sitemap
Switch item=Volume_media label="Volume" mappings=[ON="+", OFF="-"]

Rules file

rule "Volume - GUI Set iteration level"
        when Item Volume_media received command
                then if (receivedCommand == ON){                        //Volume up
                        var Number level = volIteration_media.state
                        if (level == NULL){                             //Reset to 0 after start system (state isNull)
                                level = 0
                                }
                        else if (level < 0){                            //Reset to 0 if negative
                                level = 0
                                }
                        else if (level < 10){                           //Max 10 levels up (Speaker blow up prevention)
                                level = (level + 3)
                                }
                        volIteration_media.postUpdate(level)
                        }
                else if (receivedCommand == OFF){               //Volume down
                        var Number level = volIteration_media.state
                        if (level == NULL){
                                level = 0
                                }
                        else if (level > 0){
                                level = 0
                                }
                        else if (level > -10){
                                level = (level - 3)
                                }
                        volIteration_media.postUpdate(level)
                        }
        end

rule "Volume test - Commander HW"
        when
                Item volIteration_media changed from 0 to 3 or
                Item volIteration_media changed from 0 to '-3'
        then
                var SwitchItem loopSW = chkVolLoop_media.state
                //logInfo("Volume test - Commander HW","1")
                if (loopSW == OFF || loopSW == NULL){                           //Check for running loops. Exit when present.
                        chkVolLoop_media.postUpdate(ON)                         //Timout = 10 seconds. Block of code will not be executed another time.
                        Thread::sleep(1000)                                     //Wait before chkVolLoop_media state = OFF
                        while (chkVolLoop_media.state == ON && volIteration_media.state != 0){
                                var Number level = volIteration_media.state
                                if (level > 0){                                 //Volume up
                                        MiIO_ExecuteCommand.sendCommand('miIO.ir_play {"freq": 38400, "code":"nE5mkwlk0mk3mEsms2mEsmM2AI8ANJqAGwB9gD8Bz4GtAW2BTYEHg1eCl4NngIOEr4MfgMeCV4MlgI}')
                                        level = (level - 1)
                                        }
                                else if (level < 0){                            //Volume down
                                        MiIO_ExecuteCommand.sendCommand('miIO.ir_play {"freq": 38400, "code":"nE5mcwlk0mk3mEsms1mEsmM2nABDgItNZsAP4A/gc+AQ4EMTkAMpkBTYLVzQCjwIKAI8EPwhvBs8B}')
                                        level = (level + 1)
                                        }
                                volIteration_media.postUpdate(level)
                                Thread::sleep(1200)
                                }
                        chkVolLoop_media.postUpdate(OFF)
                        }
        end

rule "Reset Volume loop"
        when Item chkVolLoop_media changed from ON to OFF
        then
                volIteration_media.postUpdate(0)
        end
  • I’ve added a reset of the “volIteration_media” to 0 before every other (none volume), command (like Power down), so that the volume loop will stop before this command is sent.

    volIteration_media.postUpdate(0) //Kill posible Volume loop
    Thread::slee(1000p)

  • For me every volume up or down push initiates three commands, because a single volume up is not realy noticable. If you want to change this, then just find 3 in the text and change this.

@marcel_verpaalen : For me this workarround works fine.
Do you think it would would have a change to get solved within the binding, if this issue would be handled like a bug (maybe in a seperate ticket)?

1 Like

One last remark.
For the ones, that do not own a android device, but do have an IOS device.

Here is an nice article how to retrieve the “acces token” from this type of device.
Works nice.
Note: You don’t have to query for the key (step 10 & 11).
You can simply browse trough the table and look up the key.

Retrieve token with IOS

With the new version of the miio binding this is not necessary any more. It can recieve the token.

Thanks for the details, everything is working fine and I can get rid of the broadlink binding. :wink:

Please add this as a feature request (‘configurable delay between commands’) in github.
At least that is what I understand from the code… not sure, or do you have some delay in the code and wait for more keypresses
Can’t you use slider or something where you indicate the step=3 in your sitemap?

@marcel_verpaalen. I understand, that there is a new version of the Mio binding. So I will test the new version first.
Thank. you,
Bob

1 Like

The commands miIO.ir_read and miIO.ir_learn does not work anymore for me with openhab3. I wanted to learn new codes, but i don’t get any codes. miIO.ir_play is still working.
I am not shure if its a problem with the binding or with openhab3 itself, but it worked well last year. Anyone with similar problems?
Maybe ist just not getting to the events.log?

I would not directly know why it is no longer possible to send to this device in OH3.x

Can it be that it does not get the double brackets right? In the console you mostly need to surround the whole command with single brackets e.g. 'miIO.ir_learn {"key": 1}'

You could see in the debug log if it send correctly and what the device is returning.

I actually think nowadays we could create bit better support by it, as the binding capabilities have improved.
If you are on 3.2 and willing to test/experiment a bit I could try to create a json database file for it.

1 Like

That would be great. I am on 3.2 and would like to test. :wink:

I am using an ECMA script to learn the codes:

      /// learn
      ///events.sendCommand("Fernbedienungen", 'miIO.ir_learn {"key": "1"}');

      /// read
      ///events.sendCommand("Fernbedienungen", 'miIO.ir_read {"key": "1"}');

      /// play
      events.sendCommand("Fernbedienungen", 'miIO.ir_play {"freq": 38400, "code": "mU3mMwlk4mcwlk0nMwlkzCAA"}');

The ir_read command seems to work:

==> /var/log/openhab/openhab.log <==

2021-12-06 13:07:54.624 [DEBUG] [nal.transport.MiIoAsyncCommunication] - Command added to Queue {"id":4650,"method":"miIO.ir_read","params":{"key":"1"}} -> 192.168.194.82 (Device: 271339092 token: 07DBA65BXXXXXXXXXXXXXXXXB47CD25D Queue: 1).

2021-12-06 13:07:54.843 [DEBUG] [internal.handler.MiIoAbstractHandler] - Received response for device 102C4E54 type: UNKNOWN, result: null, fullresponse: {"id":4650,"error":{"code":0,"message":"no code for this key"}}

2021-12-06 13:07:54.844 [DEBUG] [internal.handler.MiIoAbstractHandler] - Error received for command '{"id":4650,"method":"miIO.ir_read","params":{"key":"1"}}': {"code":0,"message":"no code for this key"}.

==> /var/log/openhab/events.log <==

2021-12-06 13:07:54.606 [INFO ] [openhab.event.ItemCommandEvent      ] - Item 'Fernbedienungen' received command miIO.ir_read {"key": "1"}

2021-12-06 13:07:54.607 [INFO ] [penhab.event.ItemStatePredictedEvent] - Item 'Fernbedienungen' predicted to become miIO.ir_read {"key": "1"}

2021-12-06 13:07:54.609 [INFO ] [openhab.event.ItemStateChangedEvent ] - Item 'Fernbedienungen' changed from {"id":4647,"result":["ok"]} to miIO.ir_read {"key": "1"}

The ir_play command works as well, the ir signal is send. But I don’t get any code by using ir_learn. Normally, the device leds should start blinking after that command, until it receives a signal. It does not start blinking, only if I send the ir_learn several times.

2021-12-06 13:12:28.984 [DEBUG] [nal.transport.MiIoAsyncCommunication] - Command added to Queue {"id":4655,"method":"miIO.ir_learn","params":{"key":"1"}} -> 192.168.194.82 (Device: 271339092 token: 07DBA65BXXXXXXXXXXXXXXXXB47CD25D Queue: 1).

==> /var/log/openhab/events.log <==

2021-12-06 13:12:28.977 [INFO ] [openhab.event.ItemCommandEvent      ] - Item 'Fernbedienungen' received command miIO.ir_learn {"key": "1"}

2021-12-06 13:12:28.978 [INFO ] [penhab.event.ItemStatePredictedEvent] - Item 'Fernbedienungen' predicted to become miIO.ir_learn {"key": "1"}

2021-12-06 13:12:28.980 [INFO ] [openhab.event.ItemStateChangedEvent ] - Item 'Fernbedienungen' changed from miIO.ir_read {"key": "1"} to miIO.ir_learn {"key": "1"}

==> /var/log/openhab/openhab.log <==

2021-12-06 13:12:29.204 [DEBUG] [internal.handler.MiIoAbstractHandler] - Received response for device 102C4E54 type: UNKNOWN, result: ["ok"], fullresponse: {"id":4655,"result":["ok"]}

==> /var/log/openhab/events.log <==

2021-12-06 13:12:29.206 [INFO ] [openhab.event.ItemStateChangedEvent ] - Item 'Fernbedienungen' changed from miIO.ir_learn {"key": "1"} to {"id":4655,"result":["ok"]}

I was checking the mihome app to better understand the communication. Seems the app does not use these commands anymore and rely on some cloud communication.
Would be good to maybe validate if the python-miio implementation still works. If yes, I’m sure we can make it work somehow with openhab as well.

Yes, seems they simply changed the command. Will try to figure it out.

WARNING:miio.device:Found an unsupported model 'chuangmi.remote.v2' for class 'Device'. If this is working for you, please open an issue at https://github.com/rytilahti/python-miio/
Model: chuangmi.remote.v2
Hardware version: esp32

Firmware version: 2.0.6_0006

What is so strange to me is that the device responds with the ‘ok’
Normally if they phase out a command, it will respond with a ‘command not supported’

@kisseler did a test on hos device yesterday and his was still working (but… maybe sending only).
It is very possible that different versions in firmware drive the difference.

Maybe they simply changed the commands. But we don’t are aware of the new ones. :wink:

Well, I can give a hint… These are the requests they make
only local commands left seems to be the indicatorLamp.

	Line 1583: callMethod('get_indicatorLamp'
	Line 1611: callMethod('set_indicatorLamp'
	Line 2651:('/v2/irdevice/controller/add'
	Line 2687:('/v2/irdevice/controller/keys/set'
	Line 2698:('/v2/irdevice/controller/key/add'
	Line 2737:('/v2/irdevice/controller/key/del'
	Line 2749:('/v2/irdevice/controller/keys'
	Line 2761:('/v2/irdevice/controller/key/click'
	Line 2773:('/v2/irdevice/send_key'
	Line 2810:('/v2/ircode/categories'
	Line 2822:('/v2/ircode/category/brands'
	Line 2834:('/v2/ircode/controller/keys'
	Line 2846:('/v2/ircode/category/brand/controllers'
	Line 2858:('/v2/ircode/area/provinces/china'
	Line 2868:('/v2/ircode/area/province/cities'
	Line 2880:('/v2/ircode/sps'
	Line 2892:('/v2/ircode/area/city/areas'
	Line 2904:('/v2/ircode/sp/controllers'
	Line 2914:('/v2/ircode/iptv/brands'
	Line 2926:('/v2/ircode/iptv/brand/controllers'
	Line 2938:('/v2/ircode/controller/functions'
	Line 2950:('/v2/irdevice/controller/functions'
	Line 2962:('/v2/ircode/area/area_id'
	Line 2974:('/v2/ircode/area/lineups'

You could try it to see if anything appears.
chuangmi.remote.v2.json (936 Bytes)