Xiaomi Chuangmi_ir learn command does not work

Hi guys, need some help (again).

I can’t learn IR commands.
I get the following log when I call the chuangmi.learn_command service :

2017-12-28 22:32:18 INFO (MainThread) [custom_components.switch.chuangmi_ir] Press the key you want HASS to learn
2017-12-28 22:32:18 ERROR (MainThread) [custom_components.switch.chuangmi_ir] <class ‘str’>
2017-12-28 22:32:18 ERROR (MainThread) [custom_components.switch.chuangmi_ir]
2017-12-28 22:32:19 ERROR (MainThread) [custom_components.switch.chuangmi_ir] <class ‘str’>
2017-12-28 22:32:19 ERROR (MainThread) [custom_components.switch.chuangmi_ir]
2017-12-28 22:32:20 ERROR (MainThread) [custom_components.switch.chuangmi_ir] <class ‘str’>
2017-12-28 22:32:20 ERROR (MainThread) [custom_components.switch.chuangmi_ir]
2017-12-28 22:32:21 ERROR (MainThread) [custom_components.switch.chuangmi_ir] <class ‘str’>
2017-12-28 22:32:21 ERROR (MainThread) [custom_components.switch.chuangmi_ir]
2017-12-28 22:32:22 ERROR (MainThread) [custom_components.switch.chuangmi_ir] <class ‘str’>
2017-12-28 22:32:22 ERROR (MainThread) [custom_components.switch.chuangmi_ir]
2017-12-28 22:32:23 ERROR (MainThread) [custom_components.switch.chuangmi_ir] <class ‘str’>
2017-12-28 22:32:23 ERROR (MainThread) [custom_components.switch.chuangmi_ir]
2017-12-28 22:32:25 ERROR (MainThread) [custom_components.switch.chuangmi_ir] <class ‘str’>
2017-12-28 22:32:25 ERROR (MainThread) [custom_components.switch.chuangmi_ir]
2017-12-28 22:32:26 ERROR (MainThread) [custom_components.switch.chuangmi_ir] <class ‘str’>
2017-12-28 22:32:26 ERROR (MainThread) [custom_components.switch.chuangmi_ir]
2017-12-28 22:32:27 ERROR (MainThread) [custom_components.switch.chuangmi_ir] <class ‘str’>
2017-12-28 22:32:27 ERROR (MainThread) [custom_components.switch.chuangmi_ir]
2017-12-28 22:32:28 ERROR (MainThread) [custom_components.switch.chuangmi_ir] <class ‘str’>
2017-12-28 22:32:28 ERROR (MainThread) [custom_components.switch.chuangmi_ir]
2017-12-28 22:32:29 ERROR (MainThread) [custom_components.switch.chuangmi_ir] <class ‘str’>
2017-12-28 22:32:29 ERROR (MainThread) [custom_components.switch.chuangmi_ir]
2017-12-28 22:32:30 ERROR (MainThread) [homeassistant.core] Error doing job: Task exception was never retrieved
Traceback (most recent call last):
File “/usr/lib/python3.4/asyncio/tasks.py”, line 237, in _step
result = next(coro)
File “/srv/homeassistant/lib/python3.4/site-packages/homeassistant/core.py”, line 1031, in _event_to_service_call
yield from service_handler.func(service_call)
File “/home/homeassistant/.homeassistant/custom_components/switch/chuangmi_ir.py”, line 72, in _learn_command
_LOGGER.error(type(res[“code”]))
KeyError: ‘code’

My conclusion is that the service is correctly called, after it’s called I start pushing the on/off button of the AC in the Mi-Home-app. But it seems to not capture those commands, and after 10 seconds it quits. I’ve done this multiple times, pushing fast/slow. Restarted the ir blaster, restarted HASS.

My config/background :
The Xiami Remote IR. is setup, and I can control my AC and my TV via the Mi Home-app. So far so good.
Next step was to install the chuangmi_ir.py . With some bumps I got that to work with miio version 0.3.3 on a Hass 0.59.2 installation , Python 3.4 VENV. I can see the switch in my Homeassistant Dashboard.
I got the token (32 chars, hex) and the correct IP. I can call the learn_command service from the dashboard.

config.yaml :

switch:
platform: chuangmi_ir
name: “irremote”
host: !secret chuangmi_ip
token: !secret chuangmi_key
timeout: 20
switches:
airco:
command_on: ‘’
command_off: ‘’

logger:
default: warn
logs:
custom_components.switch.chuangmi_ir: debug

What am I missing ?

@syssi anything you can help with ?

Ok, for future reference. The thing I was missing was using the original remote instead of using the app.

Doh. Well, only took me a month to figure that out.