Xiaomi Chuangmi_ir (Universal IR Remote Controller)


What would be the best way to create a On/Off button again?


@syssi I’ve moved from the custom component to the remote.xiaomi_miio component but I recieve the following error message in my HASS setup. I’m on Home Assistant 0.63.3. Do you have any idea what’s causing the error message below?

Error while setting up platform xiaomi_miio
12:15 PM deps/lib/python3.6/site-packages/construct/lib/init.py (ERROR)

Log Details (ERROR)
Fri Feb 23 2018 12:15:06 GMT+0100 (W. Europe Standard Time)

Error while setting up platform xiaomi_miio
Traceback (most recent call last):
File “/usr/lib/python3.6/site-packages/homeassistant/helpers/entity_platform.py”, line 84, in async_setup
SLOW_SETUP_MAX_WAIT, loop=hass.loop)
File “/usr/lib/python3.6/asyncio/tasks.py”, line 358, in wait_for
return fut.result()
File “/usr/lib/python3.6/asyncio/futures.py”, line 245, in result
raise self._exception
File “/usr/lib/python3.6/asyncio/tasks.py”, line 180, in _step
result = coro.send(None)
File “/usr/lib/python3.6/asyncio/coroutines.py”, line 210, in coro
res = func(*args, **kw)
File “/usr/lib/python3.6/site-packages/homeassistant/components/remote/xiaomi_miio.py”, line 66, in async_setup_platform
from miio import ChuangmiIr, DeviceException
File “/usr/lib/python3.6/site-packages/miio/init.py”, line 2, in
from miio.protocol import Message, Utils
File “/usr/lib/python3.6/site-packages/miio/protocol.py”, line 21, in
from construct import (Struct, Bytes, Const, Int16ub, Int32ub, GreedyBytes,
File “/config/deps/lib/python3.6/site-packages/construct/init.py”, line 22, in
from construct.core import *
File “/config/deps/lib/python3.6/site-packages/construct/core.py”, line 11, in
from construct.lib import *
File “/config/deps/lib/python3.6/site-packages/construct/lib/init.py”, line 3, in
from construct.lib.bitstream import RestreamedBytesIO, RebufferedBytesIO
ImportError: cannot import name ‘RestreamedBytesIO’


Please goto your configuration directory and provide the content of:



This is the content of “config/deps/lib/python3.6/site-packages/construct/version.py”

version = (2,8,22)
version_string = "2.8.22"
release_date = “2018.01.18”


Please delete


and restart homeassistant / hassio.


I dont have a folder called miio, will delete construct and restart


This is fine. Good luck!


That solved it :slight_smile:


After listening to your suggestion, used the official xiaomi_miio. Everything works fine (with a little more work), just that it takes at least 3 seconds to fire from Xiaomi IR, whereas it was immediate with your chuangmi_ir. Not sure where to ask, but getting these logs with xiaomi_miio. Any help?

Got error when receiving: timed out
1:57 AM components/remote/xiaomi_miio.py (ERROR)
Retrying with incremented id, retries left: 3
1:55 AM components/remote/xiaomi_miio.py (WARNING)


I guess this issue will be fixed by:


I really wanted a toggle switch back too. It’s kind of tricky to reliably track the state of my dumb TV. This template switch seems to work for me so far. If the on script was fired after the off, then the TV should be ‘on’. I think the logic as is falls over after a restart when the last_triggered attribute is reset to Null.

- platform: template
        friendly_name: "TV"
        value_template: "{{ as_timestamp(states.script.tv_off.attributes.last_triggered)  | int  < as_timestamp(states.script.tv_on.attributes.last_triggered)  | int }} "
          service: script.tv_on
          service: script.tv_off


Some one can explain me how to get RAW codes and pronto codes?
I configured some codes on the xiaomi ir remote using mihome application, can I see the code it use?

And sorry for my inglish :slight_smile:


If you use the remote.xiaomi_miio_learn_command service you will receive recordings in raw format. If you look for some online database of infrared commands you will find “pronto codes” mostly.


Dear syssi thanks!
I learn alot here with your posts, thanks for help us!


Anyone else having trouble with the previously learned command not working anymore?

When I try relearning them the codes are different and some not working…


Yes. I often get (slightly) different codes every time I try to learn a command. My approach is to try to learn it say, 10 times, and use the most frequently learnt code. I don’t really get it…


Hi all

I just setup the IR all ok, discovered the token and added the device.

I called the learn service and it received the code from my Air con remote all ok

I have added it to my config and a script but when i trigger the script the device just turns off, only way to get it back on is to pull power and reinstall.

  - platform: xiaomi_miio
    name: "IR remote"
    token: 10b5120a9bba962f4fa1a95b6e3d54d5


########## Remote control ###############

      - service: remote.send_command
        entity_id: 'remote.xiaomi_miio_192_168_1_113'
            - 'air_con_on'


Do you mean your air conditioner crashs if you send this infrared command?!


Sorry, I mean the xiaomi IR shuts off.

The blue light goes out like it’s turned off, in the logs it’s says it cannot connect to the I’s ip address.


Could you try to learn the same command with a shorter key press of the remote control?