Xiaomi Mi Infrared Remote Control

@txano

Hi, is this still possible, I cannot find Mi IO binding not in openhab not in documentation here https://docs.openhab.org/addons/bindings.html
Or has the name changed perhaps?

The binding is not yet merged in the regular oh distribution. Hence the documentation also is bit merged.

To see the documentation, go to the eclipse market website, follow the link to the github repository.

However better read the topic from xiaomi robot vacuum add it has more details than the docu

1 Like

Thanks, will do :slight_smile:

I’m trying the miIO.ir_read[“key” : 1 ] command and I get the following error.

09:39:32.085 [INFO ] [smarthome.event.ItemCommandEvent     ] - Item 'ChuangmiIrV2_miio66047370_Actions_ExecuteCommand' received command miIO.ir_read["key" : 1 ]
09:39:32.088 [WARN ] [rnal.transport.MiIoAsyncCommunication] - Send command 'miIO.ir_read' with parameters ["key" : 1 ] -> 192.168.1.119 (Device: 03EFCD8A) gave error com.google.gson.stream.MalformedJsonException: Unterminated array at line 1 column 9 path $[1]
09:39:32.090 [INFO ] [smarthome.event.ItemStateChangedEvent] - ChuangmiIrV2_miio66047370_Actions_ExecuteCommand changed from miIO.ir_read[1] to miIO.ir_read["key" : 1 ]
09:39:32.090 [ERROR] [rnal.common.AbstractInvocationHandler] - An error occurred while calling method 'ThingHandler.handleCommand()' on 'org.openhab.binding.miio.handler.MiIoUnsupportedHandler@300f062e': com.google.gson.stream.MalformedJsonException: Unterminated array at line 1 column 9 path $[1]
com.google.gson.JsonSyntaxException: com.google.gson.stream.MalformedJsonException: Unterminated array at line 1 column 9 path $[1]
	at com.google.gson.internal.Streams.parse(Streams.java:60) [22:com.google.gson:2.7.0]
	at com.google.gson.JsonParser.parse(JsonParser.java:84) [22:com.google.gson:2.7.0]
	at com.google.gson.JsonParser.parse(JsonParser.java:59) [22:com.google.gson:2.7.0]
	at com.google.gson.JsonParser.parse(JsonParser.java:45) [22:com.google.gson:2.7.0]
	at org.openhab.binding.miio.internal.transport.MiIoAsyncCommunication.queueCommand(MiIoAsyncCommunication.java:133) [237:org.openhab.binding.miio:2.3.0.201803092003]
	at org.openhab.binding.miio.handler.MiIoAbstractHandler.sendCommand(MiIoAbstractHandler.java:190) [237:org.openhab.binding.miio:2.3.0.201803092003]
	at org.openhab.binding.miio.handler.MiIoUnsupportedHandler.handleCommand(MiIoUnsupportedHandler.java:51) [237:org.openhab.binding.miio:2.3.0.201803092003]
	at sun.reflect.GeneratedMethodAccessor98.invoke(Unknown Source) ~[?:?]
	at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) ~[?:?]
	at java.lang.reflect.Method.invoke(Method.java:498) ~[?:?]
	at org.eclipse.smarthome.core.internal.common.AbstractInvocationHandler.invokeDirect(AbstractInvocationHandler.java:153) [109:org.eclipse.smarthome.core:0.10.0.b1]
	at org.eclipse.smarthome.core.internal.common.InvocationHandlerSync.invoke(InvocationHandlerSync.java:59) [109:org.eclipse.smarthome.core:0.10.0.b1]
	at com.sun.proxy.$Proxy189.handleCommand(Unknown Source) [237:org.openhab.binding.miio:2.3.0.201803092003]
	at org.eclipse.smarthome.core.thing.internal.profiles.ProfileCallbackImpl.handleCommand(ProfileCallbackImpl.java:72) [116:org.eclipse.smarthome.core.thing:0.10.0.b1]
	at org.eclipse.smarthome.core.thing.internal.profiles.SystemDefaultProfile.onCommandFromItem(SystemDefaultProfile.java:49) [116:org.eclipse.smarthome.core.thing:0.10.0.b1]
	at sun.reflect.GeneratedMethodAccessor96.invoke(Unknown Source) ~[?:?]
	at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) ~[?:?]
	at java.lang.reflect.Method.invoke(Method.java:498) ~[?:?]
	at org.eclipse.smarthome.core.internal.common.AbstractInvocationHandler.invokeDirect(AbstractInvocationHandler.java:153) [109:org.eclipse.smarthome.core:0.10.0.b1]
	at org.eclipse.smarthome.core.internal.common.Invocation.call(Invocation.java:53) [109:org.eclipse.smarthome.core:0.10.0.b1]
	at java.util.concurrent.FutureTask.run(FutureTask.java:266) [?:?]

I tried a few different json command but no sucess… Is there souce code for this somewhere?

OK got it to work :slight_smile:

First add to the Execute Command action

miIO.ir_learn {"key": "1"}

The command is automaticaly executed, check the logs. Use Karaf

openhab> log:tail org.openhab.binding.miio

then enter

miIO.ir_read {"key": "1"}

and read the token

then enter

miIO.ir_play {"freq": 38400, "code": "Z6VHADUCAACbBgAAuggAAIIRAABmIwAAQJwAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA0AAAAEAAAAAAQEBAAEBAQEAAAAAAQAAAAEBAQEAAQEBBQJAA="} 

The IR signal should be sent :slight_smile:

Some help here -> https://github.com/rytilahti/python-miio/issues/175

2 Likes

Nice you figured it out.
You can add that final command to a rule for easy execution

Hi,

at first thanks for sharing your progress. I’m stuck at the very first step: i don’t know how to add the execute command action

so if i run the openhab console and type

miIO.ir_read {"key": "1"}

the response is

Command not found: miIO.ir_read

Could you please explain how to add this custom command?

If you are trying to get the token I would advice you follow this guide:

I followed these commands I got my token.

$ npm install -g miio
$ miio discover

thank you. i alread got the token, i just don’t know how to achieve this:

i installed the binding, found the IR-device, set the token, and the THING is shown as ONLINE. But how to edit/add the actions?

these channels are marked as advanced, hence you need to do one more click in the paperUI to make them visible (the “SHOW MORE” button next to the channels definition in the thing edit,)

I just realized, that this is part of the control-tab in PaperUI … I tried to find it in the config-tab
thanks for your help. So finally i got it working. I can trigger the IR-Remote from rules. Thanks for the help!

it works flawless with the signals for my Sony-TV but the learned signals for the Yamaha AVR don’t work. could it be necesarry to change the “freq” in the miIO.ir_play command?

Edit/Solution:
i tried the app"anymote" for android to control the AVR via my mobile … these signals can be leared by the xiaomi ir whereas the signals from the original yamaha remote did not work

Hello,
What type of thing from the binding did you create?
I get stuck at

  • The command is automaticaly executed, check the logs. Use Karaf

I understand that I change the value on Execute Command and then switch Execute Test Command (Experimental)

I see the log changing to:

20:47:38.533 [INFO ] [g.miio.handler.MiIoUnsupportedHandler] - Start Experimental Testing of commands for device 'Mi Remote v2 (chuangmi.ir.v2)'.
20:47:38.590 [INFO ] [g.miio.handler.MiIoUnsupportedHandler] - Test command 'miIO.info'. Response: '59'

What do I do next?
Point my actual remote control to the Xiaomi and press a button? Nothing happens
How do the Xiaomi learns?

Thanks

I too are up to this stage.
Yet I have not been able to find this in the Control section of PaperUI - Where did you find it? -

Edit: I have managed to get it up by creating and linking items to it.
I have put in the input put in
“miIO.ir_play {“freq”: 38400, “code”: “Z6VHADUCAACbBgAAuggAAIIRAABmIwAAQJwAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA0AAAAEAAAAAAQEBAAEBAQEAAAAAAQAAAAEBAQEAAQEBBQJAA=”}”

As a test and the Ir Blaster led blinks like it is sending a signal. The question is how do I get the correct “code:” to input to turn on say the AC etc ??

Hello,

Please, tell me how you created the rule, I have tried it with this command but it does not perform the action…

Irda_Comando.sendCommand(miIO.ir_play {“freq”: 38400, “code”: “Z6U7AN4BAAAVAgAA1wUAALQLAABrJQAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAABDIRAQECEQEBAhIRAQEBAQECEQEBAhIRAhEBAQIQA=”})

Irda_Comando is the Item…

You need to make a character escape in the string:
(backslash “\” before all " in the string)

executecommand.sendCommand("miIO.ir_play {\"freq": \“38400\”, \“code\”: \“Z6VLADECAACRBgAAuQgAAHsRAABIIwAApJwAAMh3AQAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA0AAAQAAAAAAAQEAAQEBAQEAAAABAAAAAAEBAQABAQEBBQJGAkAA==\”} ")

This is my rule and works great!

Hi there,

My device doesn’t get discovered. Did you install it as a child of the gateway?

How did you install it?

Thanks,

Pim

Another problem: my device, a Cisco ISB6030: all IR-functions can be received and learned, except for the on/off functionality.

When I try to learn, I receive this code:
Z6WzAJgAAAD6AAAAIwEAAMMBAABwAgAAFAMAALxgAQAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAATIEAgQFAgICAgQDBAICBQIGATIEAgQFAgICAgQDBAICBQIGATIEAgQFAgICAgQDBAICBQIGATIEAgQFAgICAgQDBAICBQIGATIEAgQFAgICBAQDBAECBQIAA=

I send out this code:

 mirobo --ip 192.168.1.9 --token f0eac52fea895e0b136ae5eb32e54c1a raw_command miIO.ir_play '{"freq": 38400, "code":"Z6WzAJgAAAD6AAAAIwEAAMMBAABwAgAAFAMAALxgAQAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAATIEAgQFAgICAgQDBAICBQIGATIEAgQFAgICAgQDBAICBQIGATIEAgQFAgICAgQDBAICBQIGATIEAgQFAgICAgQDBAICBQIGATIEAgQFAgICBAQDBAECBQIAA="}'

The IR sender blinks, so it emits, but there is no action, the state of the machine doesn’t change.

Searching for a while on the internet but still no answers so far…

Hi, I’m using Openhab2.4 snapshot, I just installed the Xiaomi Mi IO Binding and successfully discover my “Mi IR remote”, but I cannot input any command, my command field was disappear.1
than I use “ssh -p 8101 openhab@localhost” and “log:tail org.openhab.binding”, I saw respone when I switch on and off the “(experimental)Execute Test Commands”, but when I type " miIO.ir_learn[“key” : 1]" and point the remote to “Mi IR Remote” and press any button, there are nothing happen, nothing display.


any help?

You need to send the command to the command channel (marked as advance, so need use show more in paperui) or execute from rule with proper escaping. See a few posts ago